In this post, I want to show you how to get current WooCommerce shipping zone using a simple code snippet that we will test and prove it works and will work for you! Before I share the WooCommerce get current shipping zone code snippet, it helps to give a quick overview about WooCommerce shipping zones.
Table of Contents
WooCommerce Get Current Shipping Zone
First, you need to ensure the shipping zones are set up in the WooCommerce settings page as shown on the image below:
When the shipping zone is already set we can now go ahead and test our code snippet we see how it works!
How to Get Current Shipping Zone in WooCommerce
We can get the current shipping zone by using the WC Shipping Zone class and getting the package that contains all the details of the shipping zone in WooCommerce.
The following is a simple code snippet that we need to get the current shipping zone object and the second line to extract the current shipping zone name:
[php]
$current_shipping_zone = WC_Shipping_Zones::get_zone_matching_package( $package );
$zone_name=$shipping_zone->get_zone_name();
[/php]
We can now add this snippet to our test site to see how it works.
Get Current WooCommerce Shipping Zone and Display on Header
For demonstration, I will add this code snippet to the head action hook so that we can test and see how you can easily get the shipping zone.
The following is the full code snippet with the code above inside the action hook to the header to display the current WooCommerce Shipping zone:
[php]
//WooCommerce Get Current Shipping Zone
add_action(‘wp_head’, ‘get_current_shipping_zone’);
function get_current_shipping_zone(){
$current_shipping_zone = WC_Shipping_Zones::get_zone_matching_package( $package );
$current_shipping_zone_name= $current_shipping_zone ->get_zone_name();
print(‘<pre>’);
print_r( $current_shipping_zone_name);
print(‘</pre>’);
}
[/php]
When you add this code to the test theme you should see the shipping zone is displayed on the header as shown on the image below:
Conclusion
In this post, I have outlined how you can get the current WooCommerce shipping zone using the code snippet I shared.
The most important take from this tutorial is how to make use of the WC Shipping Zone class that helps us get the current WooCommerce shipping zones using the $package parameter.

Joe is an experienced full-stack web developer with a decade of industry experience in the LAMP & MERN stacks, WordPress, WooCommerce, and JavaScript – (diverse portfolio). He has a passion for creating elegant and user-friendly solutions and thrives in collaborative environments. In his spare time, he enjoys exploring new tech trends, tinkering with new tools, and contributing to open-source projects. You can hire me here for your next project.
More articles written by Joe
Similar Articles
- How to Remove Category from Product Page WooCommerce
- How to Disable Shipping By Category In WooCommerce
- How to Change Currency Symbol In WooCommerce
- How to Customize WooCommerce Currency [Code Snippets]
- How to Get Current Product ID WooCommerce
- How to Add WooCommerce Registration Email Verification
- How to Change Coupon Code Placeholder WooCommerce
- How to Set Up WooCommerce Buy One Get One
- How to Create Number Pagination in WordPress Without Using Plugin
- How to Add View Cart Button In WooCommerce
- How to Add Custom Add to Cart Button In WooCommerce
- How to Install Facebook Pixel on WooCommerce
- How to Get WooCommerce Current Order ID from URL
- How to Get Current WooCommerce Product Category
- How to Create WooCommerce Redirect After Checkout Per Product
- How to Add Wishlist In WooCommerce
- How to Translate WooCommerce Checkout Page