Skip to content

Commit dc3925b

Browse files
fix: experimental solution
1 parent 775835d commit dc3925b

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

inc/admin.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,12 @@ function ppom_admin_save_form_meta() {
283283
$aviary_api_key = 'NA';
284284
$show_cart_thumb = 'NA';
285285

286+
if ( is_string( $_REQUEST['ppom'] ) ) {
287+
$ppom_encoded = $_REQUEST['ppom'];
288+
parse_str( $ppom_encoded, $ppom_decoded);
289+
$_REQUEST['ppom'] = $ppom_decoded['ppom'];
290+
}
291+
286292
$ppom_meta = ( isset($_REQUEST['ppom_meta']) ? $_REQUEST['ppom_meta'] : isset($_REQUEST['ppom']) ) ? $_REQUEST['ppom'] : '';
287293

288294
if ( empty( $ppom_meta ) ) {
@@ -356,6 +362,11 @@ function( $pm ) {
356362

357363

358364
$ppom_id = $wpdb->insert_id;
365+
if ( is_string( $ppom ) ) {
366+
$ppom_encoded = $ppom;
367+
parse_str( $ppom_encoded, $ppom_decoded);
368+
$ppom = $ppom_decoded['ppom'];
369+
}
359370

360371
$product_meta = apply_filters( 'ppom_meta_data_saving', (array) $ppom, $ppom_id );
361372
$product_meta = ppom_sanitize_array_data( $product_meta );
@@ -450,6 +461,12 @@ function ppom_admin_update_form_meta() {
450461
}
451462
global $wpdb;
452463

464+
if ( is_string( $_REQUEST['ppom'] ) ) {
465+
$ppom_encoded = $_REQUEST['ppom'];
466+
parse_str( $ppom_encoded, $ppom_decoded);
467+
$_REQUEST['ppom'] = $ppom_decoded['ppom'];
468+
}
469+
453470
$ppom_meta = isset( $_REQUEST['ppom_meta'] ) ? $_REQUEST['ppom_meta'] : $_REQUEST['ppom'];
454471
$product_meta = apply_filters( 'ppom_meta_data_saving', (array) $ppom_meta, $productmeta_id );
455472
$product_meta = ppom_sanitize_array_data( $product_meta );

js/admin/ppom-admin.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,24 @@ jQuery(function($) {
128128
jQuery(".ppom-meta-save-notice").html('<img src="' + ppom_vars.loader + '">').show();
129129

130130
$('.ppom-unsave-data').remove();
131+
132+
const formData = new FormData();
133+
const ppomFields = new URLSearchParams();
134+
135+
// NOTE: since the request is to big for small values of `max_input_vars`, we will send the PPOM fields as a single string.
136+
(new FormData(this)).forEach(( value, key) => {
137+
if ( key.startsWith('ppom[') && typeof value === 'string' ) {
138+
ppomFields.append( key, value );
139+
} else {
140+
formData.append(key, value);
141+
}
142+
});
143+
144+
formData.append('ppom', ppomFields.toString());
131145

132146
fetch(ajaxurl, {
133147
method: 'POST',
134-
body: new FormData(this)
148+
body: formData
135149
})
136150
.then(response => response.json())
137151
.then(resp => {

0 commit comments

Comments
 (0)