Merge pull request #32828 from woocommerce/fix/32016-shipping-zones-loop

Allow removal of all zone regions from a shipping zone
This commit is contained in:
Vedanshu Jain 2022-05-09 14:25:39 +05:30 committed by GitHub
commit 1e090c3c3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Allow removal of all zone regions from a shipping zone

View File

@ -34,11 +34,17 @@
this.trigger( 'change:methods' );
},
save: function() {
// Special handling for an empty 'zone_locations' array, which jQuery filters out during $.post().
var changes = _.clone( this.changes );
if ( _.has( changes, 'zone_locations' ) && _.isEmpty( changes.zone_locations ) ) {
changes.zone_locations = [''];
}
$.post(
ajaxurl + ( ajaxurl.indexOf( '?' ) > 0 ? '&' : '?' ) + 'action=woocommerce_shipping_zone_methods_save_changes',
{
wc_shipping_zones_nonce : data.wc_shipping_zones_nonce,
changes : this.changes,
changes : changes,
zone_id : data.zone_id
},
this.onSaveResponse,