Skip to content
Advertisement

Display orders items names excluding a product category in WooCommerce

With WooCommerce, I have faced a problem on my code below: I have tried skip specific category from my loop. Product has been skipped but some remaining products are showing multiple times:

JavaScript

How can I avoid this item name repetition on this loop?

Advertisement

Answer

The variable $product_cat_id is not defined in your code, so your if statement is always true.

To check for a product category in order items, use instead the conditional function has_term(). It will avoid getting product name displayed multiple times and items that belong to 38355 category ID will be excluded.

Here is your revisited simplified code version:

JavaScript

Now it should work as expected

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement