You can get all shipping zones and rates in WooCommerce by loading the shipping zone data store directly, looping through each WC_Shipping_Zone object, and then iterating its shipping methods to access cost, taxability, and enabled status for every configured rate.
Why You’d Need to Loop Through Zones Programmatically
- Custom shipping calculators or estimators on the product or cart page need direct access to zone/rate data
- Auditing or exporting your full shipping configuration is easier through code than clicking through each zone in wp-admin
- Custom reports or dashboards showing shipping coverage need this data structured programmatically
Step 1: Get All Shipping Zones (Including “Rest of the World”)
/** Return every shipping zone, including the default "Rest of the World" zone */
function get_all_woocommerce_shipping_zones() {
$data_store = WC_Data_Store::load( 'shipping-zone' );
$raw_zones = $data_store->get_zones();
$zones = array();
foreach ( $raw_zones as $raw_zone ) {
$zones[] = new WC_Shipping_Zone( $raw_zone );
}
$zones[] = new WC_Shipping_Zone( 0 ); // the catch-all zone
return $zones;
}Step 2: Loop Through Each Zone’s Shipping Methods
/** Return every configured shipping rate across all zones */
function get_all_woocommerce_shipping_rates() {
$rates = array();
foreach ( get_all_woocommerce_shipping_zones() as $zone ) {
foreach ( $zone->get_shipping_methods() as $method ) {
$rates[] = array(
'zone_name' => $zone->get_zone_name(),
'title' => $method->title,
'enabled' => $method->is_enabled(),
'taxable' => $method->is_taxable(),
);
}
}
return $rates;
}
Troubleshooting
The “Rest of the World” zone is missing from results
That zone isn’t returned by the data store’s get_zones() call by default — it needs to be manually appended with new WC_Shipping_Zone( 0 ), as shown above.
Disabled shipping methods still appear in the results
Check is_enabled() on each method and filter accordingly if you only want active, customer-facing rates rather than every configured method regardless of status.
Frequently Asked Questions
Can I get the actual cost value for each shipping method?
Yes, access $method->instance_settings['cost'] for flat-rate style methods, though the exact settings key varies by shipping method type.
Does this reflect real-time calculated rates or just configured base rates?
These are the configured base settings — actual calculated rates at checkout can differ based on cart weight, totals, and any dynamic pricing rules the method applies.
Is this safe to run on every page load?
For a small number of zones, yes — for many zones, consider caching the result with a transient rather than recalculating on every request.
Cache the computed zone and rate list with a transient if you’re calling this on every page load, since re-querying the shipping zone data store on every single request adds unnecessary overhead once you have more than a handful of zones configured.
Conclusion
The shipping zone data store combined with each zone’s get_shipping_methods() call is how you get all shipping zones and rates in WooCommerce programmatically, whether for a custom calculator or an internal audit.
See also How to Show Shipping Rates on the WooCommerce Single Product Page. Then read How to Hide Other Shipping Rates When Free Shipping Is Available in WooCommerce.
Prefer no code? All-in-One Utilities Woo Add-on adds over 50 WooCommerce features, so you can switch them on without code.