Last active
January 26, 2022 11:03
-
-
Save mikaelz/f41e29c6a99a595602e4 to your computer and use it in GitHub Desktop.
WooCommerce auto-update cart when quantity changed, relates with https://gist.github.com/mikaelz/418a337dace188ba95b476ce65abfe0c
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
/** | |
* Auto update cart after quantity change | |
* | |
* @return string | |
**/ | |
add_action( 'woocommerce_after_cart', 'custom_after_cart' ); | |
function custom_after_cart() { | |
echo '<script> | |
jQuery(document).ready(function($) { | |
var upd_cart_btn = $(".update-cart-button"); | |
upd_cart_btn.hide(); | |
$(".cart-form").find(".qty").on("change", function(){ | |
upd_cart_btn.trigger("click"); | |
}); | |
}); | |
</script>'; | |
} |
@ghost solution works!
Any ideas how to prevent cart auto update if user tries to add stock for product with insufficient stock?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi guys, anyone have a solution for updating cart totals when is delivery method changed ?