Prevent zone 0 having locations set in CRUD

This commit is contained in:
Mike Jolley 2017-05-22 15:19:15 +01:00
parent 8cba7db7cd
commit b1bf3278a7
1 changed files with 4 additions and 2 deletions

View File

@ -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.
}