Я новичок в Woocommerce.Я хотел бы настроить шаблон для страницы продукта Woocommerce только для категории книг.Я заменил файл content-single-product.php на пользовательский, изменив код в файле single-product.php следующим образом:
<?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. ?>
Теперь я хочу сделать то же самое при замене изображения продуктаФайл .php с этим продуктом image-books.php.Пробовал вот так, но не работает:
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' );
}
?>
Этот файл находится в папке шаблона: woocommerce> single-product.Любая помощь?