I have a problem, and im struggling from yesterday with it. So, I have web with woocommerce that is still on localhost. I have problem with template override. I overrided loop start, end, content-product.php and content-single-product.php in my theme and that works ok. I have problem with content-single-product.php because I want it to make dependable on category (whatever as identification - id, name, slug). So I found few solutions on google but none will work. In my singe-product.php I replaced
woocommerce_get_template_part( 'content', 'single-product' );
with
if ( is_product_category( 'my-cat-slug' ) )
{
woocommerce_get_template_part( 'content', 'single-product-dogs' );
}
else {
woocommerce_get_template_part( 'content', 'single-product' );
}
I tried putting instead of my-cat-slug actual Cat Name, I tried using !is_product_category to get inverse... Also nothing.
Of course I put single-product.php to woocommerce folder in my theme where rest of working overridden files are. And I created file content-single-product-dogs.php where I copied content from content-single-product.php with some changes, as small as just TEST written somewehere.
Also I tried
if ( ! function_exists( 'woocommerce_content' ) ) {
function woocommerce_content() {
if ( has_term( 'my-cat-slug', 'product_cat' ) ) {
while ( have_posts() ) : the_post();
wc_get_template_part( 'content', 'single-product-dogs' );
endwhile;
}
else {
while ( have_posts() ) : the_post();
wc_get_template_part( 'content', 'single-product' );
endwhile;
}
}
}
That also doesn't work. Everything I use, it always falls back to default overridden content-single-product.php
I have no more ideas. Please someone help :)
P.S Is it possible to change default product-image.php that will be different for that custom content-single-product-dog.php?
Thanks
woocommerce_get_template_partis deprecated in the current version - Reigelhas_term( 'my-cat-slug', 'product_cat' )on the first attempt code..is_product_categoryis when you are viewing a product category page... will not check if product has a category... - Reigel