×
Black Friday Savings
00Days
:
05Hours
:
42Minutes
:
30Seconds
Use Coupon 40%OFF

Includes 1 Year Priority Support

Shop Now

WP SITES

3093 Coded Tutorials & 296 Plugins

Get All WooCommerce Shipping Zones

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.

Was this helpful?

Yes
No
Thanks for your feedback!

Leave a Reply