Prevent zone 0 having locations set in CRUD
This commit is contained in:
parent
8cba7db7cd
commit
b1bf3278a7
|
@ -229,7 +229,9 @@ class WC_Shipping_Zone extends WC_Legacy_Shipping_Zone {
|
||||||
* @param array
|
* @param array
|
||||||
*/
|
*/
|
||||||
public function set_zone_locations( $locations ) {
|
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
|
* @param string $type state or postcode
|
||||||
*/
|
*/
|
||||||
public function add_location( $code, $type ) {
|
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 ) {
|
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.
|
$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