Skip to content

Instantly share code, notes, and snippets.

@bagerathan
Created August 22, 2021 04:02
Show Gist options
  • Select an option

  • Save bagerathan/5bbe19a3c2222005bdb951d9483bf289 to your computer and use it in GitHub Desktop.

Select an option

Save bagerathan/5bbe19a3c2222005bdb951d9483bf289 to your computer and use it in GitHub Desktop.
[Update cart without button] #woo
<!-- Update woocommerce cart after quantity change without clicking the button -->
<style>
.woocommerce button[name="update_cart"],
.woocommerce input[name="update_cart"] {
display: none;
}
</style>
<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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment