From 7825f00ae64905ad4935c6bcd3ade892c0cbb78c Mon Sep 17 00:00:00 2001 From: maksim Date: Fri, 13 Jun 2025 13:34:05 +0300 Subject: [PATCH] =?UTF-8?q?task:=206753=20|=20=D1=83=D0=B1=D1=80=D0=B0?= =?UTF-8?q?=D0=BB=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D1=8E=20=D0=BE?= =?UTF-8?q?=D1=82=D0=BC=D0=B5=D0=BD=D1=8B=20=D1=83=D0=B4=D0=B0=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F=20=D0=B2=20=D0=BA=D0=BE=D1=80=D0=B7=D0=B8?= =?UTF-8?q?=D0=BD=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../blog/assets/css/gp-style-desktop.css | 5 +- .../shop/components/cart/assets/js/cart.js | 61 ++--------------- .../cosmopet/static/front-page/css/style.css | 1 - .../cosmopet/temp-functions/cart-logic.php | 68 ------------------- 4 files changed, 10 insertions(+), 125 deletions(-) diff --git a/wp-content/themes/cosmopet/modules/blog/assets/css/gp-style-desktop.css b/wp-content/themes/cosmopet/modules/blog/assets/css/gp-style-desktop.css index 4e8d326..d6fb152 100644 --- a/wp-content/themes/cosmopet/modules/blog/assets/css/gp-style-desktop.css +++ b/wp-content/themes/cosmopet/modules/blog/assets/css/gp-style-desktop.css @@ -87,4 +87,7 @@ main{ margin-right: auto; margin-left: auto; 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 d207893..fa75b93 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 @@ -143,59 +143,7 @@ jQuery(document).ready(function($) { const variationId = $item.data('variation_id') || 0; const quantity = parseInt($item.find('.counter__input').val()); - // Сохраняем во временное хранилище - const removedItems = JSON.parse(localStorage.getItem(removedItemsStorageKey)) || []; - removedItems.push({ product_id: productId, variation_id: variationId, quantity: quantity, key: key }); - localStorage.setItem(removedItemsStorageKey, JSON.stringify(removedItems)); - - // Показываем кнопку восстановления - $item.html(` - - - `); - - // Проверяем количество товаров в корзине - $.ajax({ - type: 'POST', - url: woocommerce_params.ajax_url, - data: { - action: 'check_cart_count' - }, - success: function(response) { - if (response.success && response.data.count <= 1) { - // Если после удаления корзина станет пустой (1 товар сейчас, удаляем его) - $('.proceed-to-checkout').css('display', 'none'); - } - } - }); - - // Удаляем через 5 секунд, если не восстановили - const removeTimeout = setTimeout(() => { - permanentRemoveItem(key, productId, variationId); - }, 5000); - const product_remove_timer = setInterval(() => { - let number = Number($(`#${key}_timer`).html()) - 1; - $(`#${key}_timer`).html(number); - }, 1000); - - // Обработчик восстановления - $(document).off('click', `[data-key="${key}"] .modal-basket-item__return`).on('click', `[data-key="${key}"] .modal-basket-item__return`, function(e) { - e.preventDefault(); - clearTimeout(removeTimeout); - clearInterval(product_remove_timer); // Очищаем интервал - restoreItem(key, productId, variationId, quantity); - }); - } - - // Полное удаление товара - function permanentRemoveItem(key, productId, variationId) { $('#modal-basket').addClass('loading'); $.ajax({ @@ -217,13 +165,15 @@ jQuery(document).ready(function($) { ); localStorage.setItem(removedItemsStorageKey, JSON.stringify(updatedItems)); - updateCartFragment(false); - $('[data-key="' + key + '"]').remove() + updateCartFragment(); + // $('[data-key="' + key + '"]').remove() } } }); + } + // Восстановление товара function restoreItem(key, productId, variationId, quantity) { $('#modal-basket').addClass('loading'); @@ -359,8 +309,9 @@ jQuery(document).ready(function($) { beforeSend: function() { $('#modal-basket').addClass('loading'); }, - complete: function() { + complete: function(response) { $('#modal-basket').removeClass('loading'); + console.log(response) }, success: function(response) { console.log(response); 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 80883d8..78cea8b 100644 --- a/wp-content/themes/cosmopet/static/front-page/css/style.css +++ b/wp-content/themes/cosmopet/static/front-page/css/style.css @@ -4552,7 +4552,6 @@ color: #f4f1f0; .modal__aside { position: fixed; transition: right 0.3s ease-in-out; - right: -400px; } .modal__aside.active { diff --git a/wp-content/themes/cosmopet/temp-functions/cart-logic.php b/wp-content/themes/cosmopet/temp-functions/cart-logic.php index 1b867f3..ab4fa67 100644 --- a/wp-content/themes/cosmopet/temp-functions/cart-logic.php +++ b/wp-content/themes/cosmopet/temp-functions/cart-logic.php @@ -1,70 +1,2 @@ cart; - $count = $cart->get_cart_contents_count(); - $total = $cart->get_total('raw'); // Числовая сумма - $total_html = wc_cart_totals_order_total_html(); // Форматированная сумма - - wp_send_json_success([ - 'contents' => $contents, - 'footer' => $footer, - 'count' => $count, - 'total' => $total_html, - 'total_raw' => $total - ]); -} - -add_action('template_redirect', 'custom_redirect_cart_page'); -function custom_redirect_cart_page() { - if (is_cart()) { - wp_redirect(home_url('/')); - exit; - } -} - -add_action('wp_enqueue_scripts', 'remove_woocommerce_styles_on_checkout', 9999); -function remove_woocommerce_styles_on_checkout() { - // Проверяем, что мы на странице чекаута - if (function_exists('is_checkout') && is_checkout() && !is_order_received_page()) { - wp_deregister_style('woocommerce-layout'); - wp_deregister_style('woocommerce-smallscreen'); - wp_deregister_style('woocommerce-general'); - - // Дополнительно: отключить другие стили WooCommerce - wp_dequeue_style('select2'); - wp_deregister_style('select2'); - } -} - -add_action('wp_head', 'custom_checkout_padding'); -function custom_checkout_padding() { - // Проверяем, что это страница Checkout - if (is_checkout() && !is_admin()) { - ?> - -