Answer the question
In order to leave comments, you need to log in
How to change a tag after ajax request?
I have an online store on woocommerce, ajax adding goods to the cart works, everything is good, but I want that if the cart is empty, when a person clicks on the cart, he will see the modal window "Cart is empty", and if he added a product, then it would be transferred to the cart in fact, the catch is that this whole thing should work on ajax
HTML cart output
<a href="/" class="cart-btn header-top-item flex-container">
<div class="cart-icon"></div>
<div class="text-col">
<span class="title">Shopping Cart</span>
<div class="cart__subtotal">
<span class="subtitlew">
<?php
$total_cart = WC()->cart->get_displayed_subtotal();
echo $total_cart;
?>
</span>
<a href="/store/" class="url__nice"></a>
<span class="subtitle"><?php echo get_woocommerce_currency_symbol(); ?></span>
</div>
</div>
</a>
add_filter('woocommerce_add_to_cart_fragments', 'header_add_to_cart_fragment');
function header_add_to_cart_fragment( $fragments ) {
global $woocommerce;
ob_start();
?>
<a href="/store/checkout" class="url__nice"></a>
<span class="subtitlew">(<?php echo WC()->cart->get_cart_total(); ?>)</span>
<?php
$fragments['.subtitlew'] = ob_get_clean();
return $fragments;
}
Answer the question
In order to leave comments, you need to log in
$.post('/basket', 'checkbusket':1, function(data){
if(data == 'пусто'){
вашаФункцияМодальногоОкна('сообщение');
} else {
location='/basket';
}
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question