Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kamaroly/0f1c6ec6c90a6c44dca3254317298278 to your computer and use it in GitHub Desktop.
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
<?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 } ?>
@kamaroly
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment