Forked from kamaroly/WooCommerce Auto update cart after quantity change.php
Created
May 5, 2019 07:18
-
-
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
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
<?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