the WordPress function cat_is_ancestor_of() is made for WordPress categories, but not for WooCommerce product categories which is a custom taxonomy product_cat.
For Custom taxonomies you can use WordPress term_is_ancestor_of() function like:
term_is_ancestor_of( 19, get_queried_object_id(), 'product_cat' )
So in your code:
if ( is_product_category( 'foo-category' ) || term_is_ancestor_of( 19, get_queried_object_id(), 'product_cat' ) ) {
wc_get_template( 'archive-foo.php' );
} else {
wc_get_template( 'archive-product.php' );
}
This time it should work.
Related Posts:
- How to get WooCommerce Product Category Link by ID?
- Approach for saving a product attribute values with a custom UI in a woocommerce+dokan set up [closed]
- Set download limit and expiry for WooCommerce downloadable products in specific categories
- Remove pagination from WooCommerce product categories on admin edit navigation menus
- Taxonomy , subtaxonomy,child taxonomy of a product woocommerce
- Woocommerce custom taxonomies page
- Outputting an array of term meta values in a custom WooCommerce tab?
- Programatically added attribute, set to ‘show on product page’ automatically. Woocommerce [closed]
- Get child product categories from parent product category in WooCommerce
- Top level parent taxonomy ID
- Woocommerce product search result layout page
- Filter WooCommerce admin products list by a custom taxonomy
- Woocommerce: How to change the add to cart text in a certain category? [closed]
- Catchable fatal error on custom category post
- Get custom category image from menu
- Hide product categories and taxonomy terms in menu if empty
- Display related products based on 2 specific product attributes values in WooCommerce
- woocommerce custom product category template
- Getting WooCommerce product related child categories
- Hiding taxonomies with no children WP_Query & tax_query
- How to display ACF taxonomy checkbox links on WooCommerce product category archive
- Hide custom Woocommerce taxonomies when empty
- Add attribute taxonomy through code don’t appear in admin product page
- Showing custom taxonomy in woocommerce signle product page
- Adding term to a custom taxonomy based on term from product category
- Warning: Undefined variable $post in C:\xampp\htdocs\… after PHP upgrade
- Admin only taxonomies?
- Fill New Taxonomies
- Infinite Scroll appending Next Product Category Term pages
- How to exclude woocommerece product category in search results?
- Cloning product not copying custom taxonomies
- Check if any available product has specific attribute
- how to show product custom taxonomies in woocommerce rest api
- WordPress search form and search result through ACF field in custom taxonomy
- Get user created Woocommerce attributes ( taxonomies ) [closed]
- Custom order of taxonomy using wp_get_object_terms and woocommerce_term_meta
- How do you search for a post by custom taxonomy?
- Display woocommerce product_cat child terms with thumbnails
- Woocommerce – how to get and display selected variations on single product page
- How do I check if a post has a term with a particular ancestor/parent?
- Creating a custom archive page for WooCommerce products based on tags
- Hide empty categories on widget
- Change filter id into slug
- Set Variant options/attributes values on WooCommerce
- Check if Current Category has Children
- How to assign multiple roles for capabilities array withini register_taxonomy function?
- Determine Term depth
- pre_get_posts with tax_query causes empty result
- Programatically inserting terms doesn’t update the Taxonomy admin UI
- wp_insert_term auto unique name
- search query within custom taxonomy term, post title and meta field
- The same slug in multiple taxonomies
- Listing child terms of parent term
- Display the taxonomy name of the current term
- Advanced Tax Query
- Last posts from custom taxonomy
- How to add a body class based on a custom taxonomy term
- Search by type posts and taxonomy
- Get Taxonmy Term ID For Current Post
- Can I limit term selection to one plus parent?
- Changing stylesheet depending on custom taxonomy terms
- Taxonomy with_front causes all
- Why is my taxonomy template not shown?
- cannot get multiple loops using tax_query
- How Can I Change a Taxonomy URL Based On The Originating URL?
- How To Assign “Taxonomy per Taxonomy”?
- How to add a Rewrite Rule / Category Structure
- Hide posts having children terms when display posts by category in edit.php
- How to have two different versions of a tag/category/taxonomy archive page?
- Rewrite Rule Working for all but one of the taxonomies created
- Extend & Search Native WordPress Image Galleries With Tags and Taxonomies?
- How to use taxonomy term as a value of get_template_part?
- Hierarchical Taxonomy Terms Select Menu Output with selected=”selected” Set
- Sorting Custom Posts on Archive page with pagination
- How to fetch the data from Advanced Custom post when we search specific keyword or field name related to the post?
- 2 custom post-type and 1 taxonomy
- Displaying Custom Taxonomy without a hyperlink
- Is it safe to register a taxonomy without using any hooks?
- My custom taxonomy page is leading in 404 page
- Different Taxonomy Values for Each Post
- Custom taxonomies not showing up in admin menu
- Get list of taxonomies associated with users
- check if a taxnomy queried in $wp_query?
- passing moree than one value of slugs in taxonomy using variable
- Items from media library won’t get added to a custom taxonomy
- Custom field with terms from another taxonomy programmatically
- Taxonomies and subtaxonomies relations
- Retrieve & Display User Meta Values from Checkboxes
- Custom taxonomy if statement
- Group & Sort Taxonomy terms by letter – Is there a better way?
- Multiple taxonomies, what should the permalink look like?
- Child Pages and Custom Taxonomies
- Determine if Term has Grandparent/Great-Grandparent
- Loop custom post type by taxonomy (Category)
- Create heirachy of post terms from array & assign post to terms
- Hook to filter based on form value and insert term
- Change get_author_posts_url / Author URL via filter
- Prevent random entries in hierarchical false taxonomies
- Exporting CSV of users with custom user taxonomies out of WordPress
- Sub-pages of Custom Taxonomies