I'm new in Woocommerce. I would like to customize the template for the product page of Woocommerce just for the books category. I replaced the content-single-product.php file with a custom one modifying the code in single-product.php file like this:
<?php while ( have_posts() ) : the_post(); ?>
<?php
global $post;
$terms = wp_get_post_terms( $post->ID, 'product_cat' );
foreach ( $terms as $term ) $categories[] = $term->slug;
if ( in_array( 'livros', $categories ) ) {
wc_get_template_part( 'content', 'single-product-books' );
} else {
wc_get_template_part( 'content', 'single-product' );
}
?>
<?php endwhile; // end of the loop. ?>
Now I want to do the same in replacing the product-image.php file with this one product-image-books.php. Tried like this but not working:
global $post;
$terms = wp_get_post_terms( $post->ID, 'product_cat' );
foreach ( $terms as $term ) $categories[] = $term->slug;
if ( in_array( 'books', $categories ) ) {
wc_get_template_part( 'content', 'single-product-books' );
wc_get_template_part( 'single-product/product', 'image-books' );
} else {
wc_get_template_part( 'content', 'single-product' );
wc_get_template_part( 'content', 'product-image' );
}
?>
This file is in the template folder: woocommerce > single-product. Any help?