WC_Shipping_Zone::clear_locations()publicWC 1.0

Clear all locations for this zone.

Method of the class: WC_Shipping_Zone{}

No Hooks.

Return

null. Nothing (null).

Usage

$WC_Shipping_Zone = new WC_Shipping_Zone();
$WC_Shipping_Zone->clear_locations( $types, fooo, foooo, fooooo ) );
$types(array|string)
of location to clear.
Default: array( foo
fooo (required)
-
foooo (required)
-
fooooo ) (required)
-

WC_Shipping_Zone::clear_locations() code WC 9.4.2

public function clear_locations( $types = array( 'postcode', 'state', 'country', 'continent' ) ) {
	if ( ! is_array( $types ) ) {
		$types = array( $types );
	}
	$zone_locations = $this->get_prop( 'zone_locations', 'edit' );
	foreach ( $zone_locations as $key => $values ) {
		if ( in_array( $values->type, $types, true ) ) {
			unset( $zone_locations[ $key ] );
		}
	}
	$zone_locations = array_values( $zone_locations ); // reindex.
	$this->set_prop( 'zone_locations', $zone_locations );
}