Add parent name to term list in dropdown (coupon category list)

[ad_1]

We have a clothing store and want to create coupons in WooCommerce that have certain categories excluded. Our category structure is as follows (simplified):

– Men
– – Shirts
– – Jeans
– – Sale
– Women
– – Shirts
– – Jeans
– – Sale

However when we want to select [Men » Sale] from the Exclude categories dropdown picker in [WooCommerce » Marketing » Coupons » Usage Restriction] the list is flattened:

– Jeans
– Men
– Sale
– Sale
– Shirts
– Shirts
– Women

Now it is not clear which categories are actually the one we want to exclude. Have in min, this is a very simplified structure, in the live environment this is even worse.

I hoped for an apply_filter but the get_terms() apparently does have none in code, see source code on github here »

$categories = get_terms('product_cat', 'orderby=name&hide_empty=0');

Since this is not filtered, I don’t see a way to add a parent category to have this as the desired outcome:

– Men
– – Men » Jeans
– – Men » Shirts
– – Men » Sale
– Women
– – Women » Jeans
– – Women » Shirts
– – Women » Sale

Any idea how to get that list now that there is no filter in the code?

  • This topic was modified 6 hours, 16 minutes ago by Ronaldt. Reason: Converted nested lists to plain text (stupid text editor does not like nested lists apparently)

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer