From 12c4a0ca3509a1eef6b964fbace19f261690d578 Mon Sep 17 00:00:00 2001 From: GP_DV Date: Thu, 15 May 2025 19:33:11 +0300 Subject: [PATCH] Fix bugs --- wp-content/themes/cosmopet/functions.php | 6 +- .../header/assets/css/gp-style-desktop.css | 40 +-- .../modules/layout/assets/js/gp-main.js | 8 +- .../shop/components/cart/assets/js/cart.js | 15 +- .../components/cart/component-controller.php | 17 +- .../themes/cosmopet/templates/header.twig | 4 +- .../cosmopet/woocommerce/archive-product.php | 2 +- .../archive-product-tease.twig | 15 +- .../woocommerce/cart/cart-item-data.php | 29 --- .../themes/cosmopet/woocommerce/cart/cart.php | 236 ------------------ .../cosmopet/woocommerce/cart/cross-sells.php | 57 ----- .../cosmopet/woocommerce/cart/mini-cart.php | 167 ------------- 12 files changed, 64 insertions(+), 532 deletions(-) delete mode 100644 wp-content/themes/cosmopet/woocommerce/cart/cart-item-data.php delete mode 100644 wp-content/themes/cosmopet/woocommerce/cart/cart.php delete mode 100644 wp-content/themes/cosmopet/woocommerce/cart/cross-sells.php delete mode 100644 wp-content/themes/cosmopet/woocommerce/cart/mini-cart.php diff --git a/wp-content/themes/cosmopet/functions.php b/wp-content/themes/cosmopet/functions.php index 9210656..4b71c88 100644 --- a/wp-content/themes/cosmopet/functions.php +++ b/wp-content/themes/cosmopet/functions.php @@ -501,7 +501,7 @@ function get_products() { $context['get_category_type'] = isset($_POST['get_category_type']) ? $_POST['get_category_type'] : NULL; // Задаем количество постов для подзагрузки Ajax - $posts_per_page = 1; + $posts_per_page = 12; $args = array( 'post_type' => 'product', @@ -546,7 +546,9 @@ function get_products() { $context['count'] = count(Timber::get_posts($count_args)); - if ($context['count'] <= $context['get_page'] * 1) $context['ended'] = true; + if ($context['count'] <= $context['get_page'] * $posts_per_page) { + $context['ended'] = true; + } Timber::render( 'woocommerce/archive-product/archive-product-ajaxload.twig', $context ); diff --git a/wp-content/themes/cosmopet/modules/header/assets/css/gp-style-desktop.css b/wp-content/themes/cosmopet/modules/header/assets/css/gp-style-desktop.css index f9f3988..054aca4 100644 --- a/wp-content/themes/cosmopet/modules/header/assets/css/gp-style-desktop.css +++ b/wp-content/themes/cosmopet/modules/header/assets/css/gp-style-desktop.css @@ -731,26 +731,26 @@ width: 0px; -.mini-profile__button--counter{ - display: flex; - flex-direction: row; - justify-content: center; - align-items: center; - padding: 2px; - position: absolute; - background: var(--gradient-turquoise); - border-radius: 10px; - width: 16px; - height: 16px; - - border-radius: 50%; - top: 6px; - right: 6px; - font-style: normal; - font-weight: 700; - font-size: 9px; - line-height: 16px; - color: #121212; +.mini-profile__button--counter { + display: flex +; + flex-direction: row; + justify-content: center; + align-items: center; + padding: 2px; + position: absolute; + background: var(--gradient-turquoise); + border-radius: 10px; + width: 16px; + height: 16px; + border-radius: 50%; + right: 30px; + bottom: 20px; + font-style: normal; + font-weight: 700; + font-size: 9px; + line-height: 16px; + color: #121212; } .mini-profile__button--counter.disabled{ 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 2338e28..a46047a 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 @@ -22,13 +22,17 @@ jQuery(document).ready(function ($) { product.find('.state__block').removeClass('expanded').css('height', '0'); product.find('.add_to_cart_button').detach(); - product.find('.product-item-overlay__button').prepend('Добавить в корзину'); + product.find('.product-item-overlay__button').prepend('Добавить в корзину'); }) $('.product__main').on('click', '.counter__button', function(evt) { evt.preventDefault(); let product = $(this).closest('.product__item'); let price = parseFloat(product.find('.select__state').data('product_price')); + + if (!price){ + price = parseFloat(product.find('.product-item__price p').html()); + } let qty = product.find('.counter__input'); if ($(this).hasClass('minus') && parseInt(qty.val()) >= 2) { @@ -38,7 +42,7 @@ jQuery(document).ready(function ($) { qty.val(parseInt(qty.val()) + 1); } } - + product.find('.product-item-overlay__button a').attr('data-quantity', qty.val()) product.find('.product-item-overlay__price').html(price * qty.val() + ' '); }) 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 bb96745..4d94394 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 @@ -39,7 +39,7 @@ jQuery(document).ready(function($) { input.val(quantity).trigger('change'); }); - $(document).on('click', '.remove-item', function() { + $(document).on('click', '.remove-item', function() { const key = $(this).data('key'); removeItem(key); }); @@ -266,11 +266,18 @@ jQuery(document).ready(function($) { if (response.success) { $('#modal-basket-content').html(response.data.contents); $('.modal-block-price__price').html(response.data.total); - $('.cart-count').text(response.data.count); - + $('.mini-profile__button--counter').text(response.data.count); + if(response.data.count > 0){ + $('.mini-profile__button--counter').removeClass('disabled') + } + else( + $('.mini-profile__button--counter').addClass('disabled') + ) } } }); } -}); \ No newline at end of file +}); + + diff --git a/wp-content/themes/cosmopet/modules/shop/components/cart/component-controller.php b/wp-content/themes/cosmopet/modules/shop/components/cart/component-controller.php index bfad3cb..2a423c1 100644 --- a/wp-content/themes/cosmopet/modules/shop/components/cart/component-controller.php +++ b/wp-content/themes/cosmopet/modules/shop/components/cart/component-controller.php @@ -1,8 +1,13 @@ cart->get_cart_contents_count(); + return $context; +}); \ No newline at end of file diff --git a/wp-content/themes/cosmopet/templates/header.twig b/wp-content/themes/cosmopet/templates/header.twig index 2c03b5e..a36322f 100644 --- a/wp-content/themes/cosmopet/templates/header.twig +++ b/wp-content/themes/cosmopet/templates/header.twig @@ -232,8 +232,8 @@ diff --git a/wp-content/themes/cosmopet/woocommerce/archive-product.php b/wp-content/themes/cosmopet/woocommerce/archive-product.php index b4ed0c0..895e8c6 100644 --- a/wp-content/themes/cosmopet/woocommerce/archive-product.php +++ b/wp-content/themes/cosmopet/woocommerce/archive-product.php @@ -13,7 +13,7 @@ $context['criteria_for_new_product'] = date('Y-m-d', strtotime('-30 days')); // Задаем количество постов для подзагрузки Ajax - $context['posts_per_page'] = 1; + $context['posts_per_page'] = 12; $queried_object = get_queried_object(); diff --git a/wp-content/themes/cosmopet/woocommerce/archive-product/archive-product-tease.twig b/wp-content/themes/cosmopet/woocommerce/archive-product/archive-product-tease.twig index 306fa6e..6678af7 100644 --- a/wp-content/themes/cosmopet/woocommerce/archive-product/archive-product-tease.twig +++ b/wp-content/themes/cosmopet/woocommerce/archive-product/archive-product-tease.twig @@ -6,13 +6,13 @@
{% if post.date('Y-m-d') >= criteria_for_new_product %} - + {{ function('pll_e', 'Новинка') }} {% endif %} {% if post._sale_price %} - + {{ function('pll_e', 'Распродажа %') }} {% endif %} @@ -53,14 +53,16 @@
+ {% set collection = fn('wc_get_product_terms', post.id, 'pa_collection') %} + {% if collection %}
-

Объем

- +

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

+
    - {% set collection = fn('wc_get_product_terms', post.id, 'pa_collection') %} + {% for option in collection %} {% set term = get_term(option) %} {% set siblings = function('get_collection_siblings' , term.id) %} @@ -84,8 +86,9 @@
+ {% endif %}
-

Количество

+

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

- -
- - -
-
- - - - - -
-
-
- - -
- -
- -
- - - - - -
- - - -
- - diff --git a/wp-content/themes/cosmopet/woocommerce/cart/cross-sells.php b/wp-content/themes/cosmopet/woocommerce/cart/cross-sells.php deleted file mode 100644 index c7a7c53..0000000 --- a/wp-content/themes/cosmopet/woocommerce/cart/cross-sells.php +++ /dev/null @@ -1,57 +0,0 @@ - - -
- - -

- - - apply_filters( 'woodmart_cross_sells_products_per_view', 4 ), - 'hide_pagination_control' => true, - 'hide_prev_next_buttons' => true, - 'img_size' => 'woocommerce_thumbnail', - 'custom_sizes' => apply_filters( 'woodmart_cross_sells_custom_sizes', false ), - 'product_quantity' => woodmart_get_opt( 'product_quantity' ), - 'products_bordered_grid' => woodmart_get_opt( 'products_bordered_grid' ), - 'products_bordered_grid_style' => woodmart_get_opt( 'products_bordered_grid_style' ), - 'products_with_background' => woodmart_get_opt( 'products_with_background' ), - 'products_shadow' => woodmart_get_opt( 'products_shadow' ), - 'products_color_scheme' => woodmart_get_opt( 'products_color_scheme' ), - ); - - woodmart_set_loop_prop( 'products_view', 'carousel' ); - - echo woodmart_generate_posts_slider( $slider_args, false, $cross_sells ); - - ?> - -
- - - -
-
- - cart->is_empty() ) : ?> - -
    - - cart->get_cart() as $cart_item_key => $cart_item ) { - $_i++; - if( $_i > $items_to_show ) break; - - $_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key ); - $product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key ); - - if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_widget_cart_item_visible', true, $cart_item, $cart_item_key ) ) { - /** - * This filter is documented in woocommerce/templates/cart/cart.php. - * - * @param string $product_name Name of the product in the cart. - */ - $product_name = apply_filters( 'woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key ); - - $product_price = apply_filters( 'woocommerce_cart_item_price', WC()->cart->get_product_price( $_product ), $cart_item, $cart_item_key ); - $product_permalink = apply_filters( 'woocommerce_cart_item_permalink', $_product->is_visible() ? $_product->get_permalink( $cart_item ) : '', $cart_item, $cart_item_key ); - ?> -
  • - - ×', - esc_url( wc_get_cart_remove_url( $cart_item_key ) ), - /* translators: %s is the product name */ - esc_attr( sprintf( __( 'Remove %s from cart', 'woocommerce' ), wp_strip_all_tags( $product_name ) ) ), - esc_attr( $product_id ), - esc_attr( $cart_item_key ), - esc_attr( $_product->get_sku() ) - ), $cart_item_key ); - ?> - - get_image(), $cart_item, $cart_item_key ); ?> - - - get_image(), $cart_item, $cart_item_key ); ?> - - - -
    - - - - -
    - - - - - get_sku() ) : ?> - get_sku() ); ?> - - - - -
    - - - - is_sold_individually() && $_product->is_purchasable() && woodmart_get_opt( 'mini_cart_quantity' ) && apply_filters( 'woodmart_show_widget_cart_item_quantity', true, $cart_item_key ) ) { - woocommerce_quantity_input( - array( - 'input_value' => $cart_item['quantity'], - 'min_value' => 0, - 'max_value' => $_product->backorders_allowed() ? '' : $_product->get_stock_quantity(), - ), - $_product - ); - } - ?> - - ' . sprintf( '%s × %s', $cart_item['quantity'], $product_price ) . '', $cart_item, $cart_item_key ); ?> -
    - -
  • - -
- - - -
-

- 0 ) : ?> - - - - -
- - - -
-
- -
- cart->is_empty() ) : ?> - - version, '3.7.0', '<' ) ) : ?> -

: cart->get_cart_subtotal(); ?>

- -

- -

- - - - -

- - - - - - -