This code enables you to get all shipping zones including the default zone for the rest of the world.
$custom_zones = WC_Shipping_Zones::get_zones();
$default_zone = array(array('zone_id' => 0));
$all_zones = array_merge($custom_zones, $default_zone);
foreach ( $all_zones as $zone ) {
$zone_id = isset($zone['zone_id']) ? $zone['zone_id'] : '';
The code uses foreach to loop through the array of shipping zones.
In this example, we only get the $zone[‘zone_id’] however you can get the name and all other data you need to do what you want.
Related
- Get Shipping Zone Data for Coding in WooCommerce
- How To Setup United States Shipping States For No Shipping
Was this helpful?
Thanks for your feedback!

Leave a Reply
You must be logged in to post a comment.