From a8c50aa368077685a524ea8256ab6c53663ed51f Mon Sep 17 00:00:00 2001 From: maksim Date: Sat, 14 Jun 2025 11:32:27 +0300 Subject: [PATCH] =?UTF-8?q?Andrei=20|=20=D1=80=D0=B5=D1=84=D0=B0=D0=BA?= =?UTF-8?q?=D1=82=D0=BE=D1=80=D0=B8=D0=BD=D0=B3=20=D0=BF=D1=80=D0=BE=D0=B5?= =?UTF-8?q?=D0=BA=D1=82=D0=B0=20(=D1=80=D0=B0=D0=B7=D0=BD=D0=B5=D1=81=20ph?= =?UTF-8?q?p=20=D0=B8=20twig=20=D1=81=D1=82=D0=B0=D1=82=D0=B8=D1=87=D0=B5?= =?UTF-8?q?=D1=81=D0=BA=D0=B8=D1=85=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D1=86=20=D0=BF=D0=BE=20=D0=BE=D1=82=D0=B4=D0=B5=D0=BB=D1=8C?= =?UTF-8?q?=D0=BD=D1=8B=D0=BC=20=D0=B4=D0=B8=D1=80=D0=B5=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=B8=D1=8F=D0=BC)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../static-pages}/about/template-about.php | 2 +- .../front-page/template-front-page.php | 4 +- .../production/template-prod-page.php | 2 +- .../where_to_buy/template_wtb.php | 2 +- .../cosmopet/temp-functions/modules-logic.php | 4 +- .../templates/{about => _pages}/about.twig | 0 .../{front-page => _pages}/front-page.twig | 0 .../{production => _pages}/production.twig | 0 .../{where_to_buy => _pages}/wtb.twig | 0 .../archive-product-ajaxload.twig | 9 + .../archive-product-tease.twig | 121 ++++++++++++++ .../archive-product/archive-product.twig | 157 ++++++++++++++++++ 12 files changed, 294 insertions(+), 7 deletions(-) rename wp-content/themes/cosmopet/{templates => modules/static-pages}/about/template-about.php (92%) rename wp-content/themes/cosmopet/{templates => modules/static-pages}/front-page/template-front-page.php (95%) rename wp-content/themes/cosmopet/{templates => modules/static-pages}/production/template-prod-page.php (88%) rename wp-content/themes/cosmopet/{templates => modules/static-pages}/where_to_buy/template_wtb.php (96%) rename wp-content/themes/cosmopet/templates/{about => _pages}/about.twig (100%) rename wp-content/themes/cosmopet/templates/{front-page => _pages}/front-page.twig (100%) rename wp-content/themes/cosmopet/templates/{production => _pages}/production.twig (100%) rename wp-content/themes/cosmopet/templates/{where_to_buy => _pages}/wtb.twig (100%) create mode 100644 wp-content/themes/cosmopet/templates/archive-product/archive-product-ajaxload.twig create mode 100644 wp-content/themes/cosmopet/templates/archive-product/archive-product-tease.twig create mode 100644 wp-content/themes/cosmopet/templates/archive-product/archive-product.twig diff --git a/wp-content/themes/cosmopet/templates/about/template-about.php b/wp-content/themes/cosmopet/modules/static-pages/about/template-about.php similarity index 92% rename from wp-content/themes/cosmopet/templates/about/template-about.php rename to wp-content/themes/cosmopet/modules/static-pages/about/template-about.php index cfd3778..15e5d29 100644 --- a/wp-content/themes/cosmopet/templates/about/template-about.php +++ b/wp-content/themes/cosmopet/modules/static-pages/about/template-about.php @@ -34,6 +34,6 @@ $context['e_title'] = get_field('e-title'); $context['e_points'] = get_field('e-points'); $context['faq'] = get_field('faq'); -Timber::render('templates/about/about.twig', $context); +Timber::render('_pages/about.twig', $context); ?> diff --git a/wp-content/themes/cosmopet/templates/front-page/template-front-page.php b/wp-content/themes/cosmopet/modules/static-pages/front-page/template-front-page.php similarity index 95% rename from wp-content/themes/cosmopet/templates/front-page/template-front-page.php rename to wp-content/themes/cosmopet/modules/static-pages/front-page/template-front-page.php index 2d76143..faba9e7 100644 --- a/wp-content/themes/cosmopet/templates/front-page/template-front-page.php +++ b/wp-content/themes/cosmopet/modules/static-pages/front-page/template-front-page.php @@ -7,7 +7,7 @@ diff --git a/wp-content/themes/cosmopet/templates/production/template-prod-page.php b/wp-content/themes/cosmopet/modules/static-pages/production/template-prod-page.php similarity index 88% rename from wp-content/themes/cosmopet/templates/production/template-prod-page.php rename to wp-content/themes/cosmopet/modules/static-pages/production/template-prod-page.php index f5980cb..67a4370 100644 --- a/wp-content/themes/cosmopet/templates/production/template-prod-page.php +++ b/wp-content/themes/cosmopet/modules/static-pages/production/template-prod-page.php @@ -23,6 +23,6 @@ $context['desc'] = get_field('desc'); $context['steps_1'] = get_field('steps_1'); $context['steps_2'] = get_field('steps_2'); -Timber::render('templates/production/production.twig', $context); +Timber::render('_pages/production.twig', $context); ?> diff --git a/wp-content/themes/cosmopet/templates/where_to_buy/template_wtb.php b/wp-content/themes/cosmopet/modules/static-pages/where_to_buy/template_wtb.php similarity index 96% rename from wp-content/themes/cosmopet/templates/where_to_buy/template_wtb.php rename to wp-content/themes/cosmopet/modules/static-pages/where_to_buy/template_wtb.php index 2fe3ee0..7bed31f 100644 --- a/wp-content/themes/cosmopet/templates/where_to_buy/template_wtb.php +++ b/wp-content/themes/cosmopet/modules/static-pages/where_to_buy/template_wtb.php @@ -132,5 +132,5 @@ $context['partners_logos'] = $partners_logos_formatted; add_filter('wpcf7_autop_or_not', '__return_false'); // Рендеринг шаблона -Timber::render('templates/where_to_buy/wtb.twig', $context); +Timber::render('_pages/wtb.twig', $context); ?> \ No newline at end of file diff --git a/wp-content/themes/cosmopet/temp-functions/modules-logic.php b/wp-content/themes/cosmopet/temp-functions/modules-logic.php index a22d09a..57e3cbe 100644 --- a/wp-content/themes/cosmopet/temp-functions/modules-logic.php +++ b/wp-content/themes/cosmopet/temp-functions/modules-logic.php @@ -217,7 +217,7 @@ function include_module($module_name) { */ add_filter('theme_page_templates', function ($templates) { // Путь к папке с шаблонами - $custom_templates_dir = get_template_directory() . '/templates/'; + $custom_templates_dir = get_template_directory() . '/modules/static-pages/'; // Ищем ВСЕ PHP-файлы в /templates/ и подпапках $all_templates = new RecursiveIteratorIterator( @@ -237,7 +237,7 @@ add_filter('theme_page_templates', function ($templates) { $template_name = str_replace(['/', '.php'], [' - ', ''], $relative_path); // Добавляем в список шаблонов - $templates['templates/' . $relative_path] = $template_name; + $templates['/modules/static-pages/' . $relative_path] = $template_name; } return $templates; diff --git a/wp-content/themes/cosmopet/templates/about/about.twig b/wp-content/themes/cosmopet/templates/_pages/about.twig similarity index 100% rename from wp-content/themes/cosmopet/templates/about/about.twig rename to wp-content/themes/cosmopet/templates/_pages/about.twig diff --git a/wp-content/themes/cosmopet/templates/front-page/front-page.twig b/wp-content/themes/cosmopet/templates/_pages/front-page.twig similarity index 100% rename from wp-content/themes/cosmopet/templates/front-page/front-page.twig rename to wp-content/themes/cosmopet/templates/_pages/front-page.twig diff --git a/wp-content/themes/cosmopet/templates/production/production.twig b/wp-content/themes/cosmopet/templates/_pages/production.twig similarity index 100% rename from wp-content/themes/cosmopet/templates/production/production.twig rename to wp-content/themes/cosmopet/templates/_pages/production.twig diff --git a/wp-content/themes/cosmopet/templates/where_to_buy/wtb.twig b/wp-content/themes/cosmopet/templates/_pages/wtb.twig similarity index 100% rename from wp-content/themes/cosmopet/templates/where_to_buy/wtb.twig rename to wp-content/themes/cosmopet/templates/_pages/wtb.twig diff --git a/wp-content/themes/cosmopet/templates/archive-product/archive-product-ajaxload.twig b/wp-content/themes/cosmopet/templates/archive-product/archive-product-ajaxload.twig new file mode 100644 index 0000000..7b476ec --- /dev/null +++ b/wp-content/themes/cosmopet/templates/archive-product/archive-product-ajaxload.twig @@ -0,0 +1,9 @@ +{% for post in posts %} + {% include 'archive-product/archive-product-tease.twig' with {post: post} %} +{% endfor %} + +{% if not ended %} + +{% endif %} \ No newline at end of file diff --git a/wp-content/themes/cosmopet/templates/archive-product/archive-product-tease.twig b/wp-content/themes/cosmopet/templates/archive-product/archive-product-tease.twig new file mode 100644 index 0000000..8bb76ab --- /dev/null +++ b/wp-content/themes/cosmopet/templates/archive-product/archive-product-tease.twig @@ -0,0 +1,121 @@ +{% if post.id is defined and post.id %} + {% set cur_product = fn('wc_get_product', post.id) %} + {% set attrs = post.product.get_attributes() %} + {% set cur_weight = function('get_product_info', post.id, 'weight') %} + +
+
+ {% if post.date('Y-m-d') >= criteria_for_new_product %} + + {{ function('pll_e', 'Новинка') }} + + {% endif %} + + {% if post._sale_price %} + + {{ function('pll_e', 'Распродажа %') }} + + {% endif %} +
+ + {{ post.title }} + +
+
+ {% set compound = fn('wc_get_product_terms', post.id, 'pa_compound') %} + {% for option in compound %} + + {% set term = get_term(option) %} + {{ term.name }} + {% endfor %} +
+ {{ post.title }} +
+

{{ post._price() }} {{ fn('get_woocommerce_currency_symbol') }}

+
+
+ +
+
+
+
+ {{ post.title }} + +
    + {% set features = fn('wc_get_product_terms', post.id, 'pa_features') %} + {% for option in features %} + {% set term = get_term(option) %} +
  • {{ term.name }}
  • + {% endfor %} +
+
+ +
+
+ {% set collection = fn('wc_get_product_terms', post.id, 'pa_collection') %} + {% if collection %} +
+

{{ fn('pll_e', 'Объем') }}

+ +
+ +
+
    + + {% for option in collection %} + {% set term = get_term(option) %} + {% set siblings = function('get_collection_siblings' , term.id) %} + + {% for sibling in siblings %} + + {% set weight = function('get_product_info', sibling.ID, 'weight') %} + + {% set class = '' %} + {% if weight == cur_weight %} + {% set class = 'active' %} + {% endif %} +
  • + +
  • + {% endfor %} + {% endfor %} +
+
+
+
+ {% endif %} +
+

{{ fn('pll_e', 'Количество') }}

+ +
+ + + +
+
+
+

+ {{ post._price() }} +

+
+
+ {{ function('get_add_to_cart_button', post.id) }} +
+ +
+
+
+
+{% endif %} \ No newline at end of file diff --git a/wp-content/themes/cosmopet/templates/archive-product/archive-product.twig b/wp-content/themes/cosmopet/templates/archive-product/archive-product.twig new file mode 100644 index 0000000..fc1e64d --- /dev/null +++ b/wp-content/themes/cosmopet/templates/archive-product/archive-product.twig @@ -0,0 +1,157 @@ +{% set bodyClass = 'bg-white' %} +{% set mainClass = 'wrapper' %} +{% extends 'layout.twig' %} + +{% block content %} + + {% if site_region == 'ru' %} + + {% endif %} + + + +
+
+

+ {% if category %} + {{ category.name }} + {% else %} + {{ function('pll_e', 'Продукция') }} + {% endif %} +

+ + +
+ + {% if active_filters|length > 0 %} +
+ {% if active_filters is not empty %} +
+ {% for filter in active_filters %} + + {{ filter.name }} × + + {% endfor %} +
+ {% endif %} + + +
+ {% endif %} + +
+ {% for post in posts %} + {% include 'archive-product/archive-product-tease.twig' with {post: post} %} + {% endfor %} +
+ + +
+ + + + +{% endblock %} \ No newline at end of file