Skip to content

Instantly share code, notes, and snippets.

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 KoolPal/c041bde41a754b8b8b66e8d7008ebd17 to your computer and use it in GitHub Desktop.
Save KoolPal/c041bde41a754b8b8b66e8d7008ebd17 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 } ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment