Last active
October 12, 2023 16:57
-
-
Save kamaroly/0f1c6ec6c90a6c44dca3254317298278 to your computer and use it in GitHub Desktop.
Auto update cart after quantity change. You trigger the click, but the button doesn't have enough time to become enabled, so that is why, by the time you click the second time the button becomes enabled. Remove the "disabled" propriety before triggering the click. This should be added in **footer.php** of your child theme
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
<?php if (is_cart()) { ?> | |
<script type="text/javascript"> | |
// Each time quantity in the cart changes, trigger update | |
// cart option | |
jQuery('div.woocommerce').on('change', '.qty', function(){ | |
// Make sure the button is enabled before triggering the event | |
// otherwise this won't work. | |
jQuery("[name='update_cart']").prop("disabled", false); | |
jQuery("[name='update_cart']").trigger("click"); | |
}); | |
</script> | |
<?php } ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This Gist comes from this stackoverflow thread.
https://wordpress.stackexchange.com/questions/271341/auto-update-cart-after-quantity-change