Skip to content

Instantly share code, notes, and snippets.

@krishna19
Forked from mikaelz/functions.php
Created September 27, 2018 11:29
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 krishna19/234a510d64c9afbac99cfe61065a6816 to your computer and use it in GitHub Desktop.
Save krishna19/234a510d64c9afbac99cfe61065a6816 to your computer and use it in GitHub Desktop.
WooCommerce auto-update cart when quantity changed, relates with https://gist.github.com/mikaelz/418a337dace188ba95b476ce65abfe0c
/**
* 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>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment