Hello Sea Theme,
On the cart page. Is it possible to automatically “update cart” after changing the quantity of the product item, please?
I’ve tried search google and put this code into functions.php, but don’t work for this kind of #QTY of the theme cart page. (I don’t know to code and don’t know that this code is correct or not)
add_action( ‘wp_footer’, ‘bbloomer_cart_refresh_update_qty’ );
function bbloomer_cart_refresh_update_qty() {
if (is_cart()) {
?>
<script type=”text/javascript”>
var timeout;
jQuery(‘div.woocommerce’).on(‘change’, ‘input.qty’, function(){ // keyup and mouseup for Firefox support
if (timeout != undefined) clearTimeout(timeout); //cancel previously scheduled event
if (jQuery(this).val() == ”) return; //qty empty, instead of removing item from cart, do nothing
timeout = setTimeout(function() {
jQuery(‘[name=”update_cart”]’).trigger(‘click’);
}, 1000 ); // schedule update cart event with 1000 miliseconds delay
});
</script>
<?php
}
}
Could you please suggest to me about the code to automatically “update cart” when the quantity of cart item change.
thank you
Regards!
Min