// Woocommerce plus-minus butons jQuery(document).ready(function($){ $(document).on('click', '.plus', function(e) { // replace '.quantity' with document (without single quote) $input = $(this).prev('input.qty'); var val = parseInt($input.val()); var step = $input.attr('step'); step = 'undefined' !== typeof(step) ? parseInt(step) : 1; $input.val( val + step ).change(); }); $(document).on('click', '.minus', // replace '.quantity' with document (without single quote) function(e) { $input = $(this).next('input.qty'); var val = parseInt($input.val()); var step = $input.attr('step'); step = 'undefined' !== typeof(step) ? parseInt(step) : 1; if (val > 0) { $input.val( val - step ).change(); } }); }); // Autoupdate cart var timeout; jQuery(document).ready(function($){ $('.woocommerce').on('change', 'input.qty', function(){ if ( timeout !== undefined ) { clearTimeout( timeout ); } timeout = setTimeout(function() { $("[name='update_cart']").trigger("click"); }, 1000 ); // 1 second delay, half a second (500) seems comfortable too }); } );
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter