Update WooCommerce Cart on Quantity Change
// Update WooCommerce Cart on Quantity Change
add_action( 'wp_head', function () { ?>
<script>
var timeout;
jQuery( function( $ ) {
$('.woocommerce').on('change', 'input.qty', function(){
if ( timeout !== undefined ) {
clearTimeout( timeout );
}
timeout = setTimeout(function() {
$("[name='update_cart']").trigger("click");
}, 1000 ); // 1 second delay, half a second (500) seems comfortable too
});
} );
</script>
<style>
/* Hide Update cart button */
.woocommerce button[name="update_cart"],
.woocommerce input[name="update_cart"] {
display: none;
}
</style>
<?php } );
Only run on site front-end