Skip to content

Instantly share code, notes, and snippets.

@artikus11
Created October 9, 2023 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save artikus11/cbd4709c09ed2992a1479dac9437de23 to your computer and use it in GitHub Desktop.
Save artikus11/cbd4709c09ed2992a1479dac9437de23 to your computer and use it in GitHub Desktop.
$( 'form.checkout' ).on( 'change', 'input.qty', function( e ) {
let maxQtyData = {};
let inputs = $( this ).closest( '.woocommerce-checkout-review-order-list' ).find( 'input.qty' );
inputs.each( function( index, element ) {
maxQtyData[$( element ).attr( 'name' )] = $( this ).attr( 'max' );
} );
var data = {
security: wc_checkout_params.update_order_review_nonce,
action: 'update_order_qty_review',
order_data: inputs.serialize(),
max_data: maxQtyData
};
if ( timeout !== undefined ) {
clearTimeout( timeout );
}
timeout = setTimeout( function() {
$.ajax( {
type: 'POST',
url: wc_checkout_params.ajax_url,
data: data,
success: function( response ) {
$( document.body ).trigger( 'update_checkout', { update_shipping_method: true } );
}
} );
}, 100 );
return false;
} );
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment