vendredi 18 mai 2018

woocommerce category depth as condition with if statement

Im not sure the best way to proceed here.

I have categories laid out like this (a simplified version):

-fruit
--apple
---large
---small

--banana
---var1
----large
----small
---var2
----small
----large

I want to use the depth of a category as the condition in an if statement to achieve something like this:

if category is depth 2 (apple>large) do this

else if the category is depth 3 (banana>var1>small) do something else.

Ive tried using the function from here but have been unable to get anything back other than an empty array! http://www.devdevote.com/cms/wordpress-hacks/get_depth.html

Aucun commentaire:

Enregistrer un commentaire