Skip to content

Instantly share code, notes, and snippets.

@palicko
Created November 10, 2016 13:35
Show Gist options
  • Save palicko/0ff7fbe4a19f9bb4483340c1b7708d2c to your computer and use it in GitHub Desktop.
Save palicko/0ff7fbe4a19f9bb4483340c1b7708d2c to your computer and use it in GitHub Desktop.
/**
* Auto update cart after quantity change
*
* @return string
**/
add_action( 'wp_footer', 'cart_auto_update_qty_script' );
function cart_auto_update_qty_script() {
if ( is_cart() ) : ?>
<script>
jQuery('div.woocommerce').on('change', '.qty', function(){
jQuery("[name='update_cart']").trigger("click");
});
</script>
<?php endif;
}
// hide with CSS
.woocommerce-cart [name="update_cart"] {
display: none;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment