Created
October 9, 2023 14:34
-
-
Save artikus11/cbd4709c09ed2992a1479dac9437de23 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$( '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