Hi I have this site: https://books.websitescreated.com.au/cart/ and am using this to update the inputs on the cart page however it will not update your drawer cart.
/**
* Snippet Name: WooCommerce Automatically Update Cart On Quantity Change
* Snippet Author: ecommercehints.com
*/
// First, hide the Update Cart button
add_action( 'wp_head', 'ecommercehints_hide_update_cart_button' );
function ecommercehints_hide_update_cart_button() { ?>
<style>
button[name="update_cart"], input[name="update_cart"] {
display: none;
}
</style>
<?php }
// Second, add the jQuery to update the cart automaitcally on quantity change
add_action( 'wp_footer', 'ecommercehints_update_cart_on_quantity_change');
function ecommercehints_update_cart_on_quantity_change() { ?>
<script>
jQuery( function( $ ) {
let timeout;
$('.woocommerce').on('change', 'input.qty', function(){
if ( timeout !== undefined ) {
clearTimeout( timeout );
}
timeout = setTimeout(function() {
$("[name='update_cart']").trigger("click");
}, 500 ); // 500 being MS (half a second)
});
} );
</script>
<?php }
I need it to update your cart as well please. If I add one item from 1 to being 2 it updates the cart but not yours, it stays as 1 item. Same if you delete an item.