Answer the question
In order to leave comments, you need to log in
How to make auto-refresh in the cart when you click +/-?
Hello.
Can you please tell me how to update the cart automatically?
I found a code that works on manual input in the .qtu field, but due to my poor knowledge of js, I can’t add an update by clicking on +/- in any way. Our buttons are custom, so there are such problems.
add_action( 'wp_footer', 'cart_update_qty_script' );
function cart_update_qty_script() {
if (is_cart()) :
?>
<script>
jQuery('div.woocommerce').on('change', '.qty', function(){
jQuery("[name='update_cart']").trigger("click");
});
</script>
<?php
endif;
}
<div class="quantity">
<input type="number" class="input-text qty text" step="1" value="3" title="Количество" size="4" placeholder="" inputmode="numeric">
<input type="button" value="+" class="lafka-qty-plus">
<input type="button" value="-" class="lafka-qty-minus">
</div>
Answer the question
In order to leave comments, you need to log in
jQuery('.lafka-qty-plus, .lafka-qty-minus').on('click', function() {
jQuery("[name='update_cart']").trigger("click");
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question