Task 7719 | натяжка верстки single товара.

web_10
parent 69a3325070
commit 8a26495373
  1. 7
      wp-content/themes/cosmopet/functions.php
  2. 136
      wp-content/themes/cosmopet/modules/shop/CosmopetProduct.php
  3. 5
      wp-content/themes/cosmopet/modules/shop/components/product-single--new/assets/css/product-style.css
  4. 13
      wp-content/themes/cosmopet/modules/shop/components/single-product_new/component-controller.php
  5. 22
      wp-content/themes/cosmopet/single-product.php
  6. 86
      wp-content/themes/cosmopet/views/_pages/shop/archive-product.twig
  7. 321
      wp-content/themes/cosmopet/views/shop/single-product.twig

@ -32,14 +32,21 @@ add_filter('timber/post/classmap', function ($classmap) {
return $classmap; return $classmap;
}, 100); }, 100);
<<<<<<< HEAD
add_filter('timber/post/classmap', function ($classmap) { add_filter('timber/post/classmap', function ($classmap) {
$classmap['product'] = CosmopetProduct::class; $classmap['product'] = CosmopetProduct::class;
return $classmap; return $classmap;
}, 100); }, 100);
=======
>>>>>>> 51869ae1 (Task 7719 | натяжка верстки single товара.)
function allow_svg_upload($mimes) { function allow_svg_upload($mimes) {
$mimes['svg'] = 'image/svg+xml'; $mimes['svg'] = 'image/svg+xml';
return $mimes; return $mimes;
} }
<<<<<<< HEAD
add_filter('upload_mimes', 'allow_svg_upload'); add_filter('upload_mimes', 'allow_svg_upload');
=======
add_filter('upload_mimes', 'allow_svg_upload');
>>>>>>> 51869ae1 (Task 7719 | натяжка верстки single товара.)

@ -7,6 +7,7 @@ use Timber\Integrations\WooCommerce\Product as TimberProduct;
class CosmopetProduct extends TimberProduct { class CosmopetProduct extends TimberProduct {
protected $sibling_categories = [ protected $sibling_categories = [
<<<<<<< HEAD
<<<<<<< HEAD <<<<<<< HEAD
'pa_compound', 'pa_compound',
'pa_dog-size', 'pa_dog-size',
@ -19,6 +20,13 @@ class CosmopetProduct extends TimberProduct {
'pa_compound', 'pa_compound',
'pa_reproductive-status', 'pa_reproductive-status',
>>>>>>> 909cd3ca (Task 7719 | натяжка верстки single страницы товара) >>>>>>> 909cd3ca (Task 7719 | натяжка верстки single страницы товара)
=======
'pa_compound',
'pa_dog-size',
'pa_reproductive-status',
'pa_age-of-the-cat',
'pa_age-of-the-dog',
>>>>>>> 51869ae1 (Task 7719 | натяжка верстки single товара.)
'pa_series', 'pa_series',
]; ];
@ -53,11 +61,15 @@ class CosmopetProduct extends TimberProduct {
// Получаем галерею изображений // Получаем галерею изображений
if ($this->product && method_exists($this->product, 'get_gallery_image_ids')) { if ($this->product && method_exists($this->product, 'get_gallery_image_ids')) {
<<<<<<< HEAD
<<<<<<< HEAD <<<<<<< HEAD
$gallery_image_ids = $this->product->get_gallery_image_ids(); $gallery_image_ids = $this->product->get_gallery_image_ids();
======= =======
$gallery_image_ids = $this->product->get_gallery_image_ids(); $gallery_image_ids = $this->product->get_gallery_image_ids();
>>>>>>> 909cd3ca (Task 7719 | натяжка верстки single страницы товара) >>>>>>> 909cd3ca (Task 7719 | натяжка верстки single страницы товара)
=======
$gallery_image_ids = $this->product->get_gallery_image_ids();
>>>>>>> 51869ae1 (Task 7719 | натяжка верстки single товара.)
} else { } else {
$gallery_image_ids = []; $gallery_image_ids = [];
} }
@ -88,11 +100,15 @@ class CosmopetProduct extends TimberProduct {
} }
else{ else{
if ($this->product && method_exists($this->product, 'get_weight')) { if ($this->product && method_exists($this->product, 'get_weight')) {
<<<<<<< HEAD
<<<<<<< HEAD <<<<<<< HEAD
return $this->product->get_weight() ? $this->product->get_weight() . ' ' . $custom_measurement : ''; return $this->product->get_weight() ? $this->product->get_weight() . ' ' . $custom_measurement : '';
======= =======
return $this->product->get_weight() ? $this->product->get_weight() . ' ' . $custom_measurement : ''; return $this->product->get_weight() ? $this->product->get_weight() . ' ' . $custom_measurement : '';
>>>>>>> 909cd3ca (Task 7719 | натяжка верстки single страницы товара) >>>>>>> 909cd3ca (Task 7719 | натяжка верстки single страницы товара)
=======
return $this->product->get_weight() ? $this->product->get_weight() . ' ' . $custom_measurement : '';
>>>>>>> 51869ae1 (Task 7719 | натяжка верстки single товара.)
} }
return ''; return '';
} }
@ -250,11 +266,15 @@ class CosmopetProduct extends TimberProduct {
// Extract just the posts in sorted order // Extract just the posts in sorted order
$sorted_siblings = array_map(function($item) { $sorted_siblings = array_map(function($item) {
return $item['post']; return $item['post'];
<<<<<<< HEAD
<<<<<<< HEAD <<<<<<< HEAD
}, $siblings_with_weights); }, $siblings_with_weights);
======= =======
}, $siblings_with_weights); }, $siblings_with_weights);
>>>>>>> 909cd3ca (Task 7719 | натяжка верстки single страницы товара) >>>>>>> 909cd3ca (Task 7719 | натяжка верстки single страницы товара)
=======
}, $siblings_with_weights);
>>>>>>> 51869ae1 (Task 7719 | натяжка верстки single товара.)
return $sorted_siblings; return $sorted_siblings;
} }
@ -302,6 +322,7 @@ class CosmopetProduct extends TimberProduct {
} }
} }
<<<<<<< HEAD
<<<<<<< HEAD <<<<<<< HEAD
@ -347,15 +368,41 @@ class CosmopetProduct extends TimberProduct {
error_log("Текущий вес (числовой): " . $current_weight); error_log("Текущий вес (числовой): " . $current_weight);
error_log("Всего товаров в коллекции: " . count($all_products)); error_log("Всего товаров в коллекции: " . count($all_products));
error_log("Атрибуты текущего товара: " . print_r($current_product_attributes, true)); error_log("Атрибуты текущего товара: " . print_r($current_product_attributes, true));
=======
>>>>>>> 51869ae1 (Task 7719 | натяжка верстки single товара.)
// Получаем упорядоченные таксономии
$ordered_taxonomies = $this->getOrderedTaxonomies();
// Группируем товары по атрибутам // Инициализируем конструктор для всех таксономий
foreach ($this->sibling_categories as $taxonomy) { foreach ($this->sibling_categories as $taxonomy) {
// Проверяем, есть ли у текущего товара значение для этой категории if (isset($current_product_attributes[$taxonomy])) {
if (!isset($current_product_attributes[$taxonomy])) { $constructor[$taxonomy] = [
error_log("Пропускаем $taxonomy - нет значения у текущего товара"); 'taxonomy' => $taxonomy,
continue; // Пропускаем, если у товара нет значения для этой категории 'label' => $this->getAttributeLabel($taxonomy),
'current_value' => $this->getCurrentAttributeValue($taxonomy),
'options' => []
];
}
}
// ОБХОДИМ МАССИВ ТОВАРОВ ТОЛЬКО ОДИН РАЗ
foreach ($all_products as $product) {
// Получаем все атрибуты сравниваемого товара за один раз
$compare_attributes = [];
$compare_weight = $product->getNumericWeight();
foreach ($this->sibling_categories as $taxonomy) {
$terms = get_the_terms($product->id, $taxonomy);
if ($terms && !is_wp_error($terms)) {
$compare_attributes[$taxonomy] = array_map(function($term) {
return $term->term_id;
}, $terms);
}
} }
<<<<<<< HEAD
$constructor[$taxonomy] = [ $constructor[$taxonomy] = [
'taxonomy' => $taxonomy, 'taxonomy' => $taxonomy,
'label' => $this->getAttributeLabel($taxonomy), 'label' => $this->getAttributeLabel($taxonomy),
@ -377,10 +424,18 @@ class CosmopetProduct extends TimberProduct {
}, $terms); }, $terms);
} }
>>>>>>> 909cd3ca (Task 7719 | натяжка верстки single страницы товара) >>>>>>> 909cd3ca (Task 7719 | натяжка верстки single страницы товара)
=======
// Проверяем, подходит ли товар для каждой таксономии
foreach ($this->sibling_categories as $taxonomy) {
// Пропускаем, если у текущего товара нет значения для этой категории
if (!isset($current_product_attributes[$taxonomy])) {
continue;
>>>>>>> 51869ae1 (Task 7719 | натяжка верстки single товара.)
} }
// Проверяем, совпадают ли все остальные атрибуты и вес // Проверяем, совпадают ли все остальные атрибуты и вес
$attributes_match = true; $attributes_match = true;
<<<<<<< HEAD
<<<<<<< HEAD <<<<<<< HEAD
// Проверяем все атрибуты кроме текущей таксономии // Проверяем все атрибуты кроме текущей таксономии
@ -389,6 +444,10 @@ class CosmopetProduct extends TimberProduct {
// Проверяем только атрибуты из sibling_categories // Проверяем только атрибуты из sibling_categories
>>>>>>> 909cd3ca (Task 7719 | натяжка верстки single страницы товара) >>>>>>> 909cd3ca (Task 7719 | натяжка верстки single страницы товара)
=======
// Проверяем все атрибуты кроме текущей таксономии
>>>>>>> 51869ae1 (Task 7719 | натяжка верстки single товара.)
foreach ($this->sibling_categories as $compare_taxonomy) { foreach ($this->sibling_categories as $compare_taxonomy) {
if ($compare_taxonomy === $taxonomy) { if ($compare_taxonomy === $taxonomy) {
continue; // Пропускаем проверяемую категорию continue; // Пропускаем проверяемую категорию
@ -400,9 +459,12 @@ class CosmopetProduct extends TimberProduct {
if (!isset($compare_attributes[$compare_taxonomy])) { if (!isset($compare_attributes[$compare_taxonomy])) {
$attributes_match = false; $attributes_match = false;
<<<<<<< HEAD <<<<<<< HEAD
<<<<<<< HEAD
======= =======
$differences[] = "Нет атрибута $compare_taxonomy у сравниваемого товара"; $differences[] = "Нет атрибута $compare_taxonomy у сравниваемого товара";
>>>>>>> 909cd3ca (Task 7719 | натяжка верстки single страницы товара) >>>>>>> 909cd3ca (Task 7719 | натяжка верстки single страницы товара)
=======
>>>>>>> 51869ae1 (Task 7719 | натяжка верстки single товара.)
break; break;
} }
@ -414,9 +476,12 @@ class CosmopetProduct extends TimberProduct {
array_diff($compare_values, $current_values) !== []) { array_diff($compare_values, $current_values) !== []) {
$attributes_match = false; $attributes_match = false;
<<<<<<< HEAD <<<<<<< HEAD
<<<<<<< HEAD
======= =======
$differences[] = "Не совпадают значения для $compare_taxonomy"; $differences[] = "Не совпадают значения для $compare_taxonomy";
>>>>>>> 909cd3ca (Task 7719 | натяжка верстки single страницы товара) >>>>>>> 909cd3ca (Task 7719 | натяжка верстки single страницы товара)
=======
>>>>>>> 51869ae1 (Task 7719 | натяжка верстки single товара.)
break; break;
} }
} }
@ -426,15 +491,19 @@ class CosmopetProduct extends TimberProduct {
if (isset($compare_attributes[$compare_taxonomy])) { if (isset($compare_attributes[$compare_taxonomy])) {
$attributes_match = false; $attributes_match = false;
<<<<<<< HEAD <<<<<<< HEAD
<<<<<<< HEAD
======= =======
$differences[] = "У сравниваемого товара есть атрибут $compare_taxonomy, а у текущего нет"; $differences[] = "У сравниваемого товара есть атрибут $compare_taxonomy, а у текущего нет";
>>>>>>> 909cd3ca (Task 7719 | натяжка верстки single страницы товара) >>>>>>> 909cd3ca (Task 7719 | натяжка верстки single страницы товара)
=======
>>>>>>> 51869ae1 (Task 7719 | натяжка верстки single товара.)
break; break;
} }
} }
} }
// Проверяем вес (числовое сравнение) // Проверяем вес (числовое сравнение)
<<<<<<< HEAD
<<<<<<< HEAD <<<<<<< HEAD
if (abs($current_weight - $compare_weight) > 0.01) { if (abs($current_weight - $compare_weight) > 0.01) {
$attributes_match = false; $attributes_match = false;
@ -444,14 +513,21 @@ class CosmopetProduct extends TimberProduct {
$attributes_match = false; $attributes_match = false;
$differences[] = "Не совпадает вес: текущий '$current_weight' vs сравниваемый '$compare_weight'"; $differences[] = "Не совпадает вес: текущий '$current_weight' vs сравниваемый '$compare_weight'";
>>>>>>> 909cd3ca (Task 7719 | натяжка верстки single страницы товара) >>>>>>> 909cd3ca (Task 7719 | натяжка верстки single страницы товара)
=======
if (abs($current_weight - $compare_weight) > 0.01) {
$attributes_match = false;
>>>>>>> 51869ae1 (Task 7719 | натяжка верстки single товара.)
} }
// Если все атрибуты и вес совпадают, добавляем товар в группу // Если все атрибуты и вес совпадают, добавляем товар в группу
if ($attributes_match) { if ($attributes_match) {
<<<<<<< HEAD <<<<<<< HEAD
<<<<<<< HEAD
======= =======
error_log("Товар {$product->id} подходит для атрибута $taxonomy"); error_log("Товар {$product->id} подходит для атрибута $taxonomy");
>>>>>>> 909cd3ca (Task 7719 | натяжка верстки single страницы товара) >>>>>>> 909cd3ca (Task 7719 | натяжка верстки single страницы товара)
=======
>>>>>>> 51869ae1 (Task 7719 | натяжка верстки single товара.)
$product_terms = get_the_terms($product->id, $taxonomy); $product_terms = get_the_terms($product->id, $taxonomy);
if ($product_terms && !is_wp_error($product_terms)) { if ($product_terms && !is_wp_error($product_terms)) {
foreach ($product_terms as $term) { foreach ($product_terms as $term) {
@ -459,6 +535,7 @@ class CosmopetProduct extends TimberProduct {
if (!isset($constructor[$taxonomy]['options'][$option_key])) { if (!isset($constructor[$taxonomy]['options'][$option_key])) {
$constructor[$taxonomy]['options'][$option_key] = [ $constructor[$taxonomy]['options'][$option_key] = [
'term_id' => $term->term_id, 'term_id' => $term->term_id,
<<<<<<< HEAD
<<<<<<< HEAD <<<<<<< HEAD
'name' => $this->getTermName($term->term_id, $taxonomy), 'name' => $this->getTermName($term->term_id, $taxonomy),
'slug' => $term->slug, 'slug' => $term->slug,
@ -467,12 +544,18 @@ class CosmopetProduct extends TimberProduct {
'name' => $term->name, 'name' => $term->name,
'slug' => $term->slug, 'slug' => $term->slug,
>>>>>>> 909cd3ca (Task 7719 | натяжка верстки single страницы товара) >>>>>>> 909cd3ca (Task 7719 | натяжка верстки single страницы товара)
=======
'name' => $this->getTermName($term->term_id, $taxonomy),
'slug' => $term->slug,
'icon' => $this->getTermIcon($term->term_id, $taxonomy),
>>>>>>> 51869ae1 (Task 7719 | натяжка верстки single товара.)
'products' => [] 'products' => []
]; ];
} }
$constructor[$taxonomy]['options'][$option_key]['products'][] = $product; $constructor[$taxonomy]['options'][$option_key]['products'][] = $product;
} }
} }
<<<<<<< HEAD
<<<<<<< HEAD <<<<<<< HEAD
} }
} }
@ -525,22 +608,55 @@ class CosmopetProduct extends TimberProduct {
error_log("Опция $option_id ({$option['name']}): " . count($option['products']) . " товаров"); error_log("Опция $option_id ({$option['name']}): " . count($option['products']) . " товаров");
foreach ($option['products'] as $product) { foreach ($option['products'] as $product) {
error_log(" - Товар {$product->id}: {$product->title}"); error_log(" - Товар {$product->id}: {$product->title}");
=======
>>>>>>> 51869ae1 (Task 7719 | натяжка верстки single товара.)
}
}
}
// Сортируем опции по порядку терминов для каждой таксономии
foreach ($constructor as $taxonomy => $taxonomy_data) {
if (isset($ordered_taxonomies[$taxonomy])) {
$ordered_options = [];
foreach ($ordered_taxonomies[$taxonomy] as $term) {
if (isset($constructor[$taxonomy]['options'][$term->term_id])) {
$ordered_options[$term->term_id] = $constructor[$taxonomy]['options'][$term->term_id];
}
}
$constructor[$taxonomy]['options'] = $ordered_options;
}
} }
// Сортируем итоговый конструктор по порядку таксономий
$ordered_constructor = [];
foreach ($this->sibling_categories as $taxonomy) {
if (isset($constructor[$taxonomy])) {
$ordered_constructor[$taxonomy] = $constructor[$taxonomy];
} }
} }
error_log("Итоговый конструктор: " . print_r($constructor, true)); return $ordered_constructor;
return $constructor;
} }
protected function getAttributeLabel($taxonomy) { protected function getAttributeLabel($taxonomy) {
// Fallback на старые метки
$labels = [ $labels = [
<<<<<<< HEAD
'pa_age-of-the-cat' => 'ВОЗРАСТ КОШКИ', 'pa_age-of-the-cat' => 'ВОЗРАСТ КОШКИ',
'pa_age-of-the-dog' => 'ВОЗРАСТ СОБАКИ', 'pa_age-of-the-dog' => 'ВОЗРАСТ СОБАКИ',
'pa_compound' => 'ВКУС КОРМА', 'pa_compound' => 'ВКУС КОРМА',
'pa_reproductive-status' => 'РЕПРОДУКТИВНЫЙ СТАТУС', 'pa_reproductive-status' => 'РЕПРОДУКТИВНЫЙ СТАТУС',
'pa_series' => 'СЕРИЯ', 'pa_series' => 'СЕРИЯ',
>>>>>>> 909cd3ca (Task 7719 | натяжка верстки single страницы товара) >>>>>>> 909cd3ca (Task 7719 | натяжка верстки single страницы товара)
=======
'pa_age-of-the-cat' => pll__('ВОЗРАСТ КОШКИ'),
'pa_age-of-the-dog' => pll__('ВОЗРАСТ СОБАКИ'),
'pa_dog-size' => pll__('РАЗМЕР СОБАКИ'),
'pa_compound' => pll__('ВКУС КОРМА'),
'pa_reproductive-status' => pll__('ВИД КОШКИ'),
'pa_series' => pll__('СЕРИЯ'),
>>>>>>> 51869ae1 (Task 7719 | натяжка верстки single товара.)
]; ];
return $labels[$taxonomy] ?? wc_attribute_label($taxonomy); return $labels[$taxonomy] ?? wc_attribute_label($taxonomy);
@ -555,6 +671,9 @@ class CosmopetProduct extends TimberProduct {
} }
<<<<<<< HEAD <<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> 51869ae1 (Task 7719 | натяжка верстки single товара.)
/** /**
* Получает таксономии в правильном порядке с учетом сортировки * Получает таксономии в правильном порядке с учетом сортировки
* @return array Массив таксономий с их порядком * @return array Массив таксономий с их порядком
@ -720,8 +839,11 @@ class CosmopetProduct extends TimberProduct {
<<<<<<< HEAD
======= =======
>>>>>>> 909cd3ca (Task 7719 | натяжка верстки single страницы товара) >>>>>>> 909cd3ca (Task 7719 | натяжка верстки single страницы товара)
=======
>>>>>>> 51869ae1 (Task 7719 | натяжка верстки single товара.)
public function getAllAttributes() { public function getAllAttributes() {
$attributes = []; $attributes = [];
foreach ($this->sibling_categories as $taxonomy) { foreach ($this->sibling_categories as $taxonomy) {

@ -756,7 +756,7 @@ line-height: 143%;
.stock, .quantity{ .stock, .quantity{
display: none; display: none;
<<<<<<< HEAD:wp-content/themes/cosmopet/modules/shop/components/product-single--new/assets/css/product-style.css
} }
@ -900,6 +900,3 @@ line-height: 143%;
.product-incart__wrap.loading .product-incart__count { .product-incart__wrap.loading .product-incart__count {
opacity: 0.5; opacity: 0.5;
} }
=======
}
>>>>>>> 909cd3ca (Task 7719 | натяжка верстки single страницы товара):wp-content/themes/cosmopet/modules/shop/components/single-product_new/assets/css/product-style.css

@ -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,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');
}
}

@ -1,86 +0,0 @@
{% set bodyClass = 'bg-white' %}
{% set mainClass = 'wrapper' %}
{% extends 'layout.twig' %}
{% block content %}
<div class="breadcrumbs">
<a href="/" class="breadcrumbs__item">
{{ function('pll_e', 'Главная') }}
</a>
<a href="/shop" class="breadcrumbs__item">
{{ function('pll_e', 'Продукция') }}
</a>
{% if category %}
<a href="{{ category_link }}" class="breadcrumbs__item">
{{ category_title }}
</a>
{% endif %}
</div>
<div class="product">
<div class="product__header">
<h1 class="product__title">
{% if category %}
{{ category.name }}
{% else %}
{{ function('pll_e', 'Продукция') }}
{% endif %}
</h1>
<button class="button button--gradient button--high button--icon button--filter">
{{ function('pll_e', 'Фильтры') }}
</button>
</div>
{% if active_filters|length > 0 %}
<div class="active-filters">
{% if active_filters is not empty %}
<div class="active-filters">
{% for filter in active_filters %}
<span class="active-filter-tag" data-filter-id="{{ filter.id }}" data-filter-slug="{{ filter.slug }}" data-filter-taxonomy="{{ filter.taxonomy }}">
{{ filter.name }} ×
</span>
{% endfor %}
</div>
{% endif %}
<button class="active-filters__clear button button--white">
{% if current_lang == 'ru' %}{{ function('pll_e', 'Очистить все') }}{% elseif current_lang == 'en' %}{{ function('pll_e', 'Clear all') }}{% endif %}
</button>
</div>
{% endif %}
<div class="product__main">
{% if posts|length > 0 %}
{% for post in posts %}
{% set class = post.getTasteClass %}
{% set section = class ~ ' product-archive-card' %}
<!-- TO_DO (избавиться от wc_get_product) -->
{% include 'shop/product-card.twig' with {_product : fn('wc_get_product', post.id), section: section} %}
{% endfor %}
{% else %}
<div class="not-found">
<img src="{{ fn('get_template_directory_uri') }}/static/img/sv.svg" alt="">
<div class="not-found-title">{{ fn('pll_e', 'coming soon') }}</div>
<div class="not-found-text">{{ fn('pll_e', 'This item is not on our website yet, but it will be here very soon') }}</div>
</div>
{% endif %}
</div>
<div class="product__footer product__footer--error">
{% if posts_per_page < count %}
<button class="button button--white" id="load-more-products" data-category_id="{{ category_id }}" data-category_type="{{ category_type }}">
{{ function('pll_e', 'Загрузить еще') }}
</button>
{% endif %}
</div>
</div>
{% endblock %}

@ -1,321 +0,0 @@
{% set bodyClass = 'bg-white' %}
{% set mainClass = '' %}
{% extends 'layout.twig' %}
{% block content %}
<div class="product-single">
<div class="wrapper">
<div class="breadcrumbs">
<a href="{{ fn('home_url') }}" class="breadcrumbs__item">
{{ fn('pll_e', 'Главная') }}
</a>
{% set product_categories = post.get_terms('product_cat') %}
{% if product_categories %}
{% set category = product_categories[0] %}
<a href="{{ category.link }}" class="breadcrumbs__item">
{{ category.name }}
</a>
{% endif %}
<a href="{{post.link}}" class="breadcrumbs__item">
{{post.title}}
</a>
</div>
<div class="product_main {{ post.getTasteClass() }}">
<div class="product-info">
<h1 class="product-title --pc">
{{post.title}}
</h1>
<div class="product-contains">
<h2 class="product-block-title">{{ fn('pll_e', 'СОСТАВ') }}</h2>
<div class="product-contains-text">{{ post.getComposition }}</div>
</div>
<div class="product-values">
<h2 class="product-values-title">{{ fn('pll_e', 'ПИЩЕВАЯ ЦЕННОСТЬ') }}</h2>
<div class="product-values-list">
{% set nutritional_value = post.nutritional_value %}
{% if nutritional_value.protein %}
<div class="product-values-item">
<div class="product-values-item__name">{{ fn('pll_e', 'Сырой белок') }}</div>
<div class="product-values-item-val">{{nutritional_value.protein}}</div>
</div>
{% endif %}
{% if nutritional_value.fat %}
<div class="product-values-item">
<div class="product-values-item__name">{{ fn('pll_e', 'Сырой жир') }}</div>
<div class="product-values-item-val">{{nutritional_value.fat}}</div>
</div>
{% endif %}
{% if nutritional_value.fiber %}
<div class="product-values-item">
<div class="product-values-item__name">{{ fn('pll_e', 'Сырая клетчатка') }}</div>
<div class="product-values-item-val">{{nutritional_value.fiber}}</div>
</div>
{% endif %}
{% if nutritional_value.ash %}
<div class="product-values-item">
<div class="product-values-item__name">{{ fn('pll_e', 'Сырая зола') }}</div>
<div class="product-values-item-val">{{nutritional_value.ash}}</div>
</div>
{% endif %}
{% if nutritional_value.wat %}
<div class="product-values-item">
<div class="product-values-item__name">{{ fn('pll_e', 'Влажность') }}</div>
<div class="product-values-item-val">{{nutritional_value.wat}}</div>
</div>
{% endif %}
{% if nutritional_value.calcium %}
<div class="product-values-item">
<div class="product-values-item__name">{{ fn('pll_e', 'Кальций') }}</div>
<div class="product-values-item-val">{{nutritional_value.calcium}}</div>
</div>
{% endif %}
{% if nutritional_value.phosphorus %}
<div class="product-values-item">
<div class="product-values-item__name">{{ fn('pll_e', 'Фосфор') }}</div>
<div class="product-values-item-val">{{nutritional_value.phosphorus}}</div>
</div>
{% endif %}
{% if nutritional_value.omega_6 %}
<div class="product-values-item">
<div class="product-values-item__name">{{ fn('pll_e', 'Омега 6') }}</div>
<div class="product-values-item-val">{{nutritional_value.omega_6}}</div>
</div>
{% endif %}
{% if nutritional_value.omega_3 %}
<div class="product-values-item">
<div class="product-values-item__name">{{ fn('pll_e', 'Омега 3') }}</div>
<div class="product-values-item-val">{{nutritional_value.omega_3}}</div>
</div>
{% endif %}
</div>
{% set vitamins = post.vitamins %}
{% if vitamins %}
<div class="product-vitamins">
<div class="product-vitamins-title">
{{ fn('pll_e', 'Витамины на кг') }}
</div>
<div class="product-vitamins-list">
{% if vitamins.vitamin_a_me %}
<div class="product-vitamins-item">A, ME — {{vitamins.vitamin_a_me}}</div>
{% endif %}
{% if vitamins.vitamin_d3_me %}
<div class="product-vitamins-item">D3, ME — {{vitamins.vitamin_d3_me}}</div>
{% endif %}
{% if vitamins.vitamin_e %}
<div class="product-vitamins-item">E — {{vitamins.vitamin_e}}</div>
{% endif %}
{% if vitamins.tiamin %}
<div class="product-vitamins-item">{{ fn('pll_e', 'Тиамин') }} — {{vitamins.tiamin}}</div>
{% endif %}
{% if vitamins.riboflavin %}
<div class="product-vitamins-item">{{ fn('pll_e', 'Рибофлавин') }} — {{vitamins.riboflavin}}</div>
{% endif %}
{% if vitamins.pantothenic_acid %}
<div class="product-vitamins-item">{{ fn('pll_e', 'Пантотеновая кислота') }} — {{vitamins.pantothenic_acid}}</div>
{% endif %}
{% if vitamins.niaczin %}
<div class="product-vitamins-item">{{ fn('pll_e', 'Ниацин') }} — {{vitamins.niaczin}}</div>
{% endif %}
{% if vitamins.piridoksin %}
<div class="product-vitamins-item">{{ fn('pll_e', 'Пиридоксин') }} — {{vitamins.piridoksin}}</div>
{% endif %}
{% if vitamins.folic_acid %}
<div class="product-vitamins-item">{{ fn('pll_e', 'Фолиевая кислота') }} — {{vitamins.folic_acid}}</div>
{% endif %}
{% if vitamins.vitamin_b12 %}
<div class="product-vitamins-item">{{ fn('pll_e', 'Витамин B12') }} — {{vitamins.vitamin_b12}}</div>
{% endif %}
{% if vitamins.holin %}
<div class="product-vitamins-item">{{ fn('pll_e', 'Холин') }} — {{vitamins.holin}}</div>
{% endif %}
</div>
</div>
{% endif %}
</div>
</div>
<div class="product-show">
<div class="product-gallery">
<div class="swiper product-gallery__mainSlider">
<div class="swiper-wrapper">
{% set image_list = post.getImageGallery('full') %}
{% for image in image_list %}
<div class="swiper-slide">
<img src="{{ image.url }}" alt="{{image.alt}}">
</div>
{% endfor %}
</div>
</div>
<div thumbsSlider="" class="swiper product-gallery__thumbsSlider">
<div class="swiper-wrapper">
{% set image_list = post.getImageGallery('medium') %}
{% for image in image_list %}
<div class="swiper-slide">
<img src="{{ image.url }}" alt="{{image.alt}}">
</div>
{% endfor %}
</div>
<div class="product-gallery-arrows">
<button class="product-gallery-arrow product-gallery-prev"></button>
<button class="product-gallery-arrow product-gallery-next"></button>
</div>
</div>
<div class="product-gallery-bullets"></div>
</div>
<h1 class="product-title --m">
{{post.title}}
</h1>
</div>
<div class="product-constructor">
{% set constructor = post.getProductConstructor %}
{% for taxonomy, attribute_data in constructor %}
<div class="product-constructor__block">
<div class="product-constructor__block-title">{{attribute_data.label}}</div>
<div class="product-constructor__block-list">
{% for option_id, option in attribute_data.options %}
{% set first_product = option.products[0] %}
<a href="{{first_product.link}}" class="product-constructor__block-item{% if attribute_data.current_value == option.term_id %} active{% endif %}">
{% if taxonomy == 'pa_compound' %}
{% set icon_map = {
'govyadina': 'beef',
'indejka': 'turkey',
'krolik': 'rabbit',
'losos': 'salmon',
'ryba': 'fish',
'utka': 'duck',
'yagnenok': 'lamb'
} %}
{% set icon_class = icon_map[option.slug] ?? 'default' %}
<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">
{% elseif taxonomy == 'pa_age-of-the-dog' %}
<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">
{% elseif taxonomy == 'pa_age-of-the-cat' %}
<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">
{% 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">
{% elseif taxonomy == 'pa_series' %}
<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">
{% endif %}
<div class="product-constructor__block-item-name">{{option.name}}</div>
</a>
{% endfor %}
</div>
</div>
{% endfor %}
{% set size_siblings = post.getSizeSiblings %}
{% if size_siblings %}
<div class="product-constructor__block">
<div class="product-constructor__block-title">{{fn('pll_e', 'ВЕС УПАКОВКИ')}}</div>
<div class="product-constructor__block-list">
{% for sibling in size_siblings %}
<a href="{{sibling.link}}" class="product-constructor__block-item{% if post.get_weight == sibling.get_weight %} active{% endif %}">
<div class="product-constructor__block-item-name">{{sibling.get_weight}}</div>
</a>
{% endfor %}
</div>
</div>
{% endif %}
<div class="product-price">
<div class="product-price-main">
{{post.getPrice}}
</div>
{% if post.getRegularPrice %}
<div class="product-price-disc">
<div class="product-price-old">{{post.getRegularPrice}}</div>
<div class="product-price-percent">
{{ post.getPriceDifferenceInPercent }}
</div>
</div>
{% endif %}
</div>
{% set in_stock = post.meta('_stock_status') == 'instock' %}
{% if in_stock %}
{{ function('do_action', 'woocommerce_' ~ product.get_type() ~ '_add_to_cart') }}
{% 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 %}
</div>
</div>
<div class="product-desc">
<div class="product-block-title">
{{ fn('pll_e', 'ОПИСАНИЕ') }}
</div>
<div class="product-desc-text">
{{post.content}}
</div>
</div>
</div>
<div class="product-reviews">
<div class="product-reviews__head wrapper">
<div class="product-block-title">
{{ fn('pll_e', 'Отзывы Специалистов') }}
</div>
<div class="product-block-arrows">
<button class="slider-button-prev slider-button product-reviews-prev"></button>
<button class="slider-button-next slider-button product-reviews-next"></button>
</div>
</div>
<div class="product-reviews-slider swiper">
<div class="swiper-wrapper">
{% for slide in post.getReviews %}
{% include "shop/reviews-slide_element.twig" with {slide: slide} %}
{% endfor %}
</div>
</div>
<div class="product-block-arrows--m">
<button class="slider-button-prev slider-button product-reviews-prev"></button>
<button class="slider-button-next slider-button product-reviews-next"></button>
</div>
</div>
{% if post.getRelatedProducts %}
<div class="product-similar ">
<div class="product-similar__head wrapper">
<div class="product-block-title">
{{ fn('pll_e', 'вашему питомцу может понравиться') }}
</div>
<div class="product-block-arrows">
<button class="slider-button-prev slider-button product-similar-prev"></button>
<button class="slider-button-next slider-button product-similar-next"></button>
</div>
</div>
<div class="product-similar-slider wrapper">
<div class="swiper-wrapper">
{% for related_product in post.getRelatedProducts %}
{% set class = related_product.getTasteClass %}
{% set section = class ~ ' swiper-slide' %}
<!-- TO_DO (избавиться от wc_get_product) -->
{% include 'shop/product-card.twig' with {_product : fn('wc_get_product', related_product.id), section: section} %}
{% endfor %}
</div>
</div>
<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>
</div>
</div>
{% endif %}
</div>
{% for slide in reviews %}
{% include 'modal/rewiew_modal.twig' with {slide : slide} %}
{% endfor %}
{% endblock %}
Loading…
Cancel
Save