WC_Shipping_Zone::clear_locations( array|string $types = array('postcode', 'state', 'country', 'continent') )
Clear all locations for this zone.
Description Description
Parameters Parameters
- $types
-
(Optional) of location to clear.
Default value: array('postcode', 'state', 'country', 'continent')
Source Source
File: includes/class-wc-shipping-zone.php
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 );
}