Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 9.9 KiB After Width: | Height: | Size: 9.9 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 459 B After Width: | Height: | Size: 459 B |
Before Width: | Height: | Size: 481 B After Width: | Height: | Size: 481 B |
Before Width: | Height: | Size: 456 B After Width: | Height: | Size: 456 B |
Before Width: | Height: | Size: 458 B After Width: | Height: | Size: 458 B |
Before Width: | Height: | Size: 954 B After Width: | Height: | Size: 954 B |
Before Width: | Height: | Size: 455 B After Width: | Height: | Size: 455 B |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
@ -0,0 +1,20 @@ |
|||||||
|
<?php |
||||||
|
use Timber\Timber; |
||||||
|
global $post; |
||||||
|
|
||||||
|
$context = Timber::get_context(); |
||||||
|
|
||||||
|
// Получаем текущий продукт |
||||||
|
$product_id = get_the_ID(); |
||||||
|
$product = wc_get_product($product_id); |
||||||
|
|
||||||
|
// Добавляем продукт в контекст |
||||||
|
$context['product'] = $product; |
||||||
|
$context['post'] = Timber::get_post(); |
||||||
|
|
||||||
|
include_module('shop'); |
||||||
|
include_component('shop', 'reviews'); |
||||||
|
|
||||||
|
?> |
||||||
|
<?php |
||||||
|
Timber::render('woocommerce/single-product.twig', $context); |
@ -0,0 +1,49 @@ |
|||||||
|
/* Стили для загрузки корзины на single странице */ |
||||||
|
|
||||||
|
.product-incart__wrap.loading { |
||||||
|
position: relative; |
||||||
|
pointer-events: none; |
||||||
|
opacity: 0.7; |
||||||
|
} |
||||||
|
|
||||||
|
.product-incart__wrap.loading::before { |
||||||
|
content: ''; |
||||||
|
position: absolute; |
||||||
|
top: 0; |
||||||
|
left: 0; |
||||||
|
right: 0; |
||||||
|
bottom: 0; |
||||||
|
background: rgba(255, 255, 255, 0.8); |
||||||
|
z-index: 10; |
||||||
|
} |
||||||
|
|
||||||
|
.product-incart__wrap.loading::after { |
||||||
|
content: ''; |
||||||
|
position: absolute; |
||||||
|
top: 50%; |
||||||
|
left: 50%; |
||||||
|
width: 20px; |
||||||
|
height: 20px; |
||||||
|
margin: -10px 0 0 -10px; |
||||||
|
border: 2px solid #f3f3f3; |
||||||
|
border-top: 2px solid #3498db; |
||||||
|
border-radius: 50%; |
||||||
|
animation: spin 1s linear infinite; |
||||||
|
z-index: 11; |
||||||
|
} |
||||||
|
|
||||||
|
@keyframes spin { |
||||||
|
0% { transform: rotate(0deg); } |
||||||
|
100% { transform: rotate(360deg); } |
||||||
|
} |
||||||
|
|
||||||
|
/* Стили для кнопок во время загрузки */ |
||||||
|
.product-incart__wrap.loading .product-incart__btn { |
||||||
|
opacity: 0.5; |
||||||
|
pointer-events: none; |
||||||
|
} |
||||||
|
|
||||||
|
/* Стили для счетчика во время загрузки */ |
||||||
|
.product-incart__wrap.loading .product-incart__count { |
||||||
|
opacity: 0.5; |
||||||
|
} |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 9.9 KiB After Width: | Height: | Size: 9.9 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 459 B After Width: | Height: | Size: 459 B |
Before Width: | Height: | Size: 481 B After Width: | Height: | Size: 481 B |
Before Width: | Height: | Size: 456 B After Width: | Height: | Size: 456 B |
Before Width: | Height: | Size: 458 B After Width: | Height: | Size: 458 B |
Before Width: | Height: | Size: 954 B After Width: | Height: | Size: 954 B |
Before Width: | Height: | Size: 455 B After Width: | Height: | Size: 455 B |
@ -0,0 +1,156 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
$product; |
||||||
|
$product_type; |
||||||
|
$context_for_twig; |
||||||
|
|
||||||
|
// Получаем данные продукта |
||||||
|
$product_id = get_the_ID(); |
||||||
|
$product = wc_get_product($product_id); |
||||||
|
|
||||||
|
// Проверяем, что продукт существует |
||||||
|
if (!$product) { |
||||||
|
return; // Просто выходим, если продукт не найден |
||||||
|
} |
||||||
|
|
||||||
|
$attributes = []; |
||||||
|
$product_attributes = $product->get_attributes(); |
||||||
|
|
||||||
|
/* Получение категорий */ |
||||||
|
$tags = get_the_terms($product_id, 'product_cat'); |
||||||
|
if (!empty($tags) && !is_wp_error($tags)) { |
||||||
|
foreach ($tags as $tag) { |
||||||
|
$context_for_twig['product_tags'][] = $tag->name; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/* Получение атрибутов */ |
||||||
|
if (!empty($product_attributes)) { |
||||||
|
foreach ($product_attributes as $taxonomy => $attribute) { |
||||||
|
if ($attribute->is_taxonomy()) { |
||||||
|
$terms = wc_get_product_terms($product_id, $taxonomy, ['fields' => 'all']); |
||||||
|
// $tags = wc_get_product_terms( $product_id, 'pa_catalog_tags' ); |
||||||
|
|
||||||
|
if (!empty($terms)) { |
||||||
|
$attr_values = []; |
||||||
|
foreach ($terms as $term) { |
||||||
|
$attr_values[] = [ |
||||||
|
'name' => $term->name, |
||||||
|
'slug' => $term->slug, |
||||||
|
'term_id' => $term->term_id, |
||||||
|
'link' => get_term_link($term->term_id, $taxonomy), |
||||||
|
]; |
||||||
|
} |
||||||
|
$attributes[wc_attribute_label($taxonomy)] = $attr_values; |
||||||
|
} |
||||||
|
} else { |
||||||
|
$attributes[wc_attribute_label($taxonomy)] = $attribute->get_options(); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
$context_for_twig['product_attributes'] = $attributes; |
||||||
|
|
||||||
|
/* Получение вариаций товара */ |
||||||
|
if ($product->is_type('variable')) { |
||||||
|
$available_variations = $product->get_available_variations(); |
||||||
|
$variations_data = []; |
||||||
|
|
||||||
|
foreach ($available_variations as $variation) { |
||||||
|
$variation_id = $variation['variation_id']; |
||||||
|
$variation_obj = wc_get_product($variation_id); |
||||||
|
|
||||||
|
$variations_data[] = [ |
||||||
|
'variation_id' => $variation_id, |
||||||
|
'price' => $variation_obj->get_price(), |
||||||
|
'regular_price' => $variation_obj->get_regular_price(), |
||||||
|
'sale_price' => $variation_obj->get_sale_price(), |
||||||
|
'attributes' => $variation['attributes'] |
||||||
|
]; |
||||||
|
} |
||||||
|
|
||||||
|
$context_for_twig['variations'] = $variations_data; |
||||||
|
} |
||||||
|
|
||||||
|
/* ACF-поля и мета-данные продукта */ |
||||||
|
$meta_fields = [ |
||||||
|
'composition' => get_post_meta($product_id, '_composition', true), |
||||||
|
'feeding_recommendations' => get_post_meta($product_id, '_feeding_recommendations', true), // Ранее выводились HTML-полем «Рекомендации по кормлению» |
||||||
|
'feeding_recommendations_table' => get_field('feeding_recommendations_table', get_post(get_field('p_tables_field', $product_id))) , // Таблица «Рекомендации по кормлению» |
||||||
|
'nutritional_value' => get_post_meta($product_id, '_nutritional_value', true), |
||||||
|
'vitamins' => get_post_meta($product_id, '_vitamins', true), |
||||||
|
'additives' => get_post_meta($product_id, '_additives', true), |
||||||
|
'energy_value' => get_post_meta($product_id, '_energy_value', true), |
||||||
|
'important' => get_post_meta($product_id, '_important', true), |
||||||
|
]; |
||||||
|
|
||||||
|
$context_for_twig['product_meta'] = $meta_fields; |
||||||
|
|
||||||
|
|
||||||
|
/* Товар оформляется по подписке? */ |
||||||
|
$context_for_twig['is_subscription'] = $product->is_type( array( 'subscription', 'subscription_variation', 'variable-subscription' )) ? true : false; |
||||||
|
|
||||||
|
$context = Timber::get_context(); |
||||||
|
$post = Timber::get_post(); |
||||||
|
$context['post'] = $post; |
||||||
|
$context['wc_breadcrumbs'] = array(); |
||||||
|
|
||||||
|
if (function_exists('woocommerce_breadcrumb')) { |
||||||
|
$args = array( |
||||||
|
'delimiter' => '', |
||||||
|
'wrap_before' => '', |
||||||
|
'wrap_after' => '', |
||||||
|
'before' => '', |
||||||
|
'after' => '', |
||||||
|
'home' => _x('Home', 'breadcrumb', 'woocommerce'), |
||||||
|
); |
||||||
|
|
||||||
|
$breadcrumbs = new WC_Breadcrumb(); |
||||||
|
$breadcrumbs->generate(); |
||||||
|
|
||||||
|
$formatted_breadcrumbs = array(); |
||||||
|
foreach ($breadcrumbs->get_breadcrumb() as $crumb) { |
||||||
|
$formatted_breadcrumbs[] = array( |
||||||
|
'text' => $crumb[0], |
||||||
|
'url' => $crumb[1] |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
$context['wc_breadcrumbs'] = $formatted_breadcrumbs; |
||||||
|
} |
||||||
|
|
||||||
|
$context['product'] = $product; |
||||||
|
|
||||||
|
$context['related_products'] = array(); |
||||||
|
$related_products_ids = $product->get_upsell_ids(); |
||||||
|
if ($related_products_ids) { |
||||||
|
foreach ($related_products_ids as $related_id) { |
||||||
|
$related_product = wc_get_product($related_id); |
||||||
|
if ($related_product) { |
||||||
|
$context['related_products'][] = $related_product; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
if (class_exists('WCS_ATT_Product_Schemes')) { |
||||||
|
$schemes = WCS_ATT_Product_Schemes::get_subscription_schemes($product); |
||||||
|
$context['has_subscription_options'] = !empty($schemes); |
||||||
|
} else { |
||||||
|
$context['has_subscription_options'] = false; |
||||||
|
} |
||||||
|
|
||||||
|
Timber::render('_pages/shop/product-single.twig', $context); |
||||||
|
|
||||||
|
// Подключение стилей для загрузки корзины |
||||||
|
add_action('wp_enqueue_scripts', 'single_product_cart_styles'); |
||||||
|
|
||||||
|
function single_product_cart_styles() { |
||||||
|
if (is_product()) { |
||||||
|
wp_enqueue_style( |
||||||
|
'single-product-cart-loading', |
||||||
|
get_template_directory_uri() . '/modules/shop/components/single-product/assets/css/cart-loading.css', |
||||||
|
array(), |
||||||
|
'1.0.0' |
||||||
|
); |
||||||
|
} |
||||||
|
} |
@ -1,152 +0,0 @@ |
|||||||
<?php |
|
||||||
|
|
||||||
|
|
||||||
$product; |
|
||||||
$product_type; |
|
||||||
$context_for_twig; |
|
||||||
|
|
||||||
if (function_exists('is_product') && is_product()) { |
|
||||||
$product_id = get_the_ID(); |
|
||||||
$product = wc_get_product($product_id); |
|
||||||
|
|
||||||
$attributes = []; |
|
||||||
$product_attributes = $product->get_attributes(); |
|
||||||
|
|
||||||
/* Получение категорий */ |
|
||||||
$tags = get_the_terms($product_id, 'product_cat'); |
|
||||||
if (!empty($tags) && !is_wp_error($tags)) { |
|
||||||
foreach ($tags as $tag) { |
|
||||||
$context_for_twig['product_tags'][] = $tag->name; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/* Получение атрибутов */ |
|
||||||
if (!empty($product_attributes)) { |
|
||||||
foreach ($product_attributes as $taxonomy => $attribute) { |
|
||||||
if ($attribute->is_taxonomy()) { |
|
||||||
$terms = wc_get_product_terms($product_id, $taxonomy, ['fields' => 'all']); |
|
||||||
// $tags = wc_get_product_terms( $product_id, 'pa_catalog_tags' ); |
|
||||||
|
|
||||||
if (!empty($terms)) { |
|
||||||
$attr_values = []; |
|
||||||
foreach ($terms as $term) { |
|
||||||
$attr_values[] = [ |
|
||||||
'name' => $term->name, |
|
||||||
'slug' => $term->slug, |
|
||||||
'term_id' => $term->term_id, |
|
||||||
'link' => get_term_link($term->term_id, $taxonomy), |
|
||||||
]; |
|
||||||
} |
|
||||||
$attributes[wc_attribute_label($taxonomy)] = $attr_values; |
|
||||||
} |
|
||||||
} else { |
|
||||||
$attributes[wc_attribute_label($taxonomy)] = $attribute->get_options(); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
$context_for_twig['product_attributes'] = $attributes; |
|
||||||
|
|
||||||
/* Получение вариаций товара */ |
|
||||||
if ($product->is_type('variable')) { |
|
||||||
$available_variations = $product->get_available_variations(); |
|
||||||
$variations_data = []; |
|
||||||
|
|
||||||
foreach ($available_variations as $variation) { |
|
||||||
$variation_id = $variation['variation_id']; |
|
||||||
$variation_obj = wc_get_product($variation_id); |
|
||||||
|
|
||||||
$variations_data[] = [ |
|
||||||
'variation_id' => $variation_id, |
|
||||||
'price' => $variation_obj->get_price(), |
|
||||||
'regular_price' => $variation_obj->get_regular_price(), |
|
||||||
'sale_price' => $variation_obj->get_sale_price(), |
|
||||||
'attributes' => $variation['attributes'] |
|
||||||
]; |
|
||||||
} |
|
||||||
|
|
||||||
$context_for_twig['variations'] = $variations_data; |
|
||||||
} |
|
||||||
|
|
||||||
/* ACF-поля и мета-данные продукта */ |
|
||||||
$meta_fields = [ |
|
||||||
'composition' => get_post_meta($product_id, '_composition', true), |
|
||||||
'feeding_recommendations' => get_post_meta($product_id, '_feeding_recommendations', true), // Ранее выводились HTML-полем «Рекомендации по кормлению» |
|
||||||
'feeding_recommendations_table' => get_field('feeding_recommendations_table', get_post(get_field('p_tables_field', $product_id))) , // Таблица «Рекомендации по кормлению» |
|
||||||
'nutritional_value' => get_post_meta($product_id, '_nutritional_value', true), |
|
||||||
'vitamins' => get_post_meta($product_id, '_vitamins', true), |
|
||||||
'additives' => get_post_meta($product_id, '_additives', true), |
|
||||||
'energy_value' => get_post_meta($product_id, '_energy_value', true), |
|
||||||
'important' => get_post_meta($product_id, '_important', true), |
|
||||||
]; |
|
||||||
|
|
||||||
$context_for_twig['product_meta'] = $meta_fields; |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Товар оформляется по подписке? */ |
|
||||||
$context_for_twig['is_subscription'] = $product->is_type( array( 'subscription', 'subscription_variation', 'variable-subscription' )) ? true : false; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
add_filter('timber/context', function ($context) use ($context_for_twig) { |
|
||||||
return array_merge($context, $context_for_twig); |
|
||||||
}); |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$context = Timber::get_context(); |
|
||||||
$post = Timber::get_post(); |
|
||||||
$context['post'] = $post; |
|
||||||
|
|
||||||
$context['wc_breadcrumbs'] = array(); |
|
||||||
|
|
||||||
if (function_exists('woocommerce_breadcrumb')) { |
|
||||||
$args = array( |
|
||||||
'delimiter' => '', |
|
||||||
'wrap_before' => '', |
|
||||||
'wrap_after' => '', |
|
||||||
'before' => '', |
|
||||||
'after' => '', |
|
||||||
'home' => _x('Home', 'breadcrumb', 'woocommerce'), |
|
||||||
); |
|
||||||
|
|
||||||
$breadcrumbs = new WC_Breadcrumb(); |
|
||||||
$breadcrumbs->generate(); |
|
||||||
|
|
||||||
$formatted_breadcrumbs = array(); |
|
||||||
foreach ($breadcrumbs->get_breadcrumb() as $crumb) { |
|
||||||
$formatted_breadcrumbs[] = array( |
|
||||||
'text' => $crumb[0], |
|
||||||
'url' => $crumb[1] |
|
||||||
); |
|
||||||
} |
|
||||||
|
|
||||||
$context['wc_breadcrumbs'] = $formatted_breadcrumbs; |
|
||||||
} |
|
||||||
|
|
||||||
$product_id = get_the_ID(); |
|
||||||
$product = wc_get_product($product_id); |
|
||||||
|
|
||||||
$context['product'] = $product; |
|
||||||
|
|
||||||
$context['related_products'] = array(); |
|
||||||
$related_products_ids = $product->get_upsell_ids(); |
|
||||||
if ($related_products_ids) { |
|
||||||
foreach ($related_products_ids as $related_id) { |
|
||||||
$related_product = wc_get_product($related_id); |
|
||||||
if ($related_product) { |
|
||||||
$context['related_products'][] = $related_product; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
if (class_exists('WCS_ATT_Product_Schemes')) { |
|
||||||
$schemes = WCS_ATT_Product_Schemes::get_subscription_schemes($product); |
|
||||||
$context['has_subscription_options'] = !empty($schemes); |
|
||||||
} else { |
|
||||||
$context['has_subscription_options'] = false; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
Timber::render('_pages/shop/product-single.twig', $context); |
|
@ -1,13 +0,0 @@ |
|||||||
<?php |
|
||||||
use Timber\Timber; |
|
||||||
global $post; |
|
||||||
|
|
||||||
$context = Timber::get_context(); |
|
||||||
|
|
||||||
include_module('shop'); |
|
||||||
include_component('shop', 'reviews'); |
|
||||||
include_component('shop', 'product-card'); |
|
||||||
|
|
||||||
?> |
|
||||||
<?php |
|
||||||
Timber::render('shop/single-product.twig', $context); |
|
@ -1,6 +0,0 @@ |
|||||||
<?php |
|
||||||
|
|
||||||
include_module('author'); |
|
||||||
include_component('author', 'author-single'); |
|
||||||
|
|
||||||
?> |
|
@ -1,6 +0,0 @@ |
|||||||
<?php |
|
||||||
|
|
||||||
include_module('blog'); |
|
||||||
include_component('blog', 'single'); |
|
||||||
|
|
||||||
?> |
|
@ -1,22 +0,0 @@ |
|||||||
<?php |
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) { |
|
||||||
exit; |
|
||||||
} |
|
||||||
|
|
||||||
if (is_product()) { |
|
||||||
|
|
||||||
include_module('shop'); |
|
||||||
global $product; |
|
||||||
// Get the product ID |
|
||||||
$product_id = get_the_ID(); |
|
||||||
if ($product_id == 1105){ |
|
||||||
include_component('shop', 'single-product_new'); |
|
||||||
} |
|
||||||
else{ |
|
||||||
// include_component('shop', 'single-product'); |
|
||||||
include_component('shop', 'single-product_new'); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
} |
|
@ -0,0 +1,26 @@ |
|||||||
|
<?php |
||||||
|
/** |
||||||
|
* The Template for displaying all single posts |
||||||
|
* |
||||||
|
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/ |
||||||
|
*/ |
||||||
|
|
||||||
|
namespace App; |
||||||
|
|
||||||
|
use Timber\Timber; |
||||||
|
|
||||||
|
$context = Timber::context(); |
||||||
|
$post = $context['post']; |
||||||
|
|
||||||
|
if ( is_singular('post') ) { |
||||||
|
include_module('blog'); |
||||||
|
include_component('blog', 'single'); |
||||||
|
} elseif ( is_singular('blog_author') ) { |
||||||
|
include_module('author'); |
||||||
|
include_component('author', 'author-single'); |
||||||
|
} else { |
||||||
|
// Для других типов записей |
||||||
|
$templates = [ 'views/single-' . get_post_type() . '.twig', 'views/single.twig' ]; |
||||||
|
} |
||||||
|
|
||||||
|
Timber::render( $templates, $context ); |
@ -1,43 +1,56 @@ |
|||||||
<? |
<? |
||||||
|
|
||||||
use Timber; |
use Timber; |
||||||
use Timber\PostCollection; |
use Timber\PostCollection; |
||||||
use Timber\Integrations\WooCommerce\Product as TimberProduct; |
use Timber\Integrations\WooCommerce\Product as TimberProduct; |
||||||
|
|
||||||
|
|
||||||
Timber::$dirname = [ |
Timber::$dirname = [ |
||||||
[ |
'views', |
||||||
'modules', |
'modules' |
||||||
'views' |
]; |
||||||
], |
|
||||||
]; |
// Настройка путей для WooCommerce шаблонов |
||||||
|
add_filter('timber/loader/paths', function($paths) { |
||||||
|
$paths[] = get_template_directory() . '/views/woocommerce'; |
||||||
add_filter( 'timber/integrations', function ( array $integrations ): array { |
return $paths; |
||||||
$integrations[] = new \Timber\Integrations\WooCommerce\WooCommerceIntegration(); |
}); |
||||||
return $integrations; |
|
||||||
} ); |
add_filter( 'timber/integrations', function ( array $integrations ): array { |
||||||
|
$integrations[] = new \Timber\Integrations\WooCommerce\WooCommerceIntegration(); |
||||||
add_action('timber/init', function() { |
return $integrations; |
||||||
// Инициализируем WooCommerce интеграцию |
} ); |
||||||
if (class_exists('Timber\Integrations\WooCommerce\WooCommerce')) { |
|
||||||
Timber\Integrations\WooCommerce\WooCommerce::init(); |
|
||||||
} |
// Add the function to the Timber context |
||||||
}); |
add_filter('timber/context', function($context) { |
||||||
|
$context['template_path'] = get_template_directory_uri(); |
||||||
|
$current_url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
||||||
// Add the function to the Timber context |
$context['current_url'] = htmlspecialchars($current_url); |
||||||
add_filter('timber/context', function($context) { |
|
||||||
$context['template_path'] = get_template_directory_uri(); |
// Добавляем WooCommerce контекст если WooCommerce активен |
||||||
$current_url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
if (class_exists('WooCommerce')) { |
||||||
$context['current_url'] = htmlspecialchars($current_url); |
// WooCommerce автоматически добавляет свой контекст через интеграцию |
||||||
return $context; |
// Но мы можем его расширить |
||||||
}); |
if (is_woocommerce()) { |
||||||
|
$context['is_woocommerce'] = true; |
||||||
|
} |
||||||
add_action('init', function() { |
} |
||||||
add_filter('timber/context', function($context) { |
|
||||||
$context['current_lang'] = pll_current_language(); |
return $context; |
||||||
return $context; |
}); |
||||||
}); |
|
||||||
}, 1); |
|
||||||
|
add_action('init', function() { |
||||||
|
add_filter('timber/context', function($context) { |
||||||
|
$context['current_lang'] = pll_current_language(); |
||||||
|
|
||||||
|
// Добавляем функцию для получения иконки термина |
||||||
|
$context['get_term_icon'] = function($term_id, $taxonomy) { |
||||||
|
$product = new CosmopetProduct(); |
||||||
|
return $product->getTermIcon($term_id, $taxonomy); |
||||||
|
}; |
||||||
|
|
||||||
|
return $context; |
||||||
|
}); |
||||||
|
}, 1); |
||||||
|
@ -0,0 +1,26 @@ |
|||||||
|
{% set in_stock = post.meta('_stock_status') == 'instock' %} |
||||||
|
|
||||||
|
{% set cart_quantity = post.getCartQuantity %} |
||||||
|
{% if in_stock %} |
||||||
|
{% if post.getCartQuantity == 0 %} |
||||||
|
{{ function('do_action', 'woocommerce_' ~ post.product.get_type() ~ '_add_to_cart') }} |
||||||
|
{% else %} |
||||||
|
<div class="product-incart__wrap" data-product-id="{{ post.id }}"> |
||||||
|
<div class="product-incart counter"> |
||||||
|
<button class="product-incart__btn product-incart__btn--minus" data-key="{{post.getCartItemKey}}" data-action="decrease"></button> |
||||||
|
|
||||||
|
<div class="product-incart__count" data-key="{{post.getCartItemKey}}">{{ cart_quantity }}</div> |
||||||
|
<button class="product-incart__btn product-incart__btn--plus" data-key="{{post.getCartItemKey}}" data-action="increase"></button> |
||||||
|
</div> |
||||||
|
<div class="product-incart__label"> |
||||||
|
{{fn('pll_e', 'В корзине')}} |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
{% endif %} |
||||||
|
{% else %} |
||||||
|
<div class="detail-block-form__item detail-block-form__item--tn"> |
||||||
|
<button type="button" data-pname="{{ product.title }}" class="to-know open-to-know" > |
||||||
|
<p>{{ function('pll_e', 'Узнать о поступлении') }}</p> |
||||||
|
</button> |
||||||
|
</div> |
||||||
|
{% endif %} |
@ -1,321 +1,326 @@ |
|||||||
{% set bodyClass = 'bg-white' %} |
{% set bodyClass = 'bg-white' %} |
||||||
{% set mainClass = '' %} |
{% set mainClass = '' %} |
||||||
{% extends 'layout.twig' %} |
{% extends 'layout.twig' %} |
||||||
|
|
||||||
{% block content %} |
{% block content %} |
||||||
<div class="product-single"> |
<div class="product-single" data-product-id="{{ post.id }}"> |
||||||
<div class="wrapper"> |
<div class="wrapper"> |
||||||
<div class="breadcrumbs"> |
<div class="breadcrumbs"> |
||||||
<a href="{{ fn('home_url') }}" class="breadcrumbs__item"> |
<a href="{{ fn('home_url') }}" class="breadcrumbs__item"> |
||||||
{{ fn('pll_e', 'Главная') }} |
{{ fn('pll_e', 'Главная') }} |
||||||
</a> |
</a> |
||||||
{% set product_categories = post.get_terms('product_cat') %} |
{% set product_categories = post.get_terms('product_cat') %} |
||||||
{% if product_categories %} |
{% if product_categories %} |
||||||
{% set category = product_categories[0] %} |
{% set category = product_categories[0] %} |
||||||
<a href="{{ category.link }}" class="breadcrumbs__item"> |
<a href="{{ category.link }}" class="breadcrumbs__item"> |
||||||
{{ category.name }} |
{{ category.name }} |
||||||
</a> |
</a> |
||||||
{% endif %} |
{% endif %} |
||||||
<a href="{{post.link}}" class="breadcrumbs__item"> |
<a href="{{post.link}}" class="breadcrumbs__item"> |
||||||
{{post.title}} |
{{post.title}} |
||||||
</a> |
</a> |
||||||
</div> |
</div> |
||||||
<div class="product_main {{ post.getTasteClass() }}"> |
<div class="product_main {{ post.getTasteClass() }}"> |
||||||
<div class="product-info"> |
<div class="product-info"> |
||||||
<h1 class="product-title --pc"> |
<h1 class="product-title --pc"> |
||||||
{{post.title}} |
{{post.title}} |
||||||
</h1> |
</h1> |
||||||
<div class="product-contains"> |
<div class="product-contains"> |
||||||
<h2 class="product-block-title">{{ fn('pll_e', 'СОСТАВ') }}</h2> |
<h2 class="product-block-title">{{ fn('pll_e', 'СОСТАВ') }}</h2> |
||||||
<div class="product-contains-text">{{ post.getComposition }}</div> |
<div class="product-contains-text">{{ post.getComposition }}</div> |
||||||
</div> |
</div> |
||||||
<div class="product-values"> |
{% set nutritional_value = post.nutritional_value %} |
||||||
<h2 class="product-values-title">{{ fn('pll_e', 'ПИЩЕВАЯ ЦЕННОСТЬ') }}</h2> |
{% set vitamins = post.vitamins %} |
||||||
<div class="product-values-list"> |
{% if nutritional_value or vitamins %} |
||||||
|
<div class="product-values"> |
||||||
{% set nutritional_value = post.nutritional_value %} |
{% if nutritional_value %} |
||||||
{% if nutritional_value.protein %} |
<h2 class="product-values-title">{{ fn('pll_e', 'ПИЩЕВАЯ ЦЕННОСТЬ') }}</h2> |
||||||
<div class="product-values-item"> |
<div class="product-values-list"> |
||||||
<div class="product-values-item__name">{{ fn('pll_e', 'Сырой белок') }}</div> |
|
||||||
<div class="product-values-item-val">{{nutritional_value.protein}}</div> |
{% if nutritional_value.protein %} |
||||||
</div> |
<div class="product-values-item"> |
||||||
{% endif %} |
<div class="product-values-item__name">{{ fn('pll_e', 'Сырой белок') }}</div> |
||||||
{% if nutritional_value.fat %} |
<div class="product-values-item-val">{{nutritional_value.protein}}</div> |
||||||
<div class="product-values-item"> |
</div> |
||||||
<div class="product-values-item__name">{{ fn('pll_e', 'Сырой жир') }}</div> |
{% endif %} |
||||||
<div class="product-values-item-val">{{nutritional_value.fat}}</div> |
{% if nutritional_value.fat %} |
||||||
</div> |
<div class="product-values-item"> |
||||||
{% endif %} |
<div class="product-values-item__name">{{ fn('pll_e', 'Сырой жир') }}</div> |
||||||
{% if nutritional_value.fiber %} |
<div class="product-values-item-val">{{nutritional_value.fat}}</div> |
||||||
<div class="product-values-item"> |
</div> |
||||||
<div class="product-values-item__name">{{ fn('pll_e', 'Сырая клетчатка') }}</div> |
{% endif %} |
||||||
<div class="product-values-item-val">{{nutritional_value.fiber}}</div> |
{% if nutritional_value.fiber %} |
||||||
</div> |
<div class="product-values-item"> |
||||||
{% endif %} |
<div class="product-values-item__name">{{ fn('pll_e', 'Сырая клетчатка') }}</div> |
||||||
{% if nutritional_value.ash %} |
<div class="product-values-item-val">{{nutritional_value.fiber}}</div> |
||||||
<div class="product-values-item"> |
</div> |
||||||
<div class="product-values-item__name">{{ fn('pll_e', 'Сырая зола') }}</div> |
{% endif %} |
||||||
<div class="product-values-item-val">{{nutritional_value.ash}}</div> |
{% if nutritional_value.ash %} |
||||||
</div> |
<div class="product-values-item"> |
||||||
{% endif %} |
<div class="product-values-item__name">{{ fn('pll_e', 'Сырая зола') }}</div> |
||||||
{% if nutritional_value.wat %} |
<div class="product-values-item-val">{{nutritional_value.ash}}</div> |
||||||
<div class="product-values-item"> |
</div> |
||||||
<div class="product-values-item__name">{{ fn('pll_e', 'Влажность') }}</div> |
{% endif %} |
||||||
<div class="product-values-item-val">{{nutritional_value.wat}}</div> |
{% if nutritional_value.wat %} |
||||||
</div> |
<div class="product-values-item"> |
||||||
{% endif %} |
<div class="product-values-item__name">{{ fn('pll_e', 'Влажность') }}</div> |
||||||
{% if nutritional_value.calcium %} |
<div class="product-values-item-val">{{nutritional_value.wat}}</div> |
||||||
<div class="product-values-item"> |
</div> |
||||||
<div class="product-values-item__name">{{ fn('pll_e', 'Кальций') }}</div> |
{% endif %} |
||||||
<div class="product-values-item-val">{{nutritional_value.calcium}}</div> |
{% if nutritional_value.calcium %} |
||||||
</div> |
<div class="product-values-item"> |
||||||
{% endif %} |
<div class="product-values-item__name">{{ fn('pll_e', 'Кальций') }}</div> |
||||||
{% if nutritional_value.phosphorus %} |
<div class="product-values-item-val">{{nutritional_value.calcium}}</div> |
||||||
<div class="product-values-item"> |
</div> |
||||||
<div class="product-values-item__name">{{ fn('pll_e', 'Фосфор') }}</div> |
{% endif %} |
||||||
<div class="product-values-item-val">{{nutritional_value.phosphorus}}</div> |
{% if nutritional_value.phosphorus %} |
||||||
</div> |
<div class="product-values-item"> |
||||||
{% endif %} |
<div class="product-values-item__name">{{ fn('pll_e', 'Фосфор') }}</div> |
||||||
{% if nutritional_value.omega_6 %} |
<div class="product-values-item-val">{{nutritional_value.phosphorus}}</div> |
||||||
<div class="product-values-item"> |
</div> |
||||||
<div class="product-values-item__name">{{ fn('pll_e', 'Омега 6') }}</div> |
{% endif %} |
||||||
<div class="product-values-item-val">{{nutritional_value.omega_6}}</div> |
{% if nutritional_value.omega_6 %} |
||||||
</div> |
<div class="product-values-item"> |
||||||
{% endif %} |
<div class="product-values-item__name">{{ fn('pll_e', 'Омега 6') }}</div> |
||||||
{% if nutritional_value.omega_3 %} |
<div class="product-values-item-val">{{nutritional_value.omega_6}}</div> |
||||||
<div class="product-values-item"> |
</div> |
||||||
<div class="product-values-item__name">{{ fn('pll_e', 'Омега 3') }}</div> |
{% endif %} |
||||||
<div class="product-values-item-val">{{nutritional_value.omega_3}}</div> |
{% if nutritional_value.omega_3 %} |
||||||
</div> |
<div class="product-values-item"> |
||||||
{% endif %} |
<div class="product-values-item__name">{{ fn('pll_e', 'Омега 3') }}</div> |
||||||
</div> |
<div class="product-values-item-val">{{nutritional_value.omega_3}}</div> |
||||||
{% set vitamins = post.vitamins %} |
</div> |
||||||
{% if vitamins %} |
{% endif %} |
||||||
<div class="product-vitamins"> |
</div> |
||||||
<div class="product-vitamins-title"> |
{% endif %} |
||||||
{{ fn('pll_e', 'Витамины на кг') }} |
{% set vitamins = post.vitamins %} |
||||||
</div> |
{% if vitamins %} |
||||||
<div class="product-vitamins-list"> |
<div class="product-vitamins"> |
||||||
|
<div class="product-vitamins-title"> |
||||||
{% if vitamins.vitamin_a_me %} |
{{ fn('pll_e', 'Витамины на кг') }} |
||||||
<div class="product-vitamins-item">A, ME — {{vitamins.vitamin_a_me}}</div> |
</div> |
||||||
{% endif %} |
<div class="product-vitamins-list"> |
||||||
{% if vitamins.vitamin_d3_me %} |
|
||||||
<div class="product-vitamins-item">D3, ME — {{vitamins.vitamin_d3_me}}</div> |
{% if vitamins.vitamin_a_me %} |
||||||
{% endif %} |
<div class="product-vitamins-item">A, ME — {{vitamins.vitamin_a_me}}</div> |
||||||
{% if vitamins.vitamin_e %} |
{% endif %} |
||||||
<div class="product-vitamins-item">E — {{vitamins.vitamin_e}}</div> |
{% if vitamins.vitamin_d3_me %} |
||||||
{% endif %} |
<div class="product-vitamins-item">D3, ME — {{vitamins.vitamin_d3_me}}</div> |
||||||
{% if vitamins.tiamin %} |
{% endif %} |
||||||
<div class="product-vitamins-item">{{ fn('pll_e', 'Тиамин') }} — {{vitamins.tiamin}}</div> |
{% if vitamins.vitamin_e %} |
||||||
{% endif %} |
<div class="product-vitamins-item">E — {{vitamins.vitamin_e}}</div> |
||||||
{% if vitamins.riboflavin %} |
{% endif %} |
||||||
<div class="product-vitamins-item">{{ fn('pll_e', 'Рибофлавин') }} — {{vitamins.riboflavin}}</div> |
{% if vitamins.tiamin %} |
||||||
{% endif %} |
<div class="product-vitamins-item">{{ fn('pll_e', 'Тиамин') }} — {{vitamins.tiamin}}</div> |
||||||
{% if vitamins.pantothenic_acid %} |
{% endif %} |
||||||
<div class="product-vitamins-item">{{ fn('pll_e', 'Пантотеновая кислота') }} — {{vitamins.pantothenic_acid}}</div> |
{% if vitamins.riboflavin %} |
||||||
{% endif %} |
<div class="product-vitamins-item">{{ fn('pll_e', 'Рибофлавин') }} — {{vitamins.riboflavin}}</div> |
||||||
{% if vitamins.niaczin %} |
{% endif %} |
||||||
<div class="product-vitamins-item">{{ fn('pll_e', 'Ниацин') }} — {{vitamins.niaczin}}</div> |
{% if vitamins.pantothenic_acid %} |
||||||
{% endif %} |
<div class="product-vitamins-item">{{ fn('pll_e', 'Пантотеновая кислота') }} — {{vitamins.pantothenic_acid}}</div> |
||||||
{% if vitamins.piridoksin %} |
{% endif %} |
||||||
<div class="product-vitamins-item">{{ fn('pll_e', 'Пиридоксин') }} — {{vitamins.piridoksin}}</div> |
{% if vitamins.niaczin %} |
||||||
{% endif %} |
<div class="product-vitamins-item">{{ fn('pll_e', 'Ниацин') }} — {{vitamins.niaczin}}</div> |
||||||
{% if vitamins.folic_acid %} |
{% endif %} |
||||||
<div class="product-vitamins-item">{{ fn('pll_e', 'Фолиевая кислота') }} — {{vitamins.folic_acid}}</div> |
{% if vitamins.piridoksin %} |
||||||
{% endif %} |
<div class="product-vitamins-item">{{ fn('pll_e', 'Пиридоксин') }} — {{vitamins.piridoksin}}</div> |
||||||
{% if vitamins.vitamin_b12 %} |
{% endif %} |
||||||
<div class="product-vitamins-item">{{ fn('pll_e', 'Витамин B12') }} — {{vitamins.vitamin_b12}}</div> |
{% if vitamins.folic_acid %} |
||||||
{% endif %} |
<div class="product-vitamins-item">{{ fn('pll_e', 'Фолиевая кислота') }} — {{vitamins.folic_acid}}</div> |
||||||
{% if vitamins.holin %} |
{% endif %} |
||||||
<div class="product-vitamins-item">{{ fn('pll_e', 'Холин') }} — {{vitamins.holin}}</div> |
{% if vitamins.vitamin_b12 %} |
||||||
{% endif %} |
<div class="product-vitamins-item">{{ fn('pll_e', 'Витамин B12') }} — {{vitamins.vitamin_b12}}</div> |
||||||
</div> |
{% endif %} |
||||||
</div> |
{% if vitamins.holin %} |
||||||
{% endif %} |
<div class="product-vitamins-item">{{ fn('pll_e', 'Холин') }} — {{vitamins.holin}}</div> |
||||||
</div> |
{% endif %} |
||||||
</div> |
</div> |
||||||
<div class="product-show"> |
</div> |
||||||
<div class="product-gallery"> |
{% endif %} |
||||||
<div class="swiper product-gallery__mainSlider"> |
</div> |
||||||
<div class="swiper-wrapper"> |
{% endif %} |
||||||
{% set image_list = post.getImageGallery('full') %} |
</div> |
||||||
{% for image in image_list %} |
<div class="product-show"> |
||||||
<div class="swiper-slide"> |
<div class="product-gallery"> |
||||||
<img src="{{ image.url }}" alt="{{image.alt}}"> |
<div class="swiper product-gallery__mainSlider"> |
||||||
</div> |
<div class="swiper-wrapper"> |
||||||
{% endfor %} |
{% set image_list = post.getImageGallery('full') %} |
||||||
</div> |
{% for image in image_list %} |
||||||
</div> |
<div class="swiper-slide"> |
||||||
<div thumbsSlider="" class="swiper product-gallery__thumbsSlider"> |
<img src="{{ image.url }}" alt="{{image.alt}}"> |
||||||
<div class="swiper-wrapper"> |
</div> |
||||||
{% set image_list = post.getImageGallery('medium') %} |
{% endfor %} |
||||||
{% for image in image_list %} |
</div> |
||||||
<div class="swiper-slide"> |
</div> |
||||||
<img src="{{ image.url }}" alt="{{image.alt}}"> |
<div thumbsSlider="" class="swiper product-gallery__thumbsSlider"> |
||||||
</div> |
<div class="swiper-wrapper"> |
||||||
{% endfor %} |
{% set image_list = post.getImageGallery('medium') %} |
||||||
</div> |
{% for image in image_list %} |
||||||
<div class="product-gallery-arrows"> |
<div class="swiper-slide"> |
||||||
<button class="product-gallery-arrow product-gallery-prev"></button> |
<img src="{{ image.url }}" alt="{{image.alt}}"> |
||||||
<button class="product-gallery-arrow product-gallery-next"></button> |
</div> |
||||||
</div> |
{% endfor %} |
||||||
</div> |
</div> |
||||||
<div class="product-gallery-bullets"></div> |
<div class="product-gallery-arrows"> |
||||||
</div> |
<button class="product-gallery-arrow product-gallery-prev"></button> |
||||||
<h1 class="product-title --m"> |
<button class="product-gallery-arrow product-gallery-next"></button> |
||||||
{{post.title}} |
</div> |
||||||
</h1> |
</div> |
||||||
</div> |
<div class="product-gallery-bullets"></div> |
||||||
<div class="product-constructor"> |
</div> |
||||||
{% set constructor = post.getProductConstructor %} |
<h1 class="product-title --m"> |
||||||
{% for taxonomy, attribute_data in constructor %} |
{{post.title}} |
||||||
<div class="product-constructor__block"> |
</h1> |
||||||
<div class="product-constructor__block-title">{{attribute_data.label}}</div> |
</div> |
||||||
<div class="product-constructor__block-list"> |
<div class="product-constructor"> |
||||||
{% for option_id, option in attribute_data.options %} |
{% set constructor = post.getProductConstructor %} |
||||||
{% set first_product = option.products[0] %} |
{% for taxonomy, attribute_data in constructor %} |
||||||
<a href="{{first_product.link}}" class="product-constructor__block-item{% if attribute_data.current_value == option.term_id %} active{% endif %}"> |
{% if taxonomy != 'pa_series' %} |
||||||
{% if taxonomy == 'pa_compound' %} |
<div class="product-constructor__block"> |
||||||
{% set icon_map = { |
<div class="product-constructor__block-title">{{attribute_data.label}}</div> |
||||||
'govyadina': 'beef', |
<div class="product-constructor__block-list"> |
||||||
'indejka': 'turkey', |
{% for option_id, option in attribute_data.options %} |
||||||
'krolik': 'rabbit', |
{% set first_product = option.products[0] %} |
||||||
'losos': 'salmon', |
<a href="{{first_product.link}}" class="product-constructor__block-item{% if attribute_data.current_value == option.term_id %} active{% endif %}"> |
||||||
'ryba': 'fish', |
{% if option.icon %} |
||||||
'utka': 'duck', |
<img src="{{option.icon}}" alt="" class="product-constructor__block-item-icon{% if attribute_data.current_value == option.term_id %} active{% endif %} svg"> |
||||||
'yagnenok': 'lamb' |
{% endif %} |
||||||
} %} |
<div class="product-constructor__block-item-name">{{option.name}}</div> |
||||||
{% set icon_class = icon_map[option.slug] ?? 'default' %} |
</a> |
||||||
<img src="/wp-content/themes/cosmopet/modules/shop/components/single-product_new/assets/img/{{icon_class}}.svg" alt="" class="product-constructor__block-item-icon{% if attribute_data.current_value == option.term_id %} active{% endif %} svg"> |
{% endfor %} |
||||||
{% elseif taxonomy == 'pa_age-of-the-dog' %} |
</div> |
||||||
<img src="/wp-content/themes/cosmopet/modules/shop/components/single-product_new/assets/img/dog-face.svg" alt="" class="product-constructor__block-item-icon{% if attribute_data.current_value == option.term_id %} active{% endif %} svg"> |
</div> |
||||||
{% elseif taxonomy == 'pa_age-of-the-cat' %} |
{% endif %} |
||||||
<img src="/wp-content/themes/cosmopet/modules/shop/components/single-product_new/assets/img/cat-face.svg" alt="" class="product-constructor__block-item-icon{% if attribute_data.current_value == option.term_id %} active{% endif %} svg"> |
{% endfor %} |
||||||
{% elseif taxonomy == 'pa_reproductive-status' %} |
|
||||||
<img src="/wp-content/themes/cosmopet/modules/shop/components/single-product_new/assets/img/heart.svg" alt="" class="product-constructor__block-item-icon{% if attribute_data.current_value == option.term_id %} active{% endif %} svg"> |
{% set size_siblings = post.getSizeSiblings %} |
||||||
{% elseif taxonomy == 'pa_series' %} |
{% if size_siblings %} |
||||||
<img src="/wp-content/themes/cosmopet/modules/shop/components/single-product_new/assets/img/star.svg" alt="" class="product-constructor__block-item-icon{% if attribute_data.current_value == option.term_id %} active{% endif %} svg"> |
<div class="product-constructor__block"> |
||||||
{% endif %} |
<div class="product-constructor__block-title">{{fn('pll_e', 'ВЕС УПАКОВКИ')}}</div> |
||||||
<div class="product-constructor__block-item-name">{{option.name}}</div> |
<div class="product-constructor__block-list"> |
||||||
</a> |
{% for sibling in size_siblings %} |
||||||
{% endfor %} |
<a href="{{sibling.link}}" class="product-constructor__block-item{% if post.get_weight == sibling.get_weight %} active{% endif %}"> |
||||||
</div> |
<div class="product-constructor__block-item-name">{{sibling.get_weight}}</div> |
||||||
</div> |
</a> |
||||||
{% endfor %} |
{% endfor %} |
||||||
|
</div> |
||||||
{% set size_siblings = post.getSizeSiblings %} |
</div> |
||||||
{% if size_siblings %} |
{% endif %} |
||||||
<div class="product-constructor__block"> |
|
||||||
<div class="product-constructor__block-title">{{fn('pll_e', 'ВЕС УПАКОВКИ')}}</div> |
{# Отображаем pa_series после вариантов веса #} |
||||||
<div class="product-constructor__block-list"> |
{% for taxonomy, attribute_data in constructor %} |
||||||
{% for sibling in size_siblings %} |
{% if taxonomy == 'pa_series' %} |
||||||
<a href="{{sibling.link}}" class="product-constructor__block-item{% if post.get_weight == sibling.get_weight %} active{% endif %}"> |
<div class="product-constructor__block"> |
||||||
<div class="product-constructor__block-item-name">{{sibling.get_weight}}</div> |
<div class="product-constructor__block-title">{{attribute_data.label}}</div> |
||||||
</a> |
<div class="product-constructor__block-list"> |
||||||
{% endfor %} |
{% for option_id, option in attribute_data.options %} |
||||||
</div> |
{% set first_product = option.products[0] %} |
||||||
</div> |
<a href="{{first_product.link}}" class="product-constructor__block-item{% if attribute_data.current_value == option.term_id %} active{% endif %}"> |
||||||
{% endif %} |
{% if option.icon %} |
||||||
|
<img src="{{option.icon}}" alt="" class="product-constructor__block-item-icon{% if attribute_data.current_value == option.term_id %} active{% endif %} svg"> |
||||||
<div class="product-price"> |
{% endif %} |
||||||
<div class="product-price-main"> |
<div class="product-constructor__block-item-name">{{option.name}}</div> |
||||||
{{post.getPrice}} |
</a> |
||||||
</div> |
{% endfor %} |
||||||
{% if post.getRegularPrice %} |
</div> |
||||||
<div class="product-price-disc"> |
</div> |
||||||
<div class="product-price-old">{{post.getRegularPrice}}</div> |
{% endif %} |
||||||
<div class="product-price-percent"> |
{% endfor %} |
||||||
{{ post.getPriceDifferenceInPercent }} |
|
||||||
</div> |
<div class="product-price"> |
||||||
</div> |
<div class="product-price-main"> |
||||||
{% endif %} |
{{post.getPrice}} |
||||||
</div> |
</div> |
||||||
{% set in_stock = post.meta('_stock_status') == 'instock' %} |
{% if post.getRegularPrice %} |
||||||
{% if in_stock %} |
<div class="product-price-disc"> |
||||||
{{ function('do_action', 'woocommerce_' ~ product.get_type() ~ '_add_to_cart') }} |
<div class="product-price-old">{{post.getRegularPrice}}</div> |
||||||
{% else %} |
<div class="product-price-percent"> |
||||||
<div class="detail-block-form__item detail-block-form__item--tn"> |
{{ post.getPriceDifferenceInPercent }} |
||||||
<button type="button" data-pname="{{ product.title }}" class="to-know open-to-know" > |
</div> |
||||||
<p>{{ function('pll_e', 'Узнать о поступлении') }}</p> |
</div> |
||||||
</button> |
{% endif %} |
||||||
</div> |
</div> |
||||||
{% endif %} |
|
||||||
</div> |
|
||||||
</div> |
<div id="product-buy-block-wrapper"> |
||||||
|
{% include 'blocks/modules/shop/product-single-add_to_cart.twig' %} |
||||||
<div class="product-desc"> |
</div> |
||||||
<div class="product-block-title"> |
</div> |
||||||
{{ fn('pll_e', 'ОПИСАНИЕ') }} |
</div> |
||||||
</div> |
|
||||||
<div class="product-desc-text"> |
<div class="product-desc"> |
||||||
{{post.content}} |
<div class="product-block-title"> |
||||||
|
{{ fn('pll_e', 'ОПИСАНИЕ') }} |
||||||
</div> |
</div> |
||||||
</div> |
<div class="product-desc-text"> |
||||||
</div> |
{{post.content}} |
||||||
|
|
||||||
<div class="product-reviews"> |
</div> |
||||||
<div class="product-reviews__head wrapper"> |
</div> |
||||||
<div class="product-block-title"> |
</div> |
||||||
{{ fn('pll_e', 'Отзывы Специалистов') }} |
{% set reviews = post.getReviews %} |
||||||
</div> |
{% if reviews %} |
||||||
<div class="product-block-arrows"> |
<div class="product-reviews"> |
||||||
<button class="slider-button-prev slider-button product-reviews-prev"></button> |
<div class="product-reviews__head wrapper"> |
||||||
<button class="slider-button-next slider-button product-reviews-next"></button> |
<div class="product-block-title"> |
||||||
</div> |
{{ fn('pll_e', 'Отзывы Специалистов') }} |
||||||
</div> |
</div> |
||||||
<div class="product-reviews-slider swiper"> |
<div class="product-block-arrows"> |
||||||
<div class="swiper-wrapper"> |
<button class="slider-button-prev slider-button product-reviews-prev"></button> |
||||||
{% for slide in post.getReviews %} |
<button class="slider-button-next slider-button product-reviews-next"></button> |
||||||
{% include "shop/reviews-slide_element.twig" with {slide: slide} %} |
</div> |
||||||
{% endfor %} |
</div> |
||||||
</div> |
<div class="product-reviews-slider swiper"> |
||||||
</div> |
<div class="swiper-wrapper"> |
||||||
|
{% for slide in reviews %} |
||||||
<div class="product-block-arrows--m"> |
{% include "shop/reviews-slide_element.twig" with {slide: slide} %} |
||||||
<button class="slider-button-prev slider-button product-reviews-prev"></button> |
{% endfor %} |
||||||
<button class="slider-button-next slider-button product-reviews-next"></button> |
</div> |
||||||
</div> |
</div> |
||||||
</div> |
|
||||||
|
<div class="product-block-arrows--m"> |
||||||
{% if post.getRelatedProducts %} |
<button class="slider-button-prev slider-button product-reviews-prev"></button> |
||||||
<div class="product-similar "> |
<button class="slider-button-next slider-button product-reviews-next"></button> |
||||||
<div class="product-similar__head wrapper"> |
</div> |
||||||
<div class="product-block-title"> |
</div> |
||||||
{{ fn('pll_e', 'вашему питомцу может понравиться') }} |
{% endif %} |
||||||
</div> |
{% if post.getRelatedProducts %} |
||||||
<div class="product-block-arrows"> |
<div class="product-similar "> |
||||||
<button class="slider-button-prev slider-button product-similar-prev"></button> |
<div class="product-similar__head wrapper"> |
||||||
<button class="slider-button-next slider-button product-similar-next"></button> |
<div class="product-block-title"> |
||||||
</div> |
{{ fn('pll_e', 'вашему питомцу может понравиться') }} |
||||||
|
</div> |
||||||
</div> |
<div class="product-block-arrows"> |
||||||
<div class="product-similar-slider wrapper"> |
<button class="slider-button-prev slider-button product-similar-prev"></button> |
||||||
<div class="swiper-wrapper"> |
<button class="slider-button-next slider-button product-similar-next"></button> |
||||||
{% for related_product in post.getRelatedProducts %} |
</div> |
||||||
|
|
||||||
{% set class = related_product.getTasteClass %} |
</div> |
||||||
{% set section = class ~ ' swiper-slide' %} |
<div class="product-similar-slider wrapper"> |
||||||
|
<div class="swiper-wrapper"> |
||||||
<!-- TO_DO (избавиться от wc_get_product) --> |
{% for related_product in post.getRelatedProducts %} |
||||||
{% include 'shop/product-card.twig' with {_product : fn('wc_get_product', related_product.id), section: section} %} |
|
||||||
|
{% set class = related_product.getTasteClass %} |
||||||
|
{% set section = class ~ ' swiper-slide' %} |
||||||
{% endfor %} |
|
||||||
</div> |
<!-- TO_DO (избавиться от wc_get_product) --> |
||||||
</div> |
{% include 'shop/product-card.twig' with {_product : fn('wc_get_product', related_product.id), section: section} %} |
||||||
<div class="product-block-arrows--m"> |
|
||||||
<button class="slider-button-prev slider-button product-similar-prev"></button> |
|
||||||
<button class="slider-button-next slider-button product-similar-next"></button> |
{% endfor %} |
||||||
</div> |
</div> |
||||||
</div> |
</div> |
||||||
{% endif %} |
<div class="product-block-arrows--m"> |
||||||
|
<button class="slider-button-prev slider-button product-similar-prev"></button> |
||||||
</div> |
<button class="slider-button-next slider-button product-similar-next"></button> |
||||||
{% for slide in reviews %} |
</div> |
||||||
|
</div> |
||||||
{% include 'modal/rewiew_modal.twig' with {slide : slide} %} |
{% endif %} |
||||||
|
|
||||||
{% endfor %} |
</div> |
||||||
|
{% for slide in reviews %} |
||||||
|
|
||||||
|
{% include 'modal/rewiew_modal.twig' with {slide : slide} %} |
||||||
|
|
||||||
|
{% endfor %} |
||||||
{% endblock %} |
{% endblock %} |
@ -0,0 +1,52 @@ |
|||||||
|
<?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'); |
||||||
|
} |
||||||
|
|
||||||
|
// Рендеринг уже происходит внутри компонентов, поэтому здесь ничего не нужно |
@ -1,5 +0,0 @@ |
|||||||
<?php |
|
||||||
|
|
||||||
include_component('shop', 'catalog') |
|
||||||
|
|
||||||
?> |
|