From 0a5a29521de4def726bb8938fa89fce5906cc561 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 9 Jun 2025 09:39:30 +0300 Subject: [PATCH 01/10] =?UTF-8?q?Fix=20|=20task=206635=20=D0=9F=D0=BE?= =?UTF-8?q?=D1=84=D0=B8=D0=BA=D1=81=D0=B8=D0=BB=20=D0=BE=D0=B1=D0=BD=D0=BE?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BD=D0=B8=D0=B6=D0=BD?= =?UTF-8?q?=D0=B5=D0=B9=20=D1=87=D0=B0=D1=81=D1=82=D0=B8=20=D0=B1=D0=BB?= =?UTF-8?q?=D0=BE=D0=BA=D0=B0=20=D0=B2=20=D0=BA=D0=BE=D1=80=D0=B7=D0=B8?= =?UTF-8?q?=D0=BD=D0=B5=20=D0=BF=D1=80=D0=B8=20ajax=20=D0=B8=D0=B7=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8=D0=B8=20=D1=81=D0=BE=D1=81=D1=82?= =?UTF-8?q?=D0=BE=D1=8F=D0=BD=D0=B8=D1=8F=20=D0=BA=D0=BE=D1=80=D0=B7=D0=B8?= =?UTF-8?q?=D0=BD=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../layout/assets/css/gp-style-core.css | 6 +++++ .../shop/components/cart/assets/js/cart.js | 3 +-- .../modules/shop/module-ajax-controller.php | 5 +++- .../cosmopet/templates/modal/basket.twig | 25 +------------------ .../cosmopet/templates/shop/cart-bottom.twig | 24 ++++++++++++++++++ 5 files changed, 36 insertions(+), 27 deletions(-) create mode 100644 wp-content/themes/cosmopet/templates/shop/cart-bottom.twig diff --git a/wp-content/themes/cosmopet/modules/layout/assets/css/gp-style-core.css b/wp-content/themes/cosmopet/modules/layout/assets/css/gp-style-core.css index dad8e2b..4ab6a74 100644 --- a/wp-content/themes/cosmopet/modules/layout/assets/css/gp-style-core.css +++ b/wp-content/themes/cosmopet/modules/layout/assets/css/gp-style-core.css @@ -2178,3 +2178,9 @@ textarea{ } +.modal__button--center{ + margin-right: auto; + margin-left: auto; + display: block; + width: max-content; +} \ No newline at end of file diff --git a/wp-content/themes/cosmopet/modules/shop/components/cart/assets/js/cart.js b/wp-content/themes/cosmopet/modules/shop/components/cart/assets/js/cart.js index 0bd386d..53162d7 100644 --- a/wp-content/themes/cosmopet/modules/shop/components/cart/assets/js/cart.js +++ b/wp-content/themes/cosmopet/modules/shop/components/cart/assets/js/cart.js @@ -341,13 +341,12 @@ jQuery(document).ready(function($) { if (response.success) { $('#modal-basket-content').html(response.data.contents); $('.modal-block-price__price').html(response.data.total); + $('#modal-basket-footer').html(response.data.cart_bottom) $('.mini-profile__button--counter').text(response.data.count); if (response.data.count > 0) { $('.mini-profile__button--counter').removeClass('disabled'); - $('.proceed-to-checkout').css('display', ''); // Показываем кнопку, если есть товары } else { $('.mini-profile__button--counter').addClass('disabled'); - $('.proceed-to-checkout').css('display', 'none'); // Скрываем кнопку, если корзина пуста } } }, diff --git a/wp-content/themes/cosmopet/modules/shop/module-ajax-controller.php b/wp-content/themes/cosmopet/modules/shop/module-ajax-controller.php index 7f36e87..89f74ec 100644 --- a/wp-content/themes/cosmopet/modules/shop/module-ajax-controller.php +++ b/wp-content/themes/cosmopet/modules/shop/module-ajax-controller.php @@ -99,9 +99,12 @@ function get_cart_fragment_handler() { ob_start(); Timber::render('shop/cart-contents.twig', Timber::context()); $contents = ob_get_clean(); - + ob_start(); + Timber::render('shop/cart-bottom.twig', Timber::context()); + $cartBottom= ob_get_clean(); $response = array( 'contents' => $contents, + 'cart_bottom' => $cartBottom, 'total' => WC()->cart->get_cart_total(), 'count' => WC()->cart->get_cart_contents_count() ); diff --git a/wp-content/themes/cosmopet/templates/modal/basket.twig b/wp-content/themes/cosmopet/templates/modal/basket.twig index b19d3c4..886371f 100644 --- a/wp-content/themes/cosmopet/templates/modal/basket.twig +++ b/wp-content/themes/cosmopet/templates/modal/basket.twig @@ -16,29 +16,6 @@ \ No newline at end of file diff --git a/wp-content/themes/cosmopet/templates/shop/cart-bottom.twig b/wp-content/themes/cosmopet/templates/shop/cart-bottom.twig new file mode 100644 index 0000000..9d70685 --- /dev/null +++ b/wp-content/themes/cosmopet/templates/shop/cart-bottom.twig @@ -0,0 +1,24 @@ + {% if not fn('WC').cart.is_empty and fn('WC').cart.get_total('raw') > 0 %} + + + + {% else %} + + + + + + {% endif %} \ No newline at end of file -- 2.36.3 From 75f33e92e22ab1bb5fbb89dcd97aea01fc614c7d Mon Sep 17 00:00:00 2001 From: maksim Date: Mon, 9 Jun 2025 10:10:42 +0300 Subject: [PATCH 02/10] =?UTF-8?q?Fix=20|=20task=206619=20=D0=B8=D1=81?= =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=20=D0=B1=D0=B0=D0=B3?= =?UTF-8?q?=20=D0=B2=20js=20=D0=BA=D0=BE=D0=B4=D0=B5=20=D1=84=D0=BE=D1=80?= =?UTF-8?q?=D0=BC=D1=8B=20=D1=87=D0=B5=D0=BA=D0=B0=D1=83=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/checkout/assets/js/script.js | 174 +----------------- 1 file changed, 3 insertions(+), 171 deletions(-) diff --git a/wp-content/themes/cosmopet/modules/shop/components/checkout/assets/js/script.js b/wp-content/themes/cosmopet/modules/shop/components/checkout/assets/js/script.js index fafa1a1..e5e05eb 100644 --- a/wp-content/themes/cosmopet/modules/shop/components/checkout/assets/js/script.js +++ b/wp-content/themes/cosmopet/modules/shop/components/checkout/assets/js/script.js @@ -151,182 +151,14 @@ jQuery(document).ready(function ($) { $('#delete_coupon').on('click', function(){ $('.woocommerce-remove-coupon[data-coupon=' + $(this).data('coupon') + ']').click() + $('#promo_form').show() + $('#promo_delete').hide() }) $('.woocommerce-remove-coupon').on('click', function(){ - $('#promo_form').show() - $('#promo_delete').hide() + $('#promo_delete').hide() }) }); -jQuery(document).ready(function($) { - // Функция для получения активных фильтров из URL - function getActiveFilters() { - const params = new URLSearchParams(window.location.search); - const filters = []; - - params.forEach((value, key) => { - if (key.startsWith('filter_') || key === 'min_price' || key === 'max_price') { - let filterName = key.replace('filter_', '').replace('_', ' '); - let filterValue = value.split(',').map(val => decodeURIComponent(val.replace(/\+/g, ' '))); - - if (key === 'min_price') { - filterName = 'Цена от'; - filterValue = [value + ' ₽']; - } else if (key === 'max_price') { - filterName = 'Цена до'; - filterValue = [value + ' ₽']; - } - - filters.push({ - key: key, - name: filterName.charAt( W1).toUpperCase() + filterName.slice(1), - values: filterValue - }); - } - }); - - return filters; - } - - // Функция для отображения активных фильтров - function displayActiveFilters() { - const $filterList = $('.active-filters__list'); - const $filterContainer = $('.active-filters'); - const $clearButton = $('.active-filters__clear'); - $filterList.empty(); - - const activeFilters = getActiveFilters(); - - if (activeFilters.length > 0) { - $filterContainer.show(); - $clearButton.show(); - - activeFilters.forEach(filter => { - filter.values.forEach(value => { - const $filterTag = $('', { - class: 'active-filters__tag', - html: `${filter.name}: ${value} ×` - }); - $filterList.append($filterTag); - }); - }); - W2 else { - $filterContainer.hide(); - $clearButton.hide(); - } - } - - // Инициализация при загрузке страницы - displayActiveFilters(); - - // Обновление фильтров после AJAX-фильтрации - $(document).on('wcpf_after_filtering', function() { - displayActiveFilters(); - }); - - // Удаление фильтра - $(document).on('click', '.active-filters__remove', function() { - const key = $(this).data('key'); - const value = $(this).data('value'); - const params = new URLSearchParams(window.location.search); - - if (key === 'min_price' || key === 'max_price') { - params.delete(key); - } else { - let values = params.get(key) ? params.get(key).split(',') : []; - values = values.filter(val => decodeURIComponent(val.replace(/\+/g, ' ')) !== value); - if (values.length > 0) { - params.set(key, values.join(',')); - } else { - params.delete(key); - } - } - - const newUrl = window.location.pathname + (params.toString() ? '?' + params.toString() : ''); - window.history.pushState({}, '', newUrl); - - // Запуск AJAX-фильтрации - $.ajax({ - url: wc_checkout_params.ajax_url, - type: 'POST', - data: { - action: 'wcpf_filter', - query: params.toString(), - category_id: $('#load-more-products').data('category_id'), - category_type: $('#load-more-products').data('category_type') - }, - success: function(response) { - if (response.success) { - $('.product__main').html(response.data.products); - displayActiveFilters(); - $(document.body).trigger('wc_fragments_refreshed'); - } - }, - error: function() { - alert('Ошибка при обновлении фильтров'); - } - }); - }); - - // Очистка всех фильтров - $(document).on('click', '.active-filters__clear', function() { - const params = new URLSearchParams(window.location.search); - const newUrl = window.location.pathname; - window.history.pushState({}, '', newUrl); - - $.ajax({ - url: wc_checkout_params.ajax_url, - type: 'POST', - data: { - action: 'wcpf_filter', - query: '', - category_id: $('#load-more-products').data('category_id'), - category_type: $('#load-more-products').data('category_type') - }, - success: function(response) { - if (response.success) { - $('.product__main').html(response.data.products); - displayActiveFilters(); - $(document.body).trigger('wc_fragments_refreshed'); - } - }, - error: function() { - alert('Ошибка при очистке фильтров'); - } - }); - }); - // Обработка загрузки дополнительных продуктов - $(document).on('click', '#load-more-products', function() { - const $button = $(this); - const categoryId = $button.data('category_id'); - const categoryType = $button.data('category_type'); - const page = parseInt($button.data('page') || 1) + 1; - - $.ajax({ - url: wc_checkout_params.ajax_url, - type: 'POST', - data: { - action: 'load_more_products', - category_id: categoryId, - category_type: categoryType, - page: page, - query: window.location.search - }, - success: function(response) { - if (response.success) { - $('.product__main').append(response.data.products); - $button.data('page', page); - if (!response.data.has_more) { - $button.hide(); - } - } - }, - error: function() { - alert('Ошибка при загрузке продуктов'); - } - }); - }); -}); -- 2.36.3 From b09eb89f67ccb4799dc5e71eaf2f16e30e000b06 Mon Sep 17 00:00:00 2001 From: maksim Date: Mon, 9 Jun 2025 10:49:43 +0300 Subject: [PATCH 03/10] =?UTF-8?q?Fix=20|=20task=206613=20=D0=B8=D1=81?= =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D1=8B=20=D0=BE=D1=88?= =?UTF-8?q?=D0=B8=D0=B1=D0=BA=D0=B8=20=D0=B2=20=D0=BC=D0=B0=D0=BA=D0=B5?= =?UTF-8?q?=D1=82=D0=B5=20=D0=BF=D0=BE=D0=BF=D0=B0=D0=BF=D0=B0=20=D1=81?= =?UTF-8?q?=D0=BF=D0=B0=D1=81=D0=B8=D0=B1=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wp-content/themes/cosmopet/templates/footer.twig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wp-content/themes/cosmopet/templates/footer.twig b/wp-content/themes/cosmopet/templates/footer.twig index eba9552..43bcedc 100644 --- a/wp-content/themes/cosmopet/templates/footer.twig +++ b/wp-content/themes/cosmopet/templates/footer.twig @@ -56,7 +56,7 @@ -{% verbatim %} + - +{% verbatim %}