Error on including blade template through woocommerce hooks

HI everyone,
I’m trying to include a blade components on the checkout page through woo hooks (‘woocommerce_checkout_shipping’)

add_action('woocommerce_checkout_shipping', function() {
 echo template('components.checkout-shipping-block');
}, 10);

I created a controller for the checkout page (PageCheckout.php) with a cpt query

namespace App\Controllers;

use Sober\Controller\Controller;

class PageCheckout extends Controller

{
    public  function getPosts()
        {

           $posts = get_posts(array('post_type' => 'area'));

            return array_map(function ($area) {
                return [
                    'id' => $area->ID ?? null,
                    'slug' => $area->post_name ?? null,
                    'name' => $area->post_title ?? null,
                ];
            }, $posts ?? []);
        }
...

i’m trying to debug the array $get_posts on the components (checkout-shipping-block.blade.php), but the array is empty and got a null response.

what am i missing?

Your method doesn’t return anything.

what do you mean?
i just noticed that the component works if it’s included directly without filtering woocommerce hook.

I apologize, I misread it.

This topic was automatically closed after 42 days. New replies are no longer allowed.