Fix | task 6635 Пофиксил обновление нижней части блока в корзине при ajax изменении состояния корзины (#29)

Co-authored-by: Your Name <you@example.com>
Reviewed-on: #29
dev_10_refactoring
Andrei-10 2 months ago
parent 7ea3a87b52
commit 0fd449fabd
  1. 6
      wp-content/themes/cosmopet/modules/layout/assets/css/gp-style-core.css
  2. 3
      wp-content/themes/cosmopet/modules/shop/components/cart/assets/js/cart.js
  3. 5
      wp-content/themes/cosmopet/modules/shop/module-ajax-controller.php
  4. 25
      wp-content/themes/cosmopet/templates/modal/basket.twig
  5. 24
      wp-content/themes/cosmopet/templates/shop/cart-bottom.twig

@ -2178,3 +2178,9 @@ textarea{
} }
.modal__button--center{
margin-right: auto;
margin-left: auto;
display: block;
width: max-content;
}

@ -341,13 +341,12 @@ jQuery(document).ready(function($) {
if (response.success) { if (response.success) {
$('#modal-basket-content').html(response.data.contents); $('#modal-basket-content').html(response.data.contents);
$('.modal-block-price__price').html(response.data.total); $('.modal-block-price__price').html(response.data.total);
$('#modal-basket-footer').html(response.data.cart_bottom)
$('.mini-profile__button--counter').text(response.data.count); $('.mini-profile__button--counter').text(response.data.count);
if (response.data.count > 0) { if (response.data.count > 0) {
$('.mini-profile__button--counter').removeClass('disabled'); $('.mini-profile__button--counter').removeClass('disabled');
$('.proceed-to-checkout').css('display', ''); // Показываем кнопку, если есть товары
} else { } else {
$('.mini-profile__button--counter').addClass('disabled'); $('.mini-profile__button--counter').addClass('disabled');
$('.proceed-to-checkout').css('display', 'none'); // Скрываем кнопку, если корзина пуста
} }
} }
}, },

@ -99,9 +99,12 @@ function get_cart_fragment_handler() {
ob_start(); ob_start();
Timber::render('shop/cart-contents.twig', Timber::context()); Timber::render('shop/cart-contents.twig', Timber::context());
$contents = ob_get_clean(); $contents = ob_get_clean();
ob_start();
Timber::render('shop/cart-bottom.twig', Timber::context());
$cartBottom= ob_get_clean();
$response = array( $response = array(
'contents' => $contents, 'contents' => $contents,
'cart_bottom' => $cartBottom,
'total' => WC()->cart->get_cart_total(), 'total' => WC()->cart->get_cart_total(),
'count' => WC()->cart->get_cart_contents_count() 'count' => WC()->cart->get_cart_contents_count()
); );

@ -16,29 +16,6 @@
</div> </div>
<div class="modal__footer" id="modal-basket-footer"> <div class="modal__footer" id="modal-basket-footer">
{% if not fn('WC').cart.is_empty and fn('WC').cart.get_total('raw') > 0 %} {% include 'shop/cart-bottom.twig' %}
<div class="modal__block-price">
<p class="modal-block-price__title">{{ __('Total', 'woocommerce') }}</p>
<p class="modal-block-price__price">
{{ fn('wc_cart_totals_order_total_html') }}
</p>
</div>
<div class="modal__block-button">
<div class="modal__button">
<a href="{{ fn('wc_get_checkout_url') }}" class="button button--gradient button--high button--100-perc proceed-to-checkout">
{{ __('Proceed to checkout', 'woocommerce') }}
</a>
</div>
</div>
{% else %}
<div class="modal__block-button">
<a href="/shop/" class="modal__button">
<button class="to-know button--100-perc to-know--background-none continue-shopping">
<p>{{ __('Continue shopping', 'woocommerce') }}</p>
</button>
</a>
</div>
{% endif %}
</div> </div>
</div> </div>

@ -0,0 +1,24 @@
{% if not fn('WC').cart.is_empty and fn('WC').cart.get_total('raw') > 0 %}
<div class="modal__block-price">
<p class="modal-block-price__title">{{ __('Total', 'woocommerce') }}</p>
<p class="modal-block-price__price">
{{ fn('wc_cart_totals_order_total_html') }}
</p>
</div>
<div class="modal__block-button">
<div class="modal__button">
<a href="{{ fn('wc_get_checkout_url') }}" class="button button--gradient button--high button--100-perc proceed-to-checkout">
{{ __('Proceed to checkout', 'woocommerce') }}
</a>
</div>
</div>
{% else %}
<a href="/shop/" class="modal__button modal__button--center">
<button class="to-know button--100-perc to-know--background-none continue-shopping">
<p>{{ __('Continue shopping', 'woocommerce') }}</p>
</button>
</a>
{% endif %}
Loading…
Cancel
Save