diff --git a/inc/admin.php b/inc/admin.php index 5656e03..ed34819 100644 --- a/inc/admin.php +++ b/inc/admin.php @@ -275,6 +275,12 @@ function ppom_admin_save_form_meta() { wp_send_json( $resp ); } + if ( is_string( $_REQUEST['ppom'] ) ) { + $ppom_encoded = $_REQUEST['ppom']; + parse_str( $ppom_encoded, $ppom_decoded); + $_REQUEST['ppom'] = $ppom_decoded; + } + global $wpdb; extract( $_REQUEST ); @@ -450,6 +456,12 @@ function ppom_admin_update_form_meta() { } global $wpdb; + if ( is_string( $_REQUEST['ppom'] ) ) { + $ppom_encoded = $_REQUEST['ppom']; + parse_str( $ppom_encoded, $ppom_decoded); + $_REQUEST['ppom'] = $ppom_decoded; + } + $ppom_meta = isset( $_REQUEST['ppom_meta'] ) ? $_REQUEST['ppom_meta'] : $_REQUEST['ppom']; $product_meta = apply_filters( 'ppom_meta_data_saving', (array) $ppom_meta, $productmeta_id ); $product_meta = ppom_sanitize_array_data( $product_meta ); diff --git a/js/admin/ppom-admin.js b/js/admin/ppom-admin.js index fa1ffda..f2ec00c 100644 --- a/js/admin/ppom-admin.js +++ b/js/admin/ppom-admin.js @@ -128,10 +128,24 @@ jQuery(function($) { jQuery(".ppom-meta-save-notice").html('').show(); $('.ppom-unsave-data').remove(); + + const formData = new FormData(); + const ppomFields = new URLSearchParams(); + + // NOTE: since the request is to big for small values of `max_input_vars`, we will send the PPOM fields as a single string. + (new FormData(this)).forEach(( value, key) => { + if ( key.startsWith('ppom[') && typeof value === 'string' ) { + ppomFields.append( key, value ); + } else { + formData.append(key, value); + } + }); + + formData.append('ppom', ppomFields.toString()); fetch(ajaxurl, { method: 'POST', - body: new FormData(this) + body: formData }) .then(response => response.json()) .then(resp => {