Skip to content

Instantly share code, notes, and snippets.

@eminozlem
Created February 1, 2023 06:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eminozlem/6c212bd7c95fa200fe713265c2c2f59b to your computer and use it in GitHub Desktop.
Save eminozlem/6c212bd7c95fa200fe713265c2c2f59b to your computer and use it in GitHub Desktop.
Update Cart on Quantity Change
add_action( 'wp_head', function() {
?><style>
.woocommerce button[name="update_cart"],
.woocommerce input[name="update_cart"] {
display: none;
}</style><?php
} );
add_action( 'wp_footer', function() {
?><script>
jQuery( function( $ ) {
let timeout;
$('.woocommerce').on('change', 'input.qty', function(){
if ( timeout !== undefined ) {
clearTimeout( timeout );
}
timeout = setTimeout(function() {
$("[name='update_cart']").trigger("click");
}, 500 );
});
} );
</script><?php
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment