In WooCommerce, archive-product is the default template for all product categories. I want to create a new product category template for one parent category and all of its children.
I've created a new template archive-foo.php
Now I need to change the code inside taxonomy-product_cat.php and tell it to use archive-foo.php "if it's my parent category or any of its children".
Here is my code inside taxonomy-product_cat.php:
if (is_product_category( 'foo-category' ) || cat_is_ancestor_of(19, get_queried_object()->term_id )){ wc_get_template( 'archive-foo.php' );
} else { wc_get_template( 'archive-product.php' ); }
Currently, it's working for the parent category, but none of its children. Any help would be greatly appreciated.