Auto-Update Cart on Quantity Change
Removes the 'Update cart' button and automatically submits the WooCommerce cart form whenever a quantity input value changes.
JavaScriptby SnipCraft
js
(function ($) {
'use strict';
if (typeof wc_cart_params === 'undefined') {
return; // Not on the cart page.
}
$(document).ready(function () {
// Visually hide the button; it is still used as the trigger.
$('[name="update_cart"]').css({ opacity: 0, position: 'absolute', pointerEvents: 'none' });
var timer;
$(document).on('change', 'input.qty', function () {
clearTimeout(timer);
timer = setTimeout(function () {
$('[name="update_cart"]').prop('disabled', false).trigger('click');
}, 600);
});
});
}(jQuery));#cart#frontend#jquery#ux#woocommerce