Merge pull request #15211 from woocommerce/fix/15002
Zones API changes for zone 0
This commit is contained in:
commit
700460d925
|
@ -86,6 +86,10 @@ class WC_REST_Shipping_Zone_Locations_Controller extends WC_REST_Shipping_Zones_
|
|||
return $zone;
|
||||
}
|
||||
|
||||
if ( 0 === $zone->get_id() ) {
|
||||
return new WP_Error( "woocommerce_rest_shipping_zone_locations_invalid_zone", __( 'The "rest of the world" zone cannot be updated.', 'woocommerce' ), array( 'status' => 403 ) );
|
||||
}
|
||||
|
||||
$raw_locations = $request->get_json_params();
|
||||
$locations = array();
|
||||
|
||||
|
|
|
@ -166,6 +166,10 @@ class WC_REST_Shipping_Zones_Controller extends WC_REST_Shipping_Zones_Controlle
|
|||
return $zone;
|
||||
}
|
||||
|
||||
if ( 0 === $zone->get_id() ) {
|
||||
return new WP_Error( "woocommerce_rest_shipping_zone_invalid_zone", __( 'The "rest of the world" zone cannot be updated.', 'woocommerce' ), array( 'status' => 403 ) );
|
||||
}
|
||||
|
||||
$zone_changed = false;
|
||||
|
||||
if ( ! is_null( $request->get_param( 'name' ) ) ) {
|
||||
|
|
|
@ -229,7 +229,9 @@ class WC_Shipping_Zone extends WC_Legacy_Shipping_Zone {
|
|||
* @param array
|
||||
*/
|
||||
public function set_zone_locations( $locations ) {
|
||||
$this->set_prop( 'zone_locations', $locations );
|
||||
if ( 0 !== $this->get_id() ) {
|
||||
$this->set_prop( 'zone_locations', $locations );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -332,7 +334,7 @@ class WC_Shipping_Zone extends WC_Legacy_Shipping_Zone {
|
|||
* @param string $type state or postcode
|
||||
*/
|
||||
public function add_location( $code, $type ) {
|
||||
if ( $this->is_valid_location_type( $type ) ) {
|
||||
if ( 0 !== $this->get_id() && $this->is_valid_location_type( $type ) ) {
|
||||
if ( 'postcode' === $type ) {
|
||||
$code = trim( strtoupper( str_replace( chr( 226 ) . chr( 128 ) . chr( 166 ), '...', $code ) ) ); // No normalization - postcodes are matched against both normal and formatted versions to support wildcards.
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue