WordPress at Your Fingertips
function is not described

WC_Shipping_Zone::add_location() public WC 1.0

Add location (state or postcode) to a zone.

{} It's a method of the class: WC_Shipping_Zone{}

No Hooks.

Return

null. Nothing.

Usage

$WC_Shipping_Zone = new WC_Shipping_Zone();
$WC_Shipping_Zone->add_location( $code, $type );
$code(string) (required)
Location code.
$type(string) (required)
state or postcode.

Code of WC_Shipping_Zone::add_location() WC 5.6.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 );
	}
}