🎉 Black Friday Month Deal: Save 20% on Premium Bundles! Create Unlimited Shipping Scenarios with ease. Don’t hesitate—offer ends November 30th 🚀  Learn more →

How to add a United Arab Emirates city in WooCommerce?

How to add a United Arab Emirates city in WooCommerce
Author Bartosz Gajewski
Updated:
2020-11-23
Reading time:
2 minutes read

WooCommerce is a great solution for online shops but has its limitations. Shipping based on shipping zones and postcodes works well in most countries. But what if a country doesn’t have postcodes? In this article, you will learn how to add a United Arab Emirates city in WooCommerce.

The United Arab Emirates has no system of postal codes. Instead, they use registered PO Boxes, which are assigned individually. Other Gulf and Middle East countries also follow the same system. Shipping in WooCommerce is mainly based on postcodes, so shipping to individual cities in the UAE can be very problematic. Yes, in WooCommerce there is an option to choose the United Arab Emirates as a separate shipping zone. But what if the cost of shipping is different for different regions or cities? The best option is to add them yourself.

Would you like to find out more about shipping zones in WooCommerce – check out our ultimate guide

How to add a United Arab Emirates city in WooCommerce?

This is not about interfering with the WooCommerce code. The only thing that’s WooCommerce included is Countries and states/provinces for some countries. So we will use states to add cities. Especially since WooCommerce provides a filter named woocommerce_states that we can use.

All you have to do is to add a special code in the theme’s functions.php file or use an additional plugin like Code Snippets. Here’s an example code,  which I will cover in detail.

Basically, that code adds new states to WooCommerce. In my example, these are the biggest cities in the United Arab Emirates. You can also add new cities, just by adding new states. If you want to add Al Ain, just add a 'AA' => __( 'Al Ain', 'woocommerce' ) inside $states array.

How does it work?

It will add new states to the United Arab Emirates. This way, if you’ll go to WooCommerce > Settings > Shipping and add a new Shipping Zone, you will be able to select cities as a shipping zone.

United Arab Emirates cities in WooCommerce

The same will happen for your clients. On the checkout page or shopping cart, they will be able to select United Arab Emirates cities in the State / County dropdown field.

United Arab Emirates cities in the checkout page

Examples of usage

WooCommerce shipping to Dubai

If you want to offer shipping to only one city, like Dubai, you can add a Shipping Zone restricted to only that one city.

WooCommerce shipping to Dubai

Different shipping cost for each city

If you want to offer different shipping fees for each city, you can do it in two ways. First, you can add a separate shipping zone for each city and add a shipping method with a different fee inside all the zones. The second and much more convenient way is to use the Flexible Shipping Locations Add-on. It will allow you to configure it all in one shipping method.

United Arab Emirates cities in WooCommerce with Flexible Shipping Locations

Flexible Shipping Locations WooCommerce
€39.00

Extend Flexible Shipping with custom locations and create shipping costs based on weight, order totals or item count.

View Details or Add to cart
Plugins used by 245,546+ shops
30-day money back guarantee
Last Updated: 2024-11-18
Works with WooCommerce 9.1 - 9.5.x
Comments
Subscribe
Notify of
guest
8 Comments
Inline Feedbacks
View all comments
Ta2Ta2
Ta2Ta2
3 years ago

Thanks for the this snippet! it really helps!

However, some areas within UAE cities requires separate shipping fees. For an example:

City: Dubai
Dubai – Hatta to be 100
Dubai – Dubai Marina to be 10

How is that going to be achieved?

Ɓukasz Spryszak
Ɓukasz Spryszak
Reply to  Ta2Ta2
3 years ago

Hi Ta2Ta2, have you tried simply adding these areas as the separate locations the same way it was done in the snippet above?

Rashmi
Rashmi
1 year ago

Thanks for this, it really helped!

Last edited 1 year ago by Rashmi
Ɓukasz Spryszak
Ɓukasz Spryszak
Admin
Reply to  Rashmi
1 year ago

You’re welcome! It’s great to hear that you find it helpful.

SHAHNAS UMMAR PATTANATHEL
SHAHNAS UMMAR PATTANATHEL
10 months ago

Thanks for the this snippet! it really helps!

Ɓukasz Spryszak
Ɓukasz Spryszak
Admin
Reply to  SHAHNAS UMMAR PATTANATHEL
10 months ago

You’re welcome : ) It’s great to hear that it helped in your case.

Abdullah Qureshi
Abdullah Qureshi
9 months ago

Is this Php code snippet ?

Ɓukasz Spryszak
Ɓukasz Spryszak
Admin
Reply to  Abdullah Qureshi
8 months ago

Yes, it is.