fix: remap add-to-cart→product_id for AJAX, fallback zone detection for guest FSN amount
This commit is contained in:
@@ -113,7 +113,17 @@
|
||||
e.preventDefault();
|
||||
$btn.addClass( 'loading' ).data( 'cgkit-fc-handled', true );
|
||||
|
||||
$.post( ajaxUrl, $form.serialize() )
|
||||
// WC's wc-ajax=add_to_cart reads $_POST['product_id'], but the
|
||||
// single-product form submits the ID as field name 'add-to-cart'.
|
||||
// Append the correctly-named field so the endpoint finds it.
|
||||
var serialized = $form.serialize();
|
||||
var productId = $form.find( '[name="add-to-cart"]' ).val() ||
|
||||
$form.find( '[name="product_id"]' ).val() || '';
|
||||
if ( productId && serialized.indexOf( 'product_id=' ) === -1 ) {
|
||||
serialized += '&product_id=' + encodeURIComponent( productId );
|
||||
}
|
||||
|
||||
$.post( ajaxUrl, serialized )
|
||||
.done( function ( response ) {
|
||||
if ( ! response ) {
|
||||
self.formFallback( $form, $btn );
|
||||
|
||||
Reference in New Issue
Block a user