I want to set different template for the relevant product category. I changed single-product.php file
if (is_product_category( 'first-category' )) {
woocommerce_get_template_part( 'content', 'single-product' );
}else{
woocommerce_get_template_part( 'content', 'single-product-other' );
}
Still is loading content-single-product-other.php file content. I’m sure that the category of the product is checked
it can happen if you have putted single-product-other.php in (yourtheme/woocommerce/) folder and single-product.php in plugin folder.
All you have to do is put both template in your theme’s woocommerce folder(it is the proper way to customize original code).
still if it does not work then try to replace your code
woocommerce_get_template_part( ‘content’, ‘single-product’ );
with this.
wc_get_template_part( ‘content’, ‘single-product’ );
Replying to helgatheviking input. As mentioned the
is_product_category()
call refers to a categoriesarchive
page and not a product assigned to the category type. Here’s my working example for a composite product. ReplaceYourCategory
with theslug
of your category