đ Black Friday Month Deal: Save 20% on Premium Bundles! Create Unlimited Shipping Scenarios with ease. Don’t hesitateâoffer ends November 30th đ Â Learn more â
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.
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.
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.
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.
If you want to offer shipping to only one city, like Dubai, you can add a Shipping Zone restricted to only that one 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.
Extend Flexible Shipping with custom locations and create shipping costs based on weight, order totals or item count.
View Details or Add to cart
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?
Hi Ta2Ta2, have you tried simply adding these areas as the separate locations the same way it was done in the snippet above?
Thanks for this, it really helped!
You’re welcome! It’s great to hear that you find it helpful.
Thanks for the this snippet! it really helps!
You’re welcome : ) It’s great to hear that it helped in your case.
Is this Php code snippet ?
Yes, it is.