You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.7 KiB
52 lines
1.7 KiB
<?php
|
|
/**
|
|
* The template for displaying WooCommerce pages
|
|
*/
|
|
|
|
if (!defined('ABSPATH')) {
|
|
exit;
|
|
}
|
|
|
|
$context = Timber::context();
|
|
|
|
// Добавляем WooCommerce контекст
|
|
if (class_exists('WooCommerce')) {
|
|
$context['is_woocommerce'] = true;
|
|
$context['is_product'] = is_product();
|
|
$context['is_shop'] = is_shop();
|
|
|
|
// Получаем текущий продукт если это страница товара
|
|
if (is_product()) {
|
|
$context['product'] = wc_get_product(get_the_ID());
|
|
}
|
|
}
|
|
|
|
// Определяем какой шаблон использовать
|
|
if (is_product()) {
|
|
$product_id = get_the_ID();
|
|
$categories = get_the_terms($product_id, 'product_cat');
|
|
$use_new_template = false;
|
|
|
|
if ($categories && !is_wp_error($categories)) {
|
|
foreach ($categories as $category) {
|
|
if (in_array($category->slug, ['korm', 'lakomstva'])) {
|
|
$use_new_template = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
if ($use_new_template) {
|
|
include_component('shop', 'product-single--new'); // выводим новый шаблон с калькулятором для кормов и лакомств
|
|
} else {
|
|
include_component('shop', 'product-single'); // выводим старый шаблон подробной версии товара для аксессуаров
|
|
}
|
|
} elseif (is_shop()) {
|
|
include_component('shop', 'catalog');
|
|
} elseif (is_product_category()) {
|
|
include_component('shop', 'catalog');
|
|
} else {
|
|
include_component('shop', 'catalog');
|
|
}
|
|
|
|
// Рендеринг уже происходит внутри компонентов, поэтому здесь ничего не нужно
|
|
|