Created
February 1, 2023 06:21
-
-
Save eminozlem/6c212bd7c95fa200fe713265c2c2f59b to your computer and use it in GitHub Desktop.
Update Cart on Quantity Change
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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