Improved performance when saving variations

The serializeJSON function was causing a long delay when preparing the JSON if there are many input fields within the variations (even worse if 3rd party plugins add their own extra fields there too).
This commit is contained in:
Salva Machí 2020-01-10 11:38:38 +01:00
parent dbb8ab8d1e
commit 37d7d498ec
1 changed files with 7 additions and 2 deletions

View File

@ -447,8 +447,13 @@ jQuery( function( $ ) {
* @return {Object}
*/
get_variations_fields: function( fields ) {
var data = $( ':input', fields ).serializeJSON();
var data = {};
$( ':input', fields ).each( function(index, elem) {
data[elem.name] = elem.value;
});
$( '.variations-defaults select' ).each( function( index, element ) {
var select = $( element );
data[ select.attr( 'name' ) ] = select.val();