As a workaround I have this temporary solution:
$the_menu = wp_get_nav_menu_object('Some Menu');
$the_menu_items = wp_get_nav_menu_items($the_menu);
$category_products = [];
foreach ($the_menu_items as $index => $menu_category) {
if ($menu_category->object_id == $category->term_id ) {
$category_submenu = $menu_category;
}
}
foreach ($the_menu_items as $index => $menu_product) {
if ($menu_product->type_label == 'Product'
&& $menu_product->menu_item_parent == $category_submenu->ID
) {
$category_products[] = $menu_product;
}
}
I’m parsing all menu items (both parent items and sub items), getting the necessary item based on current category ID and then retrieving the sub items (products) of each category by parsing all the items one more time and checking if current item (product) parent ID matches with the parent category item ID and I just put it into an array.
Related Posts:
- how to get woocommerce product attribute slug
- How to display product price of the product in loop
- Limit users to one active subscription in WooCommerce Subscriptions? [closed]
- How to build a plugin that supports authenticated POST requests to the REST API from external servers?
- How do I add a text input field for customers to leave a note on a single WooCommerce product page?
- WooCommerce add_to_cart() with custom price [closed]
- WooCommerce HTML after short description if product is in specific category
- How to get total count for each star rating?
- WooCommerce pages accessible to logged in members only
- WooCommerce Apply Coupon to order AFTER taxes
- Auto update cart after quantity change
- echo product id and product_item_key in cart [closed]
- How can I display *only* the child category of a product?
- paypal not showing on woocommerce payments
- Target WooCommerce Product Gallery Image (rather than Featured Image) for og:image
- Save and display selected product option and cost as cart item data in WooCommerce
- How to implement Handling Fee like the Shipping on Cart and Checkout page on WooCommerce [closed]
- why featured product not updated in postmeta table in woocommerce?
- How to remove product base from WooCommerce product permalinks
- woocommerce image product add a class and data-src attributes
- Woo create order only after payment done
- Change Category Widget Dropdown List Select Name
- wooCommerce checkout page State / County (optional) validate not working
- Remove the link from the thumbnail and product title on woocommerce
- WooCommerce – Multiple meta query not working
- How to display the result of a custom metabox in the frontend [closed]
- Quantity on the product card and subtotal disappear [closed]
- Admin access for custom user capabilities
- Display product category taxonomy terms in WooCommerce shop loop
- WooCommerce limited role
- Skip WooCommerce 4.5.x onboarding with WP-CLI [closed]
- how to show store name when I add a product on cart in woocommerce(woocommerce multi store)?
- When Free shipping is available hide other shipping methods except Local pickup in WooCommerce [closed]
- Woocommerce Moving Review Below add to cart breaks button
- WP All Import manual Cron
- Create archive page for woocommerce attribute
- Refund from wooCommerce with stripe [closed]
- Download permission for non-purchased products
- Display FREE for $0 products in woocommerce ++++ [closed]
- How to add existing categories into a post using wp_insert_post
- create comment box in woo-commerce shop order [closed]
- Woocommerce: how to know if the customer is canceled the order or the shop owner? [closed]
- WooCommerce Hook: Content get’s displayed twice and not AFTER the order total
- Have I got this IF Statement correct?
- Setting an attribute as variation in woo commerce via php [duplicate]
- WooCommerce Price Filter not working? [closed]
- How to replace WooCommerce Product Gallery Trigger icon using PHP/CSS? [closed]
- How to remove unwanted text bug in wordpress site
- get woocommerce product image url and price from database [closed]
- Trying to style Woocommerce sidebar Cart Widget [closed]
- Cancelled orders move to Trash automatically in Woocommerce – how to disable?
- Adding Field in WooCommerce
- Woocommerce Sort by default variation price
- Add Name and SKU Main Product to Secondary Product to Cart
- How can i access woocommerce order variables inside shortcode?
- Conditional logic – if product has a parent category, echo this
- WooCommerce set default product sort to product description (content) [closed]
- Custom action not working in Woocommerce
- Add rewrite rule to make Woocommerce product category page seo friendly
- How to show the urls inside the simple product when the customer buys it?
- Custom template – query issues
- Woocommerce variable product’s total amount by javascript
- Prices showed without decimals separator on BACKEND. Weight/price not working on Wocommerce
- add the attribute value above the english product title
- How to add woocommerce products header title in woocommerce_breadcrumb hook to function.php
- Save product short description in order (without updating in order details if it is updated in product)
- Can I create categories or attribute contain more than 70,000?
- Format decimals of get_price_html
- apply_filter and add_filter conflict
- Combine one action and one filter
- How to run code when cookie is added?
- Return product list based on current product attribute
- Getting in an exception for get product detail by id in woocommerce REST api
- Woocommerce Ajax add to cart redirect to homepage
- Applying pre-production modifications
- WooCommerce – Remove automaticly added membership product if user remove regular product from cart
- Temporary access to page with URL sent to email
- How to save a Woocomerce metabox input as a metadata field
- Use woocomerce shop filters on other pages
- Product related to post by title
- How do you programatically add a booking item to the cart?
- populating extra field with woocommerce categories
- Woocommerce Shop Manager Capabilities
- customize src attribute in woocommerce single product image
- How to tell woocommerce slider to use thumbnails
- Add customer name to woocommerce email-header.php heading
- woocommerce sort by dropdown styling
- Mysql query – amount spent by customer
- How to change the link of product menu from wordpress admin panel
- bulk media crop for featured images
- Users credentials and syncing from third party with WooCommerce
- Anchor link to every product
- Plugin could not be activated because it triggered a fatal error
- Woocommerce custom product with JS script, can’t understand how it works [closed]
- Rename woocommerce button [closed]
- Making product image in woocommerce invoice linkable [closed]
- Create WordPress account on different domain when WooCommerce order completed
- Creating a woocommerce order when a user creates an account
- I want to update shipping charge $0 for all Woocommeerce Subscription auto-renewal orders
- Conflict between Woocommerce Booking + Woocommerce Product Options [closed]