Update cart without the update button in cart.php

Goes into woocommerce.php or functions.php

/**
 * Update cart without the update button in cart.php
 */
function twstudio_cart_update_qty_script() {
	if (is_cart()) :
		?>
		<script>
			jQuery('div.woocommerce').on('click', '.qty', function(){
				jQuery("[name='update_cart']").removeAttr('disabled');
			});
			jQuery('div.woocommerce').on('change', '.qty', function(){
				jQuery("[name='update_cart']").trigger("click");
			});

		</script>
	<?php
	endif;
}
add_action( 'wp_footer', 'twstudio_cart_update_qty_script' );

2 comments on "Update cart without the update button in cart.php"

  1. Tariq says:

    How would we do it for mini cart.

    1. tws says:

      This plugin looks like it does the job: https://wordpress.org/plugins/woo-ajax-mini-cart/

Leave a Reply

Your email address will not be published. Required fields are marked *