From 175ecfd93caf838aed5d9738a30b68e5579a6197 Mon Sep 17 00:00:00 2001 From: maksim Date: Wed, 11 Jun 2025 17:11:19 +0300 Subject: [PATCH] =?UTF-8?q?Task:6563=20|=20=D0=92=D1=8B=D0=B2=D0=BE=D0=B4?= =?UTF-8?q?=20=D0=B0=D0=BA=D1=82=D0=B8=D0=B2=D0=BD=D1=8B=D1=85=20=D1=84?= =?UTF-8?q?=D0=B8=D0=BB=D1=8C=D1=82=D1=80=D0=BE=D0=B2=20=D1=87=D0=B5=D1=80?= =?UTF-8?q?=D0=B5=D0=B7=20GET=20=D0=BF=D0=B0=D1=80=D0=BC=D0=B5=D1=82=D1=80?= =?UTF-8?q?=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/layout/assets/js/gp-main.js | 2 +- .../cosmopet/static/front-page/css/style.css | 3 +- .../cosmopet/woocommerce/archive-product.php | 45 ++++ .../archive-product-modal.twig | 221 ------------------ .../archive-product/archive-product.twig | 104 ++++++++- .../assets/css/gp-style-desktop.css | 33 +++ 6 files changed, 179 insertions(+), 229 deletions(-) diff --git a/wp-content/themes/cosmopet/modules/layout/assets/js/gp-main.js b/wp-content/themes/cosmopet/modules/layout/assets/js/gp-main.js index eb7c6e0..24792c7 100644 --- a/wp-content/themes/cosmopet/modules/layout/assets/js/gp-main.js +++ b/wp-content/themes/cosmopet/modules/layout/assets/js/gp-main.js @@ -541,4 +541,4 @@ document.addEventListener('DOMContentLoaded', function() { modalAside.style.width = ''; modalAside.style.right = '-30vw'; } -}); \ No newline at end of file +}); diff --git a/wp-content/themes/cosmopet/static/front-page/css/style.css b/wp-content/themes/cosmopet/static/front-page/css/style.css index 12bdf8b..80883d8 100644 --- a/wp-content/themes/cosmopet/static/front-page/css/style.css +++ b/wp-content/themes/cosmopet/static/front-page/css/style.css @@ -4557,4 +4557,5 @@ color: #f4f1f0; .modal__aside.active { right: 0; -} \ No newline at end of file +} + diff --git a/wp-content/themes/cosmopet/woocommerce/archive-product.php b/wp-content/themes/cosmopet/woocommerce/archive-product.php index 895e8c6..7143dd5 100644 --- a/wp-content/themes/cosmopet/woocommerce/archive-product.php +++ b/wp-content/themes/cosmopet/woocommerce/archive-product.php @@ -8,6 +8,49 @@ wp_enqueue_style( 'shop_styles_order', get_template_directory_uri() . '/woocommerce/assets/css/gp-style-order.css'); wp_enqueue_style( 'shop_styles_ultra', get_template_directory_uri() . '/woocommerce/assets/css/gp-style-ultra.css'); + function get_active_woobewoo_filters_for_twig() { + $filters = []; + error_log('=== WooBeWoo: фильтры проверяются ==='); + + foreach ($_GET as $key => $value) { + error_log("Ключ: $key => " . print_r($value, true)); + + if (strpos($key, 'wpf_filter_') === 0) { + $raw_taxonomy = str_replace('wpf_filter_', '', $key); + error_log("→ Обнаружен фильтр: $raw_taxonomy"); + + $slugs = is_array($value) ? $value : explode(',', $value); + error_log("→ Slugs: " . implode(', ', $slugs)); + + // Попробуем с pa_ и без, в зависимости от существования таксономии + $taxonomy = taxonomy_exists('pa_' . $raw_taxonomy) ? 'pa_' . $raw_taxonomy : $raw_taxonomy; + + foreach ($slugs as $slug) { + $term = get_term_by('slug', $slug, $taxonomy); + + if ($term) { + error_log("✔ Найден термин: {$term->name} (ID: {$term->term_id}) в таксономии: $taxonomy"); + $filters[] = [ + 'id' => $term->term_id, + 'name' => $term->name, + 'slug' => $term->slug, + 'taxonomy' => $taxonomy, + ]; + } else { + error_log("✖ Термин не найден: $slug в таксономии: $taxonomy"); + } + } + } + } + + if (empty($filters)) { + error_log('‼️ Ни один активный фильтр не найден.'); + } + + return $filters; +} + + $context = Timber::context(); //$context['posts'] = Timber::get_posts(); $context['criteria_for_new_product'] = date('Y-m-d', strtotime('-30 days')); @@ -68,6 +111,8 @@ $count_args = array_merge($count_args, $categories); } + $context['active_filters'] = get_active_woobewoo_filters_for_twig(); + $context['posts'] = Timber::get_posts($args); $context['count'] = count(Timber::get_posts($count_args)); $context['sidebar_filters'] = Timber::get_widgets('sidebar_filters'); diff --git a/wp-content/themes/cosmopet/woocommerce/archive-product/archive-product-modal.twig b/wp-content/themes/cosmopet/woocommerce/archive-product/archive-product-modal.twig index 2df58e0..e69de29 100644 --- a/wp-content/themes/cosmopet/woocommerce/archive-product/archive-product-modal.twig +++ b/wp-content/themes/cosmopet/woocommerce/archive-product/archive-product-modal.twig @@ -1,221 +0,0 @@ -{# #} \ No newline at end of file diff --git a/wp-content/themes/cosmopet/woocommerce/archive-product/archive-product.twig b/wp-content/themes/cosmopet/woocommerce/archive-product/archive-product.twig index 4408865..6126fa2 100644 --- a/wp-content/themes/cosmopet/woocommerce/archive-product/archive-product.twig +++ b/wp-content/themes/cosmopet/woocommerce/archive-product/archive-product.twig @@ -36,16 +36,28 @@ {% 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 %} @@ -61,5 +73,85 @@ {% endif %}
+ + + {% endblock %} \ No newline at end of file diff --git a/wp-content/themes/cosmopet/woocommerce/assets/css/gp-style-desktop.css b/wp-content/themes/cosmopet/woocommerce/assets/css/gp-style-desktop.css index 28dce49..e67de0d 100644 --- a/wp-content/themes/cosmopet/woocommerce/assets/css/gp-style-desktop.css +++ b/wp-content/themes/cosmopet/woocommerce/assets/css/gp-style-desktop.css @@ -1947,6 +1947,39 @@ main{ } +.active-filters { + display: flex; + flex-wrap: wrap; + gap: 10px; + margin-bottom: 20px; + margin-top: 20px; +} + +.active-filter-tag { + padding: 6px 12px; + border: 1px solid #3EC2A6; + border-radius: 16px; + color: #3EC2A6; + font-weight: 400; + font-size: 20px; + line-height: 120%; + white-space: nowrap; + cursor: default; + transition: all 0.2s; + text-transform: uppercase; + +} + +.active-filter-tag:hover { + background-color: #e8f8f5; + cursor: pointer; +} + +.active-filters__clear.button--white { + padding: 6px 12px; + height: 38px; + margin-top: 20px; +}