After saving attributes check that empty attributes are not disabled in the dropdown.

This commit is contained in:
Gerhard Potgieter 2018-09-26 12:25:34 +02:00
parent 6e8f995426
commit f637cf3005
1 changed files with 10 additions and 2 deletions

View File

@ -446,11 +446,11 @@ jQuery( function( $ ) {
opacity: 0.6
}
});
var original_data = $( '.product_attributes' ).find( 'input, select, textarea' );
var data = {
post_id : woocommerce_admin_meta_boxes.post_id,
product_type: $( '#product-type' ).val(),
data : $( '.product_attributes' ).find( 'input, select, textarea' ).serialize(),
data : original_data.serialize(),
action : 'woocommerce_save_attributes',
security : woocommerce_admin_meta_boxes.save_attributes_nonce
};
@ -464,6 +464,14 @@ jQuery( function( $ ) {
$( '.product_attributes' ).html( response.data.html );
$( '.product_attributes' ).unblock();
// Make sure the dropdown is not disabled for empty value attributes.
var nr_elements = original_data.length / 6;
for ( i = 0; i < nr_elements; i++ ) {
if ( typeof( original_data ) != "undefined" && original_data[ i * 6 + 2 ].value === "" ) {
$( 'select.attribute_taxonomy' ).find( 'option[value="' + original_data[ i * 6 ].value + '"]' ).removeAttr( 'disabled' );
}
}
// Reload variations panel.
var this_page = window.location.toString();
this_page = this_page.replace( 'post-new.php?', 'post.php?post=' + woocommerce_admin_meta_boxes.post_id + '&action=edit&' );