WC_Shipping_Zone::add_location()publicWC 1.0

Add location (state or postcode) to a zone.

Метод класса: WC_Shipping_Zone{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$WC_Shipping_Zone = new WC_Shipping_Zone();
$WC_Shipping_Zone->add_location( $code, $type );
$code(строка) (обязательный)
Location code.
$type(строка) (обязательный)
state or postcode.

Код WC_Shipping_Zone::add_location() WC 8.7.0

public function add_location( $code, $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.
		}
		$location         = array(
			'code' => wc_clean( $code ),
			'type' => wc_clean( $type ),
		);
		$zone_locations   = $this->get_prop( 'zone_locations', 'edit' );
		$zone_locations[] = (object) $location;
		$this->set_prop( 'zone_locations', $zone_locations );
	}
}