Created
August 22, 2021 04:02
-
-
Save bagerathan/5bbe19a3c2222005bdb951d9483bf289 to your computer and use it in GitHub Desktop.
[Update cart without button] #woo
This file contains hidden or 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
| <!-- 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