fix: remap add-to-cart→product_id for AJAX, fallback zone detection for guest FSN amount

This commit is contained in:
2026-03-05 08:44:52 +01:00
parent f8081c6b65
commit 1f85d517f0
2 changed files with 68 additions and 3 deletions

View File

@@ -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 );