corcel / corcel

Use WordPress backend with Laravel or any PHP application

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Menu doesn't return Product Categories added to WordPress menus

haghanihakimi opened this issue · comments

  • Corcel Version: ^6.0
  • Framework Name & Version: Laravel ^9.19
  • PHP Version: ^8.0.2
  • Database Driver & Version: MySQLi - mysqlnd8.1.10

Description:

I'm trying to get "Product Categories" I added to the new menu. So, I created a menu and named it "newnavmenu". Instead of adding Pages, I want to add "Product categories" that I created in WooCommerce Categories.
Now, when I loop through items, the instance() method returns null and there is not specific information about menu items. I can see basic information about newnavmenu itself but nothing related to "Product categories" items I added before.

Steps To Reproduce:

So basically I do exactly what I found in documentation:

Route::get('/', function () {
    $menu = Menu::slug('newnavmenu')->first()->items;

    return view('welcome', compact(
        'menu'
    ));
});

And I try to loop through items in blade file:

@foreach ($menu as $item)
            {{$item->instance()}}
@endforeach

Even if I return $item without insance() method, none of categories is available:

@foreach ($menu as $item)
            {{$item)}}
@endforeach

How do I return "Product Categories" I added to new created menu? Anyone can help please?