City and district dropdowns for WooCommerce checkout in Egypt
WooCommerce ships with a list of Egypt’s governorates, but delivery in Egypt works at a smaller level: the city and the district. When customers type their area as free text, the courier and the ERP get addresses they can’t match, and shipping prices can come out wrong. For an e-commerce store I’ve worked on, I built a checkout plugin that replaces free text with real dropdowns.
The problem
- Customers wrote the same area in many ways, in Arabic and English, with different spellings.
- The courier’s system and the ERP need exact names to create a shipment.
- Shipping prices depend on the zone, and the zone depends on a clean location.
- Different parts of the system used different governorate codes. The checkout sent short codes like
CorAL, while the shipping zones expected WooCommerce codes likeEG:EGC.
What I built
- City → District dropdowns generated from the courier’s official location list: 28 cities and about 3,600 districts, so every district name matches the courier’s system exactly.
- Validation: checkout can’t be completed without a valid country, city and district.
- Code translation: the plugin maps the checkout’s codes to the codes the shipping zones use, so each order gets the right zone and price. I also added the North Coast as its own location, because it is a separate delivery area.
- Order data for operations: the city and district are saved on the order in a structured way, ready for the ERP and the courier.
I tested it on the staging site against the real shipping zones: Cairo, Giza and Alexandria at one rate, the Delta and Canal cities at another, and Upper Egypt, Sinai and the North Coast at a third.
What I learned along the way
The first version showed “There are no shipping options available” for every governorate on staging. The district dropdowns worked fine. The real cause was in the shipping setup: a general “Egypt” zone created by the first version caught every order before the specific zones could, and the codes didn’t match. Finding that meant reading the zone order and the codes, not rewriting the dropdowns. The lesson: on WooCommerce, always check the shipping zones and their order before blaming the checkout code.
Why a checkout plugin is a marketing tool
- Fewer abandoned checkouts. Choosing from a list is faster than typing an address, especially on mobile.
- Correct shipping prices. Customers see the right delivery cost before they pay, which avoids surprises and complaints.
- Fewer failed deliveries. With cash on delivery, a parcel that can’t be delivered is lost revenue plus the shipping cost.
- Location data you can use. Clean city and district data allows sales reports by area and campaigns targeted to the places where customers actually order.
FAQ
Can WooCommerce show cities and districts for Egypt?
Not by default. WooCommerce only has the governorates. You need a plugin or custom code that adds city and district fields and validates them.
Can shipping prices depend on the district?
Yes. Districts can be mapped to shipping zones, so each area gets the right rate. Make sure the codes used at checkout match the codes in your zones.
Where should the district list come from?
Ideally from your courier’s own location list, so the names match their system exactly and shipments can be created without manual fixes.