Andrei | фикс каталога (поместил файлы single страницы в правильные директории удалил лишние файлы которые не использовались)

dev_10_fixbugs
Andrei 2 months ago
parent 39ef43e7fd
commit c74600377a
  1. 55
      wp-content/themes/cosmopet/modules/shop/components/single-product/component-controller.php
  2. 50
      wp-content/themes/cosmopet/single-product.php
  3. 986
      wp-content/themes/cosmopet/templates/_pages/shop/product-single.twig
  4. 1
      wp-content/themes/cosmopet/templates/shop/index.php
  5. 63
      wp-content/themes/cosmopet/templates/shop/single-product.php
  6. 19
      wp-content/themes/cosmopet/woocommerce/single-product.php

@ -1,11 +1,6 @@
<?php <?php
// add_filter('timber/context', function($context) {
// $context['test'] = 111111111;
// return $context;
// });
// $product->is_type('variable')
$product; $product;
$product_type; $product_type;
$context_for_twig; $context_for_twig;
@ -103,3 +98,53 @@ add_filter('timber/context', function ($context) use ($context_for_twig) {
return array_merge($context, $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 = wc_get_related_products($product_id, 5);
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;
}
}
}
Timber::render('_pages/shop/product-single.twig', $context);

@ -8,53 +8,5 @@ if (is_product()) {
include_module('shop'); include_module('shop');
include_component('shop', 'single-product'); include_component('shop', 'single-product');
$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 = wc_get_related_products($product_id, 5);
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;
}
}
}
Timber::render('modules/shop/components/single-product/component-template.twig', $context);
} }

@ -1,494 +1,494 @@
{% set current_path = template_path ~ '/modules/shop/components/single-product' %} {% set current_path = template_path ~ '/modules/shop/components/single-product' %}
{% set bodyClass = 'bg-white' %} {% set bodyClass = 'bg-white' %}
{% set mainClass = 'wrapper' %} {% set mainClass = 'wrapper' %}
{% extends 'layout.twig' %} {% extends 'layout.twig' %}
{% block content %} {% block content %}
<div class="wrapper"> <div class="wrapper">
<div class="breadcrumbs"> <div class="breadcrumbs">
{% if wc_breadcrumbs %} {% if wc_breadcrumbs %}
{% for crumb in wc_breadcrumbs %} {% for crumb in wc_breadcrumbs %}
<a href="{{ crumb.url }}" class="breadcrumbs__item"> <a href="{{ crumb.url }}" class="breadcrumbs__item">
{{ crumb.text }} {{ crumb.text }}
</a> </a>
{% endfor %} {% endfor %}
{% endif %} {% endif %}
</div> </div>
<a href="{{ fn('get_permalink', fn('wc_get_page_id', 'shop')) }}" class="back back-detail"> <a href="{{ fn('get_permalink', fn('wc_get_page_id', 'shop')) }}" class="back back-detail">
{{ function('pll_e', 'к каталогу') }} {{ function('pll_e', 'к каталогу') }}
</a> </a>
<div class="detail"> <div class="detail">
<div class="detail__images"> <div class="detail__images">
{% for image in gallery_images %} {% for image in gallery_images %}
<div class="detail__image detail__image--width-perc-{% if loop.index == 1 or loop.index == 4 %}100{% else %}50{% endif %}" data-count-img="{{ loop.index0 }}"> <div class="detail__image detail__image--width-perc-{% if loop.index == 1 or loop.index == 4 %}100{% else %}50{% endif %}" data-count-img="{{ loop.index0 }}">
<img src="{{ image.src }}" alt="{{ image.alt }}" class=""> <img src="{{ image.src }}" alt="{{ image.alt }}" class="">
</div> </div>
{% endfor %} {% endfor %}
<div class="swiper-pagination"></div> <div class="swiper-pagination"></div>
</div> </div>
<div class="detail__content"> <div class="detail__content">
{# Start | Теги = категории #} {# Start | Теги = категории #}
<div class="detail__label"> <div class="detail__label">
<div class="detail__label-wrap"> <div class="detail__label-wrap">
{% for tag in product_tags %} {% for tag in product_tags %}
<div class="product-item-label__tag product-item-label__tag--black"> <div class="product-item-label__tag product-item-label__tag--black">
{{ tag }} {{ tag }}
</div> </div>
{% endfor %} {% endfor %}
{% if product_attributes.Flavor is defined and product_attributes.Flavor|length > 0 %} {% if product_attributes.Flavor is defined and product_attributes.Flavor|length > 0 %}
<div class="product-item-label__tag product-item-label__tag--black"> <div class="product-item-label__tag product-item-label__tag--black">
{{ product_attributes.Flavor[0].name }} {{ product_attributes.Flavor[0].name }}
</div> </div>
{% endif %} {% endif %}
{% if product_attributes.Вкус is defined and product_attributes.Вкус|length > 0 %} {% if product_attributes.Вкус is defined and product_attributes.Вкус|length > 0 %}
<div class="product-item-label__tag product-item-label__tag--black"> <div class="product-item-label__tag product-item-label__tag--black">
<a href="{{ product_attributes.Вкус[0].link }}">{{ product_attributes.Вкус[0].name }}</a> <a href="{{ product_attributes.Вкус[0].link }}">{{ product_attributes.Вкус[0].name }}</a>
</div> </div>
{% endif %} {% endif %}
{% if product_attributes.Тег is defined and product_attributes.Тег|length > 0 %} {% if product_attributes.Тег is defined and product_attributes.Тег|length > 0 %}
<div class="product-item-label__tag product-item-label__tag--title"> <div class="product-item-label__tag product-item-label__tag--title">
<a href="{{ product_attributes.Тег[0].link }}">{{ product_attributes.Тег[0].name }}</a> <a href="{{ product_attributes.Тег[0].link }}">{{ product_attributes.Тег[0].name }}</a>
</div> </div>
{% endif %} {% endif %}
</div> </div>
{% if product.is_on_sale %} {% if product.is_on_sale %}
<div class="product-item-label__tag product-item-label__tag--sale"> <div class="product-item-label__tag product-item-label__tag--sale">
{{ function('pll_e', 'Распродажа %') }} {{ function('pll_e', 'Распродажа %') }}
</div> </div>
{% endif %} {% endif %}
</div> </div>
{# End | Теги = категории #} {# End | Теги = категории #}
<h1 class="detail__title"> <h1 class="detail__title">
{{ product.get_title }} {{ product.get_title }}
</h1> </h1>
<div class="detail__images-phone"> <div class="detail__images-phone">
<div class="swiper-wrapper"> <div class="swiper-wrapper">
{% for image in gallery_images %} {% for image in gallery_images %}
<div class="swiper-slide"> <div class="swiper-slide">
<div class="detail-images-phone__image-block" data-count-img="{{ loop.index0 }}"> <div class="detail-images-phone__image-block" data-count-img="{{ loop.index0 }}">
<img src="{{ image.src }}" alt="{{ image.alt }}"> <img src="{{ image.src }}" alt="{{ image.alt }}">
</div> </div>
</div> </div>
{% endfor %} {% endfor %}
</div> </div>
<div class="swiper-pagination"></div> <div class="swiper-pagination"></div>
</div> </div>
{# Start | Цена для неподписочного товара #} {# Start | Цена для неподписочного товара #}
{% if product.get_price %} {% if product.get_price %}
<div class="detail__block-price"> <div class="detail__block-price">
{% if is_subscription %} {% if is_subscription %}
{% if product.get_regular_price %} {% if product.get_regular_price %}
<div class="detail-block-price__sale"> <div class="detail-block-price__sale">
<p class="detail-block-price-sale__text"> <p class="detail-block-price-sale__text">
{{ product.get_regular_price }} {{ fn('get_woocommerce_currency_symbol') }} {{ product.get_regular_price }} {{ fn('get_woocommerce_currency_symbol') }}
</p> </p>
<p class="detail-block-price-sale__perc"> <p class="detail-block-price-sale__perc">
{{ ((product.get_regular_price - product.get_price) / product.get_regular_price * 100)|round }} {{ ((product.get_regular_price - product.get_price) / product.get_regular_price * 100)|round }}
</p> </p>
</div> </div>
{% else %} {% else %}
не задана цена по подписке не задана цена по подписке
{% endif %} {% endif %}
{% else %} {% else %}
<p class="detail-block-price__price"> <p class="detail-block-price__price">
{{ product.get_price }} {{ fn('get_woocommerce_currency_symbol') }} {{ product.get_price }} {{ fn('get_woocommerce_currency_symbol') }}
{% if product.is_on_sale %} {% if product.is_on_sale %}
<div class="detail-block-price__sale"> <div class="detail-block-price__sale">
<p class="detail-block-price-sale__text"> <p class="detail-block-price-sale__text">
{{ product.get_regular_price }} {{ fn('get_woocommerce_currency_symbol') }} {{ product.get_regular_price }} {{ fn('get_woocommerce_currency_symbol') }}
</p> </p>
<p class="detail-block-price-sale__perc"> <p class="detail-block-price-sale__perc">
{% set discount = ((product.get_regular_price - product.get_sale_price) / product.get_regular_price * 100)|round(0, 'floor') %} {% set discount = ((product.get_regular_price - product.get_sale_price) / product.get_regular_price * 100)|round(0, 'floor') %}
{{ discount }} {{ discount }}
</p> </p>
</div> </div>
{% endif %} {% endif %}
</p> </p>
{% endif %} {% endif %}
</div> </div>
{% endif %} {% endif %}
{# End | Цена для неподписочного товара #} {# End | Цена для неподписочного товара #}
{# Start | Кнопка добавить в корзину + варинанты подписки на товар #} {# Start | Кнопка добавить в корзину + варинанты подписки на товар #}
<form action="" class="detail-block__form" data-product-id="{{ product.id }}"> <form action="" class="detail-block__form" data-product-id="{{ product.id }}">
{% set collection = fn('wc_get_product_terms', product.id, 'pa_collection') %} {% set collection = fn('wc_get_product_terms', product.id, 'pa_collection') %}
{% if collection %} {% if collection %}
{% set siblings = function('get_collection_siblings', collection[0].term_id) %} {% set siblings = function('get_collection_siblings', collection[0].term_id) %}
{% if siblings %} {% if siblings %}
<div class="detail-block-form__item detail-block-form__item--radio radio-button"> <div class="detail-block-form__item detail-block-form__item--radio radio-button">
{% for sibling in siblings %} {% for sibling in siblings %}
{% set weight = function('get_product_info', sibling.ID, 'weight') %} {% set weight = function('get_product_info', sibling.ID, 'weight') %}
{% set current_weight = function('get_product_info', product.id, 'weight') %} {% set current_weight = function('get_product_info', product.id, 'weight') %}
{% set class = weight == current_weight ? 'active' : '' %} {% set class = weight == current_weight ? 'active' : '' %}
<a <a
href="{{ function('get_permalink', sibling.ID) }}" href="{{ function('get_permalink', sibling.ID) }}"
class="button button--white button--red-48-px {{ class }}" class="button button--white button--red-48-px {{ class }}"
data-product_id="{{ sibling.ID }}" data-product_id="{{ sibling.ID }}"
data-product_price="{{ function('get_product_info', sibling.ID, 'price') }}" data-product_price="{{ function('get_product_info', sibling.ID, 'price') }}"
> >
{{ weight|upper }} {{ weight|upper }}
</a> </a>
{% endfor %} {% endfor %}
<input type="text" class="radio-button__input" value="{{ current_weight|upper }}" readonly> <input type="text" class="radio-button__input" value="{{ current_weight|upper }}" readonly>
</div> </div>
{% endif %} {% endif %}
{% endif %} {% endif %}
</form> </form>
{% if product.in_stock %} {% if product.in_stock %}
{{ function('do_action', 'woocommerce_' ~ product.get_type() ~ '_add_to_cart') }} {{ function('do_action', 'woocommerce_' ~ product.get_type() ~ '_add_to_cart') }}
{# Start | Вывод кнопки узнать о поступлении если товара нет в наличии #} {# Start | Вывод кнопки узнать о поступлении если товара нет в наличии #}
{% else %} {% else %}
<div class="detail-block-form__item detail-block-form__item--tn"> <div class="detail-block-form__item detail-block-form__item--tn">
<button type="button" data-pname="{{ product.title }}" class="to-know open-to-know" > <button type="button" data-pname="{{ product.title }}" class="to-know open-to-know" >
<p>{{ function('pll_e', 'Узнать о поступлении') }}</p> <p>{{ function('pll_e', 'Узнать о поступлении') }}</p>
</button> </button>
</div> </div>
{% endif %} {% endif %}
{# End | Вывод кнопки узнать о поступлении если товара нет в наличии #} {# End | Вывод кнопки узнать о поступлении если товара нет в наличии #}
{# End | Кнопка добавить в корзину + варинанты подписки на товар #} {# End | Кнопка добавить в корзину + варинанты подписки на товар #}
{# Start | Табы с информацией #} {# Start | Табы с информацией #}
<div class="detail__toggle"> <div class="detail__toggle">
{# Start | Описание товара #} {# Start | Описание товара #}
<div class="toggle"> <div class="toggle">
<p class="toggle__title"> <p class="toggle__title">
{{ function('pll_e', 'ОПИСАНИЕ') }} {{ function('pll_e', 'ОПИСАНИЕ') }}
</p> </p>
<div class="toggle__block-content"> <div class="toggle__block-content">
<div class="toggle__content"> <div class="toggle__content">
<p class="toggle__text"> <p class="toggle__text">
{{ product.get_description() }} {{ product.get_description() }}
</p> </p>
</div> </div>
</div> </div>
</div> </div>
{# End | Описание товара #} {# End | Описание товара #}
{# Start | Состав товара #} {# Start | Состав товара #}
{% if product_meta.composition %} {% if product_meta.composition %}
<div class="toggle"> <div class="toggle">
<p class="toggle__title"> <p class="toggle__title">
{{ function('pll_e', 'СОСТАВ') }} {{ function('pll_e', 'СОСТАВ') }}
</p> </p>
<div class="toggle__block-content"> <div class="toggle__block-content">
<div class="toggle__content"> <div class="toggle__content">
<p class="toggle__text"> <p class="toggle__text">
{{ product_meta.composition }} {{ product_meta.composition }}
</p> </p>
</div> </div>
</div> </div>
</div> </div>
{% endif %} {% endif %}
{# End | Состав товара #} {# End | Состав товара #}
{# Start | Рекомендации по кормлению #} {# Start | Рекомендации по кормлению #}
{% if product_meta.feeding_recommendations_table %} {% if product_meta.feeding_recommendations_table %}
<div class="toggle"> <div class="toggle">
<p class="toggle__title"> <p class="toggle__title">
{{ function('pll_e', 'РЕКОМЕНДАЦИИ ПО КОРМЛЕНИЮ') }} {{ function('pll_e', 'РЕКОМЕНДАЦИИ ПО КОРМЛЕНИЮ') }}
</p> </p>
<div class="toggle__block-content"> <div class="toggle__block-content">
<div class="toggle__content"> <div class="toggle__content">
<style> <style>
.toggle__table { .toggle__table {
width: 100%; width: 100%;
border-collapse: collapse; border-collapse: collapse;
table-layout: fixed; table-layout: fixed;
} }
.toggle__table th, .toggle__table th,
.toggle__table td { .toggle__table td {
width: 33.33%; width: 33.33%;
vertical-align: top; vertical-align: top;
padding: 8px; padding: 8px;
text-align: left; text-align: left;
} }
.toggle-table__title { .toggle-table__title {
font-weight: bold; font-weight: bold;
font-size: 16px; font-size: 16px;
} }
.toggle-table__item { .toggle-table__item {
position: relative; position: relative;
padding-bottom: 10px; padding-bottom: 10px;
} }
.toggle-table__item p { .toggle-table__item p {
display: inline-block; display: inline-block;
margin: 0; margin: 0;
background: #fff; /* подложка, если нужно перекрыть линию */ background: #fff; /* подложка, если нужно перекрыть линию */
padding-right: 4px; padding-right: 4px;
z-index: 1; z-index: 1;
position: relative; position: relative;
} }
/* Линия-многоточие */ /* Линия-многоточие */
.toggle-table-item__line { .toggle-table-item__line {
position: absolute; position: absolute;
left: 0; left: 0;
bottom: 4px; bottom: 4px;
width: 100%; width: 100%;
border-bottom: 1px dotted #aaa; border-bottom: 1px dotted #aaa;
z-index: 0; z-index: 0;
} }
/* Адаптив */ /* Адаптив */
@media (max-width: 768px) { @media (max-width: 768px) {
.toggle__table th, .toggle__table th,
.toggle__table td { .toggle__table td {
font-size: 14px; font-size: 14px;
padding: 6px; padding: 6px;
} }
} }
/* Maks */ /* Maks */
.toggle__table tbody, .toggle__table tbody,
.toggle__table thead, .toggle__table thead,
.toggle__table thead tr{ .toggle__table thead tr{
width: 100%; width: 100%;
} }
.toggle__table thead tr{ .toggle__table thead tr{
display:flex; display:flex;
} }
.toggle__table tbody tr{ .toggle__table tbody tr{
display: flex; display: flex;
gap: 8px; gap: 8px;
} }
</style> </style>
<table class="toggle__table toggle__table--three"> <table class="toggle__table toggle__table--three">
{% if product_meta.feeding_recommendations_table.header is defined %} {% if product_meta.feeding_recommendations_table.header is defined %}
<thead> <thead>
<tr> <tr>
{% for col in product_meta.feeding_recommendations_table.header %} {% for col in product_meta.feeding_recommendations_table.header %}
<th class="toggle-table__title">{{ col.c }}</th> <th class="toggle-table__title">{{ col.c }}</th>
{% endfor %} {% endfor %}
</tr> </tr>
</thead> </thead>
{% endif %} {% endif %}
<tbody> <tbody>
{% for row in product_meta.feeding_recommendations_table.body %} {% for row in product_meta.feeding_recommendations_table.body %}
<tr> <tr>
{% for cell in row %} {% for cell in row %}
<td class="toggle-table__item"> <td class="toggle-table__item">
<p>{{ cell.c }}</p> <p>{{ cell.c }}</p>
<div class="toggle-table-item__line"></div> <div class="toggle-table-item__line"></div>
</td> </td>
{% endfor %} {% endfor %}
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
{# Старая таблица #} {# Старая таблица #}
{# <div class="toggle__table toggle__table--three"> {# <div class="toggle__table toggle__table--three">
{% if product_meta.feeding_recommendations_table.header %} {% if product_meta.feeding_recommendations_table.header %}
<div class="toggle-table__block"> <div class="toggle-table__block">
<p class="toggle-table__title">{{ product_meta.feeding_recommendations_table.header.0 is iterable ? product_meta.feeding_recommendations_table.header.0|join(', ') : product_meta.feeding_recommendations_table.header.0 }}</p> <p class="toggle-table__title">{{ product_meta.feeding_recommendations_table.header.0 is iterable ? product_meta.feeding_recommendations_table.header.0|join(', ') : product_meta.feeding_recommendations_table.header.0 }}</p>
{% for row in product_meta.feeding_recommendations_table.body %} {% for row in product_meta.feeding_recommendations_table.body %}
<div class="toggle-table__item"> <div class="toggle-table__item">
<p>{{ row.0 is iterable ? row.0|join(', ') : row.0 }}</p> <p>{{ row.0 is iterable ? row.0|join(', ') : row.0 }}</p>
<div class="toggle-table-item__line"></div> <div class="toggle-table-item__line"></div>
</div> </div>
{% endfor %} {% endfor %}
</div> </div>
<div class="toggle-table__block"> <div class="toggle-table__block">
<p class="toggle-table__title">{{ product_meta.feeding_recommendations_table.header.1 is iterable ? product_meta.feeding_recommendations_table.header.1|join(', ') : product_meta.feeding_recommendations_table.header.1 }}</p> <p class="toggle-table__title">{{ product_meta.feeding_recommendations_table.header.1 is iterable ? product_meta.feeding_recommendations_table.header.1|join(', ') : product_meta.feeding_recommendations_table.header.1 }}</p>
{% for row in product_meta.feeding_recommendations_table.body %} {% for row in product_meta.feeding_recommendations_table.body %}
<div class="toggle-table__item"> <div class="toggle-table__item">
<p>{{ row.1 is iterable ? row.1|join(', ') : row.1 }}</p> <p>{{ row.1 is iterable ? row.1|join(', ') : row.1 }}</p>
<div class="toggle-table-item__line"></div> <div class="toggle-table-item__line"></div>
</div> </div>
{% endfor %} {% endfor %}
</div> </div>
<div class="toggle-table__block"> <div class="toggle-table__block">
<p class="toggle-table__title">{{ product_meta.feeding_recommendations_table.header.2 is iterable ? product_meta.feeding_recommendations_table.header.2|join(', ') : product_meta.feeding_recommendations_table.header.2 }}</p> <p class="toggle-table__title">{{ product_meta.feeding_recommendations_table.header.2 is iterable ? product_meta.feeding_recommendations_table.header.2|join(', ') : product_meta.feeding_recommendations_table.header.2 }}</p>
{% for row in product_meta.feeding_recommendations_table.body %} {% for row in product_meta.feeding_recommendations_table.body %}
<div class="toggle-table__item"> <div class="toggle-table__item">
<p>{{ row.2 is iterable ? row.2|join(', ') : row.2 }}</p> <p>{{ row.2 is iterable ? row.2|join(', ') : row.2 }}</p>
</div> </div>
{% endfor %} {% endfor %}
</div> </div>
{% endif %} {% endif %}
</div> #} </div> #}
</div> </div>
</div> </div>
</div> </div>
{% elseif product_meta.feeding_recommendations %} {% elseif product_meta.feeding_recommendations %}
<div class="toggle"> <div class="toggle">
<p class="toggle__title"> <p class="toggle__title">
{{ function('pll_e', 'РЕКОМЕНДАЦИИ ПО КОРМЛЕНИЮ') }} {{ function('pll_e', 'РЕКОМЕНДАЦИИ ПО КОРМЛЕНИЮ') }}
</p> </p>
<div class="toggle__block-content"> <div class="toggle__block-content">
<div class="toggle__content"> <div class="toggle__content">
{{ product_meta.feeding_recommendations }} {{ product_meta.feeding_recommendations }}
</div> </div>
</div> </div>
</div> </div>
{% endif %} {% endif %}
{# End | Рекомендации по кормлению #} {# End | Рекомендации по кормлению #}
{% if product_meta.nutritional_value or product_meta.vitamins or product_meta.additives or product_meta.energy_value %} {% if product_meta.nutritional_value or product_meta.vitamins or product_meta.additives or product_meta.energy_value %}
<div class="toggle"> <div class="toggle">
<p class="toggle__title"> <p class="toggle__title">
{{ function('pll_e', 'ПИЩЕВАЯ ЦЕННОСТЬ') }} {{ function('pll_e', 'ПИЩЕВАЯ ЦЕННОСТЬ') }}
</p> </p>
<div class="toggle__block-content"> <div class="toggle__block-content">
<div class="toggle__content"> <div class="toggle__content">
{% if product_meta.nutritional_value and product_meta.vitamins %} {% if product_meta.nutritional_value and product_meta.vitamins %}
<div class="toggle__table toggle__table--two"> <div class="toggle__table toggle__table--two">
<div class="toggle-table__block "> <div class="toggle-table__block ">
<p class="toggle-table__title toggle-table__title--center">{{ function('pll_e', 'ПИЩЕВАЯ ЦЕННОСТЬ') }}</p> <p class="toggle-table__title toggle-table__title--center">{{ function('pll_e', 'ПИЩЕВАЯ ЦЕННОСТЬ') }}</p>
{{ product_meta.nutritional_value }} {{ product_meta.nutritional_value }}
</div> </div>
<div class="toggle-table__block "> <div class="toggle-table__block ">
<p class="toggle-table__title toggle-table__title--center">{{ function('pll_e', 'ВИТАМИНЫ НА КГ') }}</p> <p class="toggle-table__title toggle-table__title--center">{{ function('pll_e', 'ВИТАМИНЫ НА КГ') }}</p>
{{ product_meta.vitamins }} {{ product_meta.vitamins }}
</div> </div>
</div> </div>
{% endif %} {% endif %}
{% if product_meta.additives or product_meta.energy_value %} {% if product_meta.additives or product_meta.energy_value %}
<div class="toggle__table toggle__table--two"> <div class="toggle__table toggle__table--two">
{% if product_meta.additives %} {% if product_meta.additives %}
<div class="toggle-table__block "> <div class="toggle-table__block ">
<p class="toggle-table__title toggle-table__title--center">{{ function('pll_e', 'ПИТАТЕЛЬНЫЕ ДОБАВКИ НА КГ') }}</p> <p class="toggle-table__title toggle-table__title--center">{{ function('pll_e', 'ПИТАТЕЛЬНЫЕ ДОБАВКИ НА КГ') }}</p>
{{ product_meta.additives }} {{ product_meta.additives }}
</div> </div>
{% endif %} {% endif %}
{% if product_meta.energy_value %} {% if product_meta.energy_value %}
<div class="toggle-table__block "> <div class="toggle-table__block ">
<p class="toggle-table__title toggle-table__title--center">{{ function('pll_e', 'ЭНЕРГЕТИЧЕСКАЯ ЦЕННОСТЬ НА 100 ГРАММ') }}</p> <p class="toggle-table__title toggle-table__title--center">{{ function('pll_e', 'ЭНЕРГЕТИЧЕСКАЯ ЦЕННОСТЬ НА 100 ГРАММ') }}</p>
<div class="toggle-table__item"> <div class="toggle-table__item">
<div class="detail__warning warning"> <div class="detail__warning warning">
<div class="detail-warning__content"> <div class="detail-warning__content">
<p class="detail-warning__title">{{ product_meta.energy_value }}</p> <p class="detail-warning__title">{{ product_meta.energy_value }}</p>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
{% endif %} {% endif %}
</div> </div>
{% endif %} {% endif %}
</div> </div>
</div> </div>
</div> </div>
{% endif %} {% endif %}
</div> </div>
{# End | Табы с информацией #} {# End | Табы с информацией #}
{% if product_meta.important %} {% if product_meta.important %}
<div class="detail__warning"> <div class="detail__warning">
<div class="detail-warning__content"> <div class="detail-warning__content">
<p class="detail-warning__title">{{ function('pll_e', 'Важно') }}</p> <p class="detail-warning__title">{{ function('pll_e', 'Важно') }}</p>
<p class="detail-warning__text"> <p class="detail-warning__text">
{{ product_meta.important }} {{ product_meta.important }}
</p> </p>
</div> </div>
</div> </div>
{% endif %} {% endif %}
</div> </div>
<div class="product__main"> <div class="product__main">
{% set recommended_products = function('get_field', 'recommended_products', product.id) %} {% set recommended_products = function('get_field', 'recommended_products', product.id) %}
{% set related_products = recommended_products ? recommended_products : function('wc_get_related_products', product.id, 4) %} {% set related_products = recommended_products ? recommended_products : function('wc_get_related_products', product.id, 4) %}
{% if related_products %} {% if related_products %}
<div class="detail__wrapper-catalot"> <div class="detail__wrapper-catalot">
<div class="detail__catalot"> <div class="detail__catalot">
<div class="detail-catalot__header"> <div class="detail-catalot__header">
<p class="detail-catalot__title"> <p class="detail-catalot__title">
{{ function('pll_e', 'вашему питомцу может понравиться') }} {{ function('pll_e', 'вашему питомцу может понравиться') }}
</p> </p>
<div class="detail-catalot__control"> <div class="detail-catalot__control">
<button class="detail-catalot-control__button prev"> <button class="detail-catalot-control__button prev">
<img src="{{ theme.uri }}/static/shop/img/svg/main/arrow-left.svg" alt=""> <img src="{{ theme.uri }}/static/shop/img/svg/main/arrow-left.svg" alt="">
</button> </button>
<button class="detail-catalot-control__button next"> <button class="detail-catalot-control__button next">
<img src="{{ theme.uri }}/static/shop/img/svg/main/arrow-right.svg" alt=""> <img src="{{ theme.uri }}/static/shop/img/svg/main/arrow-right.svg" alt="">
</button> </button>
</div> </div>
</div> </div>
<div class="detail-catalot__content swiper-wrapper"> <div class="detail-catalot__content swiper-wrapper">
{% for related_product in related_products %} {% for related_product in related_products %}
<div class="swiper-slide"> <div class="swiper-slide">
{% set post_id = related_product.ID is defined ? related_product.ID : related_product %} {% set post_id = related_product.ID is defined ? related_product.ID : related_product %}
{% set wc_product = fn('wc_get_product', post_id) %} {% set wc_product = fn('wc_get_product', post_id) %}
{% if wc_product %} {% if wc_product %}
{% include '_blocks/shop/archive-product-tease.twig' with {post: wc_product} %} {% include '_blocks/shop/archive-product-tease.twig' with {post: wc_product} %}
{% endif %} {% endif %}
</div> </div>
{% endfor %} {% endfor %}
</div> </div>
</div> </div>
</div> </div>
{% endif %} {% endif %}
</div> </div>
</div> </div>
<div class="gallery"> <div class="gallery">
<button class="gallery__close gallery-button"> <button class="gallery__close gallery-button">
<img src="{{ theme.uri }}/static/shop/img/svg/main/black-x.svg" alt=""> <img src="{{ theme.uri }}/static/shop/img/svg/main/black-x.svg" alt="">
</button> </button>
<div class="gallery__wrapper"> <div class="gallery__wrapper">
<div class="gallery__pagination"> <div class="gallery__pagination">
{% for image in gallery_images %} {% for image in gallery_images %}
<button class="gallery-pagination__item" data-count-img="{{ loop.index0 }}"> <button class="gallery-pagination__item" data-count-img="{{ loop.index0 }}">
<img src="{{ image.src }}" alt="{{ image.alt }}"> <img src="{{ image.src }}" alt="{{ image.alt }}">
</button> </button>
{% endfor %} {% endfor %}
</div> </div>
<div class="gallery__slider swiper"> <div class="gallery__slider swiper">
<div class="swiper-wrapper"> <div class="swiper-wrapper">
{% for image in gallery_images %} {% for image in gallery_images %}
<div class="swiper-slide"> <div class="swiper-slide">
<div class="gallery__block"> <div class="gallery__block">
<img src="{{ image.src }}" alt="{{ image.alt }}"> <img src="{{ image.src }}" alt="{{ image.alt }}">
</div> </div>
</div> </div>
{% endfor %} {% endfor %}
</div> </div>
<div class="swiper-pagination"></div> <div class="swiper-pagination"></div>
<div class="swiper-button-prev gallery-button"> <div class="swiper-button-prev gallery-button">
<img src="{{ theme.uri }}/static/shop/img/svg/main/arrow-left.svg" alt=""> <img src="{{ theme.uri }}/static/shop/img/svg/main/arrow-left.svg" alt="">
</div> </div>
<div class="swiper-button-next gallery-button"> <div class="swiper-button-next gallery-button">
<img src="{{ theme.uri }}/static/shop/img/svg/main/arrow-right.svg" alt=""> <img src="{{ theme.uri }}/static/shop/img/svg/main/arrow-right.svg" alt="">
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
{% endblock %} {% endblock %}

@ -1,63 +0,0 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if (is_product()) {
include_module('shop');
include_component('shop', 'single-product');
$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 = wc_get_related_products($product_id, 5);
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;
}
}
}
Timber::render('modules/shop/components/single-product/component-template.twig', $context);
}

@ -1,19 +0,0 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
get_header();
$template_path = 'templates/shop/single-product.php';
if (file_exists(get_template_directory() . '/' . $template_path)) {
include_once get_template_directory() . '/' . $template_path;
} else {
while (have_posts()) : the_post();
wc_get_template_part('content', 'single-product');
endwhile;
}
get_footer();
Loading…
Cancel
Save