WC_Shipping_Zones::get_zones()
Get shipping zones from the database.
Method of the class: WC_Shipping_Zones{}
No Hooks.
Return
Array
. Array of arrays.
Usage
$result = WC_Shipping_Zones::get_zones( $context );
- $context(string)
- Getting shipping methods for what context. Valid values, admin, json.
Default: 'admin'
Changelog
Since 2.6.0 | Introduced. |
WC_Shipping_Zones::get_zones() WC Shipping Zones::get zones code WC 9.3.1
public static function get_zones( $context = 'admin' ) { $data_store = WC_Data_Store::load( 'shipping-zone' ); $raw_zones = $data_store->get_zones(); $zones = array(); foreach ( $raw_zones as $raw_zone ) { $zone = new WC_Shipping_Zone( $raw_zone ); $zones[ $zone->get_id() ] = $zone->get_data(); $zones[ $zone->get_id() ]['zone_id'] = $zone->get_id(); $zones[ $zone->get_id() ]['formatted_zone_location'] = $zone->get_formatted_location(); $zones[ $zone->get_id() ]['shipping_methods'] = $zone->get_shipping_methods( false, $context ); } return $zones; }