Posts

WooCommerce Country Codes: Essential Guide for E-commerce Stores

If you’re running an online store with WooCommerce, you’ve probably encountered country codes. But what exactly are they? Simply put, a country code is a short, standardised abbreviation (usually two letters) that represents a specific country, like US for the United States or GB for Great Britain. WooCommerce uses these codes behind the scenes to identify where your customers are from, which helps it calculate shipping costs, taxes, and even the checkout options that appear during a purchase. These country codes make it easier for your store to handle international orders smoothly without confusion or errors.

WooCommerce is one of the leading e-commerce platforms, loved for its flexibility and powerful features that support selling worldwide. Thanks to the use of country codes, it lets you set up shipping zones, tax rules, and payment methods tailored precisely to different countries and regions. This means you can offer your customers accurate prices and shipping times no matter where they live.

Alongside country codes, WooCommerce also uses state or region codes, which work the same way but at a more detailed level. For example, in the US or Canada, different states or provinces may have different tax rates or shipping rules, and these codes help WooCommerce handle those details properly.

In this guide, you’ll learn everything about WooCommerce country codes: what they are, how to use them, and why they’re so important for running a smooth, professional online store that sells internationally.

What Are WooCommerce Country Codes?

WooCommerce Country Codes

When managing an online store with WooCommerce, country codes play an essential role in organising your sales and shipping across different countries. At their core, country codes are short, standardised abbreviations that represent countries worldwide. WooCommerce uses the internationally recognised ISO 3166-1 alpha-2 standard for these codes, which consists of two capital letters—such as GB for the United Kingdom, FR for France, and DE for Germany.

These codes are more than just labels. WooCommerce relies on them internally to:

  • Identify the country of a customer during checkout
  • Apply the correct shipping zones and rates based on location
  • Calculate taxes accurately according to local laws
  • Tailor payment gateways and currency options for specific countries

Understanding the difference between country codes and state codes is also important. While country codes represent entire nations, state codes (or region codes) refer to subdivisions within those countries. For example, in the United States, US is the country code, while CA stands for California, a state within the US. Similarly, in Canada, CA is the country code, and ON is the code for Ontario. WooCommerce uses both to allow store owners to set precise shipping rules or tax rates that may differ between states, provinces, or regions.

Why Accurate Country Codes Matter

Using accurate country codes is crucial for your store’s smooth operation and customer satisfaction. Here’s why:

  • Shipping Precision: Shipping costs and options often vary from country to country. Correct codes ensure customers see only the relevant shipping methods and prices.
  • Tax Compliance: Different countries—and even regions within countries—have distinct tax laws. Accurate codes help your store apply the right tax rates, avoiding legal complications.
  • Improved User Experience: When country codes are correctly set, customers get tailored checkout options like preferred currencies or local payment gateways, making purchases faster and easier.
  • Avoid Order Errors: Mistakes in country codes can lead to failed orders, incorrect shipping, or delays, which harm your reputation and increase costs.

In short, country codes are the backbone of WooCommerce’s international functionality. Ensuring they are set up properly helps you manage your global store efficiently, keeps customers happy, and keeps your business compliant with different country regulations.

List of Supported WooCommerce Country Codes

WooCommerce supports a comprehensive set of country codes based on the ISO 3166-1 alpha-2 standard. These two-letter codes allow WooCommerce to precisely identify countries for shipping, taxes, and checkout processes. Having a clear, up-to-date list of supported country codes is essential for store owners, especially those selling internationally.

Below is an alphabetised table of WooCommerce-supported country codes and their corresponding countries. This list forms the basis for WooCommerce’s shipping zones, tax calculations, and more.

Country CodeCountry NameCountry CodeCountry Name
AEUnited Arab EmiratesMDMoldova
AFAfghanistanMEMontenegro
AGAntigua and BarbudaMGMadagascar
AIAnguillaMKNorth Macedonia
ALAlbaniaMLMali
AMArmeniaMMMyanmar
AOAngolaMNMongolia
ARArgentinaMOMacau
ASAmerican SamoaMRMauritania
ATAustriaMSMontserrat
AUAustraliaMTMalta
AWArubaMUMauritius
AXÅland IslandsMVMaldives
AZAzerbaijanMWMalawi
BABosnia and HerzegovinaMXMexico
BBBarbadosMYMalaysia
BDBangladeshMZMozambique
BEBelgiumNANamibia
BFBurkina FasoNCNew Caledonia
BGBulgariaNENiger
BHBahrainNFNorfolk Island
BIBurundiNGNigeria
BJBeninNINicaragua
BLSaint BarthélemyNLNetherlands
BMBermudaNONorway
BNBruneiNPNepal
BOBoliviaNRNauru
BQBonaire, Sint Eustatius, and SabaNUNiue
BRBrazilNZNew Zealand
BSBahamasOMOman
BTBhutanPAPanama
BVBouvet IslandPEPeru
BWBotswanaPFFrench Polynesia
BYBelarusPGPapua New Guinea
BZBelizePHPhilippines
CACanadaPKPakistan
CCCocos (Keeling) IslandsPLPoland
CDDemocratic Republic of the CongoPMSaint Pierre and Miquelon
CFCentral African RepublicPNPitcairn Islands
CGRepublic of the CongoPRPuerto Rico
CHSwitzerlandPSPalestinian Territories
CICôte d’IvoirePTPortugal
CKCook IslandsPWPalau
CLChilePYParaguay
CMCameroonQAQatar
CNChinaRERéunion
COColombiaRORomania
CRCosta RicaRSSerbia
CUCubaRURussia
CVCape VerdeRWRwanda
CWCuraçaoSASaudi Arabia
CXChristmas IslandSBSolomon Islands
CYCyprusSCSeychelles
CZCzech RepublicSDSudan
DEGermanySESweden
DJDjiboutiSGSingapore
DKDenmarkSHSaint Helena
DMDominicaSISlovenia
DODominican RepublicSJSvalbard and Jan Mayen
DZAlgeriaSKSlovakia
ECEcuadorSLSierra Leone
EEEstoniaSMSan Marino
EGEgyptSNSenegal
EHWestern SaharaSOSomalia
EREritreaSRSuriname
ESSpainSSSouth Sudan
ETEthiopiaSTSão Tomé and Príncipe
FIFinlandSVEl Salvador
FJFijiSXSint Maarten
FMMicronesiaSYSyria
FOFaroe IslandsSZEswatini
FRFranceTCTurks and Caicos Islands
GAGabonTDChad
GBUnited KingdomTFFrench Southern Territories
GDGrenadaTGTogo
GEGeorgiaTHThailand
GFFrench GuianaTJTajikistan
GGGuernseyTKTokelau
GHGhanaTLTimor-Leste
GIGibraltarTMTurkmenistan
GLGreenlandTNTunisia
GMGambiaTOTonga
GNGuineaTRTurkey
GPGuadeloupeTTTrinidad and Tobago
GQEquatorial GuineaTVTuvalu
GRGreeceTZTanzania
GTGuatemalaUAUkraine
GUGuamUGUganda
GWGuinea-BissauUMUnited States Minor Outlying Islands
GYGuyanaUSUnited States
HKHong KongUYUruguay
HMHeard Island and McDonald IslandsUZUzbekistan
HNHondurasVAVatican City
HRCroatiaVCSaint Vincent and the Grenadines
HTHaitiVEVenezuela
HUHungaryVGBritish Virgin Islands
IDIndonesiaVIU.S. Virgin Islands
IEIrelandVNVietnam
ILIsraelVUVanuatu
IMIsle of ManWFWallis and Futuna
INIndiaWSSamoa
IOBritish Indian Ocean TerritoryXKKosovo
IQIraqYEYemen
IRIranYTMayotte
ISIcelandZASouth Africa
ITItalyZMZambia
JEJerseyZWZimbabwe
JMJamaica

How Is This List Maintained and Updated?

WooCommerce regularly updates its country code list to stay aligned with the official ISO 3166-1 alpha-2 standard maintained by the International Organization for Standardization (ISO). Changes can happen if countries rename, merge, split, or new territories are recognised. WooCommerce reflects these updates in their codebase through periodic software updates and patches.

For store owners, this means that keeping WooCommerce up to date will usually ensure your country code list remains current without manual intervention.

How to Access This List Within WooCommerce

If you want to see or work directly with the list of country codes WooCommerce supports, you can access it in several ways:

  • Within WooCommerce Plugin Files: The country codes are stored in a PHP file called countries.php inside the WooCommerce plugin folder (typically found at woocommerce/i18n/countries.php). This file contains an array mapping country codes to country names.
  • Through WooCommerce Settings: In your WordPress admin dashboard, go to WooCommerce > Settings > General > Selling Locations or Shipping Zones. When configuring shipping or tax zones, WooCommerce uses this country code list internally to let you choose which countries or regions you want to target.

Programmatically: If you are developing custom code or plugins, WooCommerce provides functions to retrieve the country list, such as:

php
CopyEdit
WC()->countries->get_countries();

  •  This returns an array of all supported countries and their codes.

WooCommerce State Codes and Their Importance

Just as WooCommerce uses country codes to identify nations, it also relies on state codes to represent subdivisions within those countries—such as states, provinces, regions, or territories. These codes follow the ISO 3166-2 standard, which defines codes for the principal subdivisions of all countries coded in ISO 3166-1.

State codes are crucial in WooCommerce for several reasons:

  • Shipping: Many shipping methods and carriers calculate rates based on specific states or provinces rather than just countries. State codes let WooCommerce assign shipping zones more precisely.
  • Tax Calculations: Tax rates often differ between regions within the same country. For example, sales tax in California differs from Texas. WooCommerce uses state codes to apply accurate tax rules.
  • Checkout and Billing: Correct state codes ensure customers see appropriate options and avoid confusion during checkout.
  • Legal Compliance: Some regulations require storing location data at a regional level, making state codes essential.

Because these subdivisions vary widely across countries, WooCommerce allows you to customise or add state codes based on your target markets.

List of WooCommerce State Codes:-

Albanian (AL) states

CodeStateCodeStateCodeState
AL-01BeratAL-02DurrësAL-03Elbasan
AL-04FierAL-05GjirokastërAL-06Korçë
AL-07KukësAL-08LezhëAL-09Dibër
AL-10ShkodërAL-11TiranaAL-12Vlorë

Angolan (AO) States

CodeStateCodeStateCodeState
BGOBengoBLUBenguelaBIEBié
CABCabindaCNNCuneneHUAHuambo
HUIHuílaCCUKuando KubangoCNOKwanza-Norte
CUSKwanza-SulLUALuandaLNOLunda-Norte
LSULunda-SulMALMalanjeMOXMoxico
NAMNamibeUIGUígeZAIZaire

Argentinian (AR) Provinces

CodeStateCodeStateCodeState
CCiudad Autónoma de Buenos AiresBBuenos AiresKCatamarca
HChacoUChubutXCórdoba
WCorrientesEEntre RíosPFormosa
YJujuyLLa PampaFLa Rioja
MMendozaNMisionesQNeuquén
RRío NegroASaltaJSan Juan
DSan LuisZSanta CruzSSanta Fe
GSantiago del EsteroVTierra del FuegoTTucumán

Australian (AU) States

CodeStateCodeState
ACTAustralian Capital TerritoryNSWNew South Wales
NTNorthern TerritoryQLDQueensland
SASouth AustraliaTASTasmania
VICVictoriaWAWestern Australia

Bangladeshi (BD) Districts

CodeStateCodeStateCodeState
BD-05BagerhatBD-01BandarbanBD-02Barguna
BD-06BarishalBD-07BholaBD-03Bogura
BD-04BrahmanbariaBD-09ChandpurBD-10Chattogram
BD-12ChuadangaBD-11Cox’s BazarBD-08Cumilla
BD-13DhakaBD-14DinajpurBD-15Faridpur
BD-16FeniBD-19GaibandhaBD-18Gazipur
BD-17GopalganjBD-20HabiganjBD-21Jamalpur
BD-22JashoreBD-25JhalokatiBD-23Jhenaidah
BD-24JoypurhatBD-29KhagrachhariBD-27Khulna
BD-26KishoreganjBD-28KurigramBD-30Kushtia
BD-31LakshmipurBD-32LalmonirhatBD-36Madaripur
BD-37MaguraBD-33ManikganjBD-39Meherpur
BD-38MoulvibazarBD-35MunshiganjBD-34Mymensingh
BD-48NaogaonBD-43NarailBD-40Narayanganj
BD-42NarsingdiBD-44NatoreBD-45Nawabganj
BD-41NetrakonaBD-46NilphamariBD-47Noakhali
BD-49PabnaBD-52PanchagarhBD-51Patuakhali
BD-50PirojpurBD-53RajbariBD-54Rajshahi
BD-56RangamatiBD-55RangpurBD-58Satkhira
BD-62ShariatpurBD-57SherpurBD-59Sirajganj
BD-61SunamganjBD-60SylhetBD-63Tangail
BD-64Thakurgaon

Bulgarian (BG) States

CodeStateCodeStateCodeState
BG-01BlagoevgradBG-02BurgaBG-08Dobrich
BG-07GabrovoBG-26HaskovoBG-09Kardzhali
BG-10KyustendilBG-11LovechBG-12Montana
BG-13PazardzhikBG-14PernikBG-15Pleven
BG-16PlovdivBG-17RazgradBG-18Ruse
BG-27ShumenBG-19SilistraBG-20Sliven
BG-21SmolyanBG-23SofiaBG-22Sofia-Grad
BG-24Stara ZagoraBG-25TargovishteBG-03Varna
BG-04Veliko TarnovoBG-05VidinBG-06Vratsa
BG-28Yambol

Beninese (BJ) States

CodeStateCodeStateCodeState
ALAliboriAKAtakoraAQAtlantique
BOBorgouCOCollinesKOKouffo
DODongaLILittoralMOMono
OUOuéméPLPlateauZOZou

Bolivian (BO) States

CodeStateCodeStateCodeState
BO-BBeniBO-HChuquisacaBO-CCochabamba
BO-LLa PazBO-OOruroBO-NPando
BO-PPotosíBO-SSanta CruzBO-TTarija

Brazilian (BR) States

CodeStateCodeStateCodeState
ACAcreALAlagoasAPAmapá
AMAmazonasBABahiaCECeará
DFDistrito FederalESEspírito SantoGOGoiás
MAMaranhãoMTMato GrossoMSMato Grosso do Sul
MGMinas GeraisPAParáPBParaíba
PRParanáPEPernambucoPIPiauí
RJRio de JaneiroRNRio Grande do NorteRSRio Grande do Sul
RORondôniaRRRoraimaSCSanta Catarina
SPSão PauloSESergipeTOTocantins

Canadian (CA) Provinces and Territories

CodeProvince/TerritoryCodeProvince/TerritoryCodeProvince/Territory
ABAlbertaBCBritish ColumbiaMBManitoba
NBNew BrunswickNLNewfoundland and LabradorNTNorthwest Territories
NSNova ScotiaNUNunavutONOntario
PEPrince Edward IslandQCQuebecSKSaskatchewan
YTYukon Territory

Algerian (DZ) States

CodeStateCodeStateCodeState
DZ-01AdrarDZ-02ChlefDZ-03Laghouat
DZ-04Oum El BouaghiDZ-05BatnaDZ-06Béjaïa
DZ-07BiskraDZ-08BécharDZ-09Blida
DZ-10BouiraDZ-11TamanghassetDZ-12Tébessa
DZ-13TlemcenDZ-14TiaretDZ-15Tizi Ouzou
DZ-16AlgiersDZ-17DjelfaDZ-18Jijel
DZ-19SétifDZ-20SaïdaDZ-21Skikda
DZ-22Sidi Bel AbbèsDZ-23AnnabaDZ-24Guelma
DZ-25ConstantineDZ-26MédéaDZ-27Mostaganem
DZ-28M’SilaDZ-29MascaraDZ-30Ouargla
DZ-31OranDZ-32El BayadhDZ-33Illizi
DZ-34Bordj Bou ArréridjDZ-35BoumerdèsDZ-36El Tarf
DZ-37TindoufDZ-38TissemsiltDZ-39El Oued
DZ-40KhenchelaDZ-41Souk AhrasDZ-42Tipasa
DZ-43MilaDZ-44Aïn DeflaDZ-45Naama
DZ-46Aïn TémouchentDZ-47GhardaïaDZ-48Relizane

Ecuadorian (EC) States

CodeStateCodeStateCodeState
EC-AAzuayEC-BBolívarEC-FCañar
EC-CCarchiEC-HChimborazoEC-XCotopaxi
EC-OEl OroEC-EEsmeraldasEC-WGalápagos
EC-GGuayasEC-IImbaburaEC-LLoja
EC-RLos RíosEC-MManabíEC-SMorona-Santiago
EC-NNapoEC-DOrellanaEC-YPastaza
EC-PPichinchaEC-SESanta ElenaEC-SDSanto Domingo de los Tsáchilas
EC-USucumbíosEC-TTungurahuaEC-ZZamora-Chinchipe

Egyptian (EG) States

CodeStateCodeStateCodeState
EGALXAlexandriaEGASNAswanEGASTAsyut
EGBARed SeaEGBHBeheiraEGBNSBeni Suef
EGCCairoEGDKDakahliaEGDTDamietta
EGFYMFaiyumEGGHGharbiaEGGZGiza
EGISIsmailiaEGJSSouth SinaiEGKBQalyubia
EGKFSKafr el-SheikhEGKNQenaEGLXLuxor
EGMNMinyaEGMNFMonufiaEGMTMatrouh
EGPTSPort SaidEGSHGSohagEGSHRAl Sharqia
EGSINNorth SinaiEGSUZSuezEGWADNew Valley

Spanish (ES) States

CodeStateCodeStateCodeState
CA CoruñaVIAraba/ÁlavaABAlbacete
AAlicanteALAlmeríaOAsturias
AVÁvilaBABadajozPMBaleares
BBarcelonaBUBurgosCCCáceres
CACádizSCantabriaCSCastellón
CECeutaCRCiudad RealCOCórdoba
CUCuencaGIGironaGRGranada
GUGuadalajaraSSGipuzkoaHHuelva
HUHuescaJJaénLOLa Rioja
GCLas PalmasLELeónLLleida
LULugoMMadridMAMálaga
MLMelillaMUMurciaNANavarra
OROurensePPalenciaPOPontevedra
SASalamancaTFSanta Cruz de TenerifeSGSegovia
SESevillaSOSoriaTTarragona
TETeruelTOToledoVValencia
VAValladolidBIBiscayZAZamora
ZZaragoza

Ghanaian (GH) Regions

CodeStateCodeStateCodeState
AFAhafoAHAshantiBABrong-Ahafo
BOBonoBEBono EastCPCentral
EPEasternAAGreater AccraNENorth East
NPNorthernOTOtiSVSavannah
UEUpper EastUWUpper WestTVVolta
WPWesternWNWestern North

Greek (GR) Regions

CodeStateCodeStateCodeState
IAtticaAEast Macedonia and ThraceBCentral Macedonia
CWest MacedoniaDEpirusEThessaly
FIonian IslandsGWest GreeceHCentral Greece
JPeloponneseKNorth AegeanLSouth Aegean
MCrete

Guatemalan (GT) States

CodeStateCodeStateCodeState
GT-AVAlta VerapazGT-BVBaja VerapazGT-CMChimaltenango
GT-CQChiquimulaGT-PREl ProgresoGT-ESEscuintla
GT-GUGuatemalaGT-HUHuehuetenangoGT-IZIzabal
GT-JAJalapaGT-JUJutiapaGT-PEPetén
GT-QZQuetzaltenangoGT-QCQuichéGT-RERetalhuleu
GT-SASacatepéquezGT-SMSan MarcosGT-SRSanta Rosa
GT-SOSololáGT-SUSuchitepéquezGT-TOTotonicapán
GT-ZAZacapa

Hong Kong (HK) States

CodeStateCodeStateCodeState
HONG KONGHong Kong IslandKOWLOONKowloonNEW TERRITORIESNew Territories

Honduran (HN) States

CodeStateCodeStateCodeState
HN-ATAtlántidaHN-IBBay IslandsHN-CHCholuteca
HN-CLColónHN-CMComayaguaHN-CPCopán
HN-CRCortésHN-EPEl ParaísoHN-FMFrancisco Morazán
HN-GDGracias a DiosHN-INIntibucáHN-LELempira
HN-LPLa PazHN-OCOcotepequeHN-OLOlancho
HN-SBSanta BárbaraHN-VAValleHN-YOYoro

Hungarian (HU) States

CodeStateCodeStateCodeState
BKBács-KiskunBEBékésBABaranya
BZBorsod-Abaúj-ZemplénBUBudapestCSCsongrád-Csanád
FEFejérGSGyőr-Moson-SopronHBHajdú-Bihar
HEHevesJNJász-Nagykun-SzolnokKEKomárom-Esztergom
NONógrádPEPestSOSomogy
SZSzabolcs-Szatmár-BeregTOTolnaVAVas
VEVeszprémZAZala

Indonesian (ID) Provinces

CodeStateCodeStateCodeState
ACDaerah Istimewa AcehSUSumatera UtaraSBSumatera Barat
RIRiauKRKepulauan RiauJAJambi
SSSumatera SelatanBBBangka BelitungBEBengkulu
LALampungJKDKI JakartaJBJawa Barat
BTBantenJTJawa TengahJIJawa Timur
YODaerah Istimewa YogyakartaBABaliNBNusa Tenggara Barat
NTNusa Tenggara TimurKBKalimantan BaratKTKalimantan Tengah
KIKalimantan TimurKSKalimantan SelatanKUKalimantan Utara
SASulawesi UtaraSTSulawesi TengahSGSulawesi Tenggara
SRSulawesi BaratSNSulawesi SelatanGOGorontalo
MAMalukuMUMaluku UtaraPAPapua
PBPapua Barat

Irish (IE) States

CodeStateCodeStateCodeState
CWCarlowCNCavanCEClare
COCorkDLDonegalDDublin
GGalwayKYKerryKEKildare
KKKilkennyLSLaoisLMLeitrim
LKLimerickLDLongfordLHLouth
MOMayoMHMeathMNMonaghan
OYOffalyRNRoscommonSOSligo
TATipperaryWDWaterfordWHWestmeath
WXWexfordWWWicklow

Indian (IN) States

CodeStateCodeStateCodeState
APAndhra PradeshARArunachal PradeshASAssam
BRBiharCTChhattisgarhGAGoa
GJGujaratHRHaryanaHPHimachal Pradesh
JKJammu and KashmirJHJharkhandKAKarnataka
KLKeralaLALadakhMPMadhya Pradesh
MHMaharashtraMNManipurMLMeghalaya
MZMizoramNLNagalandOROdisha
PBPunjabRJRajasthanSKSikkim
TNTamil NaduTSTelanganaTRTripura
UKUttarakhandUPUttar PradeshWBWest Bengal
ANAndaman and Nicobar IslandsCHChandigarhDNDadra and Nagar Haveli
DDDaman and DiuDLDelhiLDLakshadeep
PYPuducherry

Iranian (IR) States

CodeStateCodeStateCodeState
KHZKhuzestan (خوزستان)THRTehran (تهران)ILMIlaam (ایلام)
BHRBushehr (بوشهر)ADLArdabil (اردبیل)ESFIsfahan (اصفهان)
YZDYazd (یزد)KRHKermanshah (کرمانشاه)KRNKerman (کرمان)
HDNHamadan (همدان)GZNGhazvin (قزوین)ZJNZanjan (زنجان)
LRSLuristan (لرستان)ABZAlborz (البرز)EAZEast Azarbaijan (آذربایجان شرقی)
WAZWest Azarbaijan (آذربایجان غربی)CHBChaharmahal and Bakhtiari (چهارمحال و بختیاری)SKHSouth Khorasan (خراسان جنوبی)
RKHRazavi Khorasan (خراسان رضوی)NKHNorth Khorasan (خراسان شمالی)SMNSemnan (سمنان)
FRSFars (فارس)QHMQom (قم)KRDKurdistan / کردستان)
KBDKohgiluyeh and BoyerAhmad (کهگیلوییه و بویراحمد)GLSGolestan (گلستان)GILGilan (گیلان)
MZNMazandaran (مازندران)MKZMarkazi (مرکزی)HRZHormozgan (هرمزگان)
SBNSistan and Baluchestan (سیستان و بلوچستان)

Italian (IT) Provinces

CodeStateCodeStateCodeState
AGAgrigentoALAlessandriaANAncona
AOAostaARArezzoAPAscoli Piceno
ATAstiAVAvellinoBABari
BTBarletta-Andria-TraniBLBellunoBNBenevento
BGBergamoBIBiellaBOBologna
BZBolzanoBSBresciaBRBrindisi
CACagliariCLCaltanissettaCBCampobasso
CECasertaCTCataniaCZCatanzaro
CHChietiCOComoCSCosenza
CRCremonaKRCrotoneCNCuneo
ENEnnaFMFermoFEFerrara
FIFirenzeFGFoggiaFCForlì-Cesena
FRFrosinoneGEGenovaGOGorizia
GRGrossetoIMImperiaISIsernia
SPLa SpeziaAQL’AquilaLTLatina
LELecceLCLeccoLILivorno
LOLodiLULuccaMCMacerata
MNMantovaMSMassa-CarraraMTMatera
MEMessinaMIMilanoMOModena
MBMonza e della BrianzaNANapoliNONovara
NUNuoroOROristanoPDPadova
PAPalermoPRParmaPVPavia
PGPerugiaPUPesaro e UrbinoPEPescara
PCPiacenzaPIPisaPTPistoia
PNPordenonePZPotenzaPOPrato
RGRagusaRARavennaRCReggio Calabria
REReggio EmiliaRIRietiRNRimini
RMRomaRORovigoSASalerno
SSSassariSVSavonaSISiena
SRSiracusaSOSondrioSUSud Sardegna
TATarantoTETeramoTRTerni
TOTorinoTPTrapaniTNTrento
TVTrevisoTSTriesteUDUdine
VAVareseVEVeneziaVBVerbano-Cusio-Ossola
VCVercelliVRVeronaVVVibo Valentia
VIVicenzaVTViterbo

Amaican (JM) parishes

CodeStateCodeStateCodeState
JM-01KingstonJM-02Saint AndrewJM-03Saint Thomas
JM-04PortlandJM-05Saint MaryJM-06Saint Ann
JM-07TrelawnyJM-08Saint JamesJM-09Hanover
JM-10WestmorelandJM-11Saint ElizabethJM-12Manchester
JM-13ClarendonJM-14Saint Catherine

Japanese (JP) prefectures

CodeStateCodeStateCodeState
JP01HokkaidoJP02AomoriJP03Iwate
JP04MiyagiJP05AkitaJP06Yamagata
JP07FukushimaJP08IbarakiJP09Tochigi
JP10GunmaJP11SaitamaJP12Chiba
JP13TokyoJP14KanagawaJP15Niigata
JP16ToyamaJP17IshikawaJP18Fukui
JP19YamanashiJP20NaganoJP21Gifu
JP22ShizuokaJP23AichiJP24Mie
JP25ShigaJP26KyotoJP27Osaka
JP28HyogoJP29NaraJP30Wakayama
JP31TottoriJP32ShimaneJP33Okayama
JP34HiroshimaJP35YamaguchiJP36Tokushima
JP37KagawaJP38EhimeJP39Kochi
JP40FukuokaJP41SagaJP42Nagasaki
JP43KumamotoJP44OitaJP45Miyazaki
JP46KagoshimaJP47Okinawa

Kenyan (KE) counties

CodeStateCodeStateCodeState
KE01BaringoKE02BometKE03Bungoma
KE04BusiaKE05Elgeyo-MarakwetKE06Embu
KE07GarissaKE08Homa BayKE09Isiolo
KE10KajiadoKE11KakamegaKE12Kericho
KE13KiambuKE14KilifiKE15Kirinyaga
KE16KisiiKE17KisumuKE18Kitui
KE19KwaleKE20LaikipiaKE21Lamu
KE22MachakosKE23MakueniKE24Mandera
KE25MarsabitKE26MeruKE27Migori
KE28MombasaKE29Murang’aKE30Nairobi County
KE31NakuruKE32NandiKE33Narok
KE34NyamiraKE35NyandaruaKE36Nyeri
KE37SamburuKE38SiayaKE39Taita-Taveta
KE40Tana RiverKE41Tharaka-NithiKE42Trans Nzoia
KE43TurkanaKE44Uasin GishuKE45Vihiga
KE46WajirKE47West Pokot

Laotian (LA) provinces

CodeStateCodeStateCodeState
ATAttapeuBKBokeoBLBolikhamsai
CHChampasakHOHouaphanhKHKhammouane
LMLuang NamthaLPLuang PrabangOUOudomxay
PHPhongsalySLSalavanSVSavannakhet
VIVientiane ProvinceVTVientianeXASainyabuli
XESekongXIXiangkhouangXSXaisomboun

Liberian (LR) provinces

CodeStateCodeStateCodeState
BMBomiBNBongGAGbarpolu
GBGrand BassaGCGrand Cape MountGGGrand Gedeh
GKGrand KruLOLofaMAMargibi
MYMarylandMOMontserradoNMNimba
RVRivercessRGRiver GeeSNSinoe

Moldovan (MD) states

CodeStateCodeStateCodeState
CChișinăuBLBălțiANAnenii Noi
BSBasarabeascaBRBriceniCHCahul
CTCantemirCLCălărașiCSCăușeni
CMCimișliaCRCriuleniDNDondușeni
DRDrochiaDBDubăsariEDEdineț
FLFăleștiFRFloreștiGEUTA Găgăuzia
GLGlodeniHNHînceștiILIaloveni
TLTeleneștiUNUngheni

Mexican (MX) states

CodeStateCodeStateCodeState
DFCiudad de MéxicoJAJaliscoNLNuevo León
AGAguascalientesBCBaja CaliforniaBSBaja California Sur
CMCampecheCSChiapasCHChihuahua
COCoahuilaCLColimaDGDurango
GTGuanajuatoGRGuerreroHGHidalgo
MXEstado de MéxicoMIMichoacánMOMorelos
NANayaritOAOaxacaPUPuebla
QTQuerétaroQRQuintana RooSLSan Luis Potosí
SISinaloaSOSonoraTBTabasco
TMTamaulipasTLTlaxcalaVEVeracruz
YUYucatánZAZacatecas

Malaysian (MY) states

CodeStateCodeStateCodeState
JHRJohorKDHKedahKTNKelantan
LBNLabuanMLKMalacca (Melaka)NSNNegeri Sembilan
PHGPahangPNGPenang (Pulau Pinang)PRKPerak
PLSPerlisSBHSabahSWKSarawak
SGRSelangorTRGTerengganuPJYPutrajaya
KULKuala Lumpur

Mozambican (MZ) provinces

CodeStateCodeStateCodeState
MZPCabo DelgadoMZGGazaMZIInhambane
MZBManicaMZLMaputo ProvinceMZMPMMaputo
MZNNampulaMZANiassaMZSSofala
MZTTeteMZQZambézia

Namibian (NA) regions

CodeStateCodeStateCodeState
ERErongoHAHardapKAKaras
KEKavango EastKWKavango WestKHKhomas
KUKuneneOWOhangwenaOHOmaheke
OSOmusatiONOshanaOTOshikoto
ODOtjozondjupaCAZambezi

Nigerian (NG) provinces

CodeStateCodeStateCodeState
ABAbiaFCAbujaADAdamawa
AKAkwa IbomANAnambraBABauchi
BYBayelsaBEBenueBOBorno
CRCross RiverDEDeltaEBEbonyi
EDEdoEKEkitiENEnugu
GOGombeIMImoJIJigawa
KDKadunaKNKanoKTKatsina
KEKebbiKOKogiKWKwara
LALagosNANasarawaNINiger
OGOgunONOndoOSOsun
OYOyoPLPlateauRIRivers
SOSokotoTATarabaYOYobe
ZAZamfara

Nepalese (NP) zones

CodeStateCodeStateCodeState
BAGBagmatiBHEBheriDHADhaulagiri
GANGandakiJANJanakpurKARKarnali
KOSKoshiLUMLumbiniMAHMahakali
MECMechiNARNarayaniRAPRapti
SAGSagarmathaSETSeti

Nicaraguan (NI) states

CodeStateCodeStateCodeState
NI-ANAtlántico NorteNI-ASAtlántico SurNI-BOBoaco
NI-CACarazoNI-CIChinandegaNI-COChontales
NI-ESEstelíNI-GRGranadaNI-JIJinotega
NI-LELeónNI-MDMadrizNI-MNManagua
NI-MSMasayaNI-MTMatagalpaNI-NSNueva Segovia
NI-RIRivasNI-SJRío San Juan

New Zealand (NZ) states

CodeStateCodeStateCodeState
NLNorthlandAKAucklandWAWaikato
BPBay of PlentyTKTaranakiGIGisborne
HBHawke’s BayMWManawatu-WanganuiWEWellington
NSNelsonMBMarlboroughTMTasman
WCWest CoastCTCanterburyOTOtago
SLSouthland

Panamanian (PA) states

CodeStateCodeStateCodeState
PA-1Bocas del ToroPA-2CocléPA-3Colón
PA-4ChiriquíPA-5DariénPA-6Herrera
PA-7Los SantosPA-8PanamáPA-9Veraguas
PA-10West PanamáPA-EMEmberáPA-KYGuna Yala
PA-NBNgöbe-Buglé

Peruvian (PE) states

CodeStateCodeStateCodeState
CALEl CallaoLMAMunicipalidad Metropolitana de LimaAMAAmazonas
ANCAncashAPUApurímacAREArequipa
AYAAyacuchoCAJCajamarcaCUSCusco
HUVHuancavelicaHUCHuánucoICAIca
JUNJunínLALLa LibertadLAMLambayeque
LIMLimaLORLoretoMDDMadre de Dios
MOQMoqueguaPASPascoPIUPiura
PUNPunoSAMSan MartínTACTacna
TUMTumbesUCAUcayali

Philippine (PH) provinces

CodeStateCodeStateCodeState
ABRAbraAGNAgusan del NorteAGSAgusan del Sur
AKLAklanALBAlbayANTAntique
APAApayaoAURAuroraBASBasilan
BANBataanBTNBatanesBTGBatangas
BENBenguetBILBiliranBOHBohol
BUKBukidnonBULBulacanCAGCagayan
CANCamarines NorteCASCamarines SurCAMCamiguin
CAPCapizCATCatanduanesCAVCavite
CEBCebuCOMCompostela ValleyNCOCotabato
DAVDavao del NorteDASDavao del SurDACDavao Occidental
DAODavao OrientalDINDinagat IslandsEASEastern Samar
GUIGuimarasIFUIfugaoILNIlocos Norte
ILSIlocos SurILIIloiloISAIsabela
KALKalingaLUNLa UnionLAGLaguna
LANLanao del NorteLASLanao del SurLEYLeyte
MAGMaguindanaoMADMarinduqueMASMasbate
MSCMisamis OccidentalMSRMisamis OrientalMOUMountain Province
NECNegros OccidentalNERNegros OrientalNSANorthern Samar
NUENueva EcijaNUVNueva VizcayaMDCOccidental Mindoro
MDROriental MindoroPLWPalawanPAMPampanga
PANPangasinanQUEQuezonQUIQuirino
RIZRizalROMRomblonWSASamar
SARSaranganiSIQSiquijorSORSorsogon
SCOSouth CotabatoSLESouthern LeyteSUKSultan Kudarat
SLUSuluSUNSurigao del NorteSURSurigao del Sur
TARTarlacTAWTawi-TawiZMBZambales
ZANZamboanga del NorteZASZamboanga del SurZSIZamboanga Sibugay
00Metro Manila

Pakistani (PK) states

CodeStateCodeStateCodeState
JKAzad KashmirBABalochistanTAFATA
GBGilgit BaltistanISIslamabad Capital TerritoryKPKhyber Pakhtunkhwa
PBPunjabSDSindh

Paraguayan (PY) states

CodeStateCodeStateCodeState
PY-ASUAsunciónPY-1ConcepciónPY-2San Pedro
PY-3PY-4GuairáPY-5Caaguazú
PY-6CaazapáPY-7ItapúaPY-8Misiones
PY-9ParaguaríPY-10Alto ParanáPY-11Central
PY-12ÑeembucúPY-13AmambayPY-14Canindeyú
PY-15Presidente HayesPY-16Alto ParaguayPY-17Boquerón

Romanian (RO) states

CodeStateCodeStateCodeState
ABAlbaARAradAGArgeș
BCBacăuBHBihorBNBistrița-Năsăud
BTBotoșaniBRBrăilaBVBrașov
BBucureștiBZBuzăuCLCălărași
CSCaraș-SeverinCJClujCTConstanța
CVCovasnaDBDâmbovițaDJDolj
GLGalațiGRGiurgiuGJGorj
HRHarghitaHDHunedoaraILIalomița
ISIașiIFIlfovMMMaramureș
MHMehedințiMSMureșNTNeamț
OTOltPHPrahovaSJSălaj
SMSatu MareSBSibiuSVSuceava
TRTeleormanTMTimișTLTulcea
VLVâlceaVSVasluiVNVrancea

Salvadoran (SV) states

CodeStateCodeStateCodeState
SV-AHAhuachapánSV-CACabañasSV-CHChalatenango
SV-CUCuscatlánSV-LILa LibertadSV-MOMorazán
SV-PALa PazSV-SASanta AnaSV-SMSan Miguel
SV-SOSonsonateSV-SSSan SalvadorSV-SVSan Vicente
SV-UNLa UniónSV-USUsulután

Thai (TH) states

CodeStateCodeStateCodeState
TH-37Amnat CharoenTH-15Ang ThongTH-14Ayutthaya
TH-10BangkokTH-38Bueng KanTH-31Buri Ram
TH-24ChachoengsaoTH-18Chai NatTH-36Chaiyaphum
TH-22ChanthaburiTH-50Chiang MaiTH-57Chiang Rai
TH-20ChonburiTH-86ChumphonTH-46Kalasin
TH-62Kamphaeng PhetTH-71KanchanaburiTH-40Khon Kaen
TH-81KrabiTH-52LampangTH-51Lamphun
TH-42LoeiTH-16LopburiTH-58Mae Hong Son
TH-44Maha SarakhamTH-49MukdahanTH-26Nakhon Nayok
TH-73Nakhon PathomTH-48Nakhon PhanomTH-30Nakhon Ratchasima
TH-60Nakhon SawanTH-80Nakhon Si ThammaratTH-55Nan
TH-96NarathiwatTH-39Nong Bua Lam PhuTH-43Nong Khai
TH-12NonthaburiTH-13Pathum ThaniTH-94Pattani
TH-82Phang NgaTH-93PhatthalungTH-56Phayao
TH-67PhetchabunTH-76PhetchaburiTH-66Phichit
TH-65PhitsanulokTH-54PhraeTH-83Phuket
TH-25Prachin BuriTH-77Prachuap Khiri KhanTH-85Ranong
TH-70RatchaburiTH-21RayongTH-45Roi Et
TH-27Sa KaeoTH-47Sakon NakhonTH-11Samut Prakan
TH-74Samut SakhonTH-75Samut SongkhramTH-19Saraburi
TH-91SatunTH-17Sing BuriTH-33Sisaket
TH-90SongkhlaTH-64SukhothaiTH-72Suphan Buri
TH-84Surat ThaniTH-32SurinTH-63Tak
TH-92TrangTH-23TratTH-34Ubon Ratchathani
TH-41Udon ThaniTH-61Uthai ThaniTH-53Uttaradit
TH-95YalaTH-35Yasothon

Turkish (TR) states

CodeStateCodeStateCodeState
TR01AdanaTR02AdıyamanTR03Afyon
TR04AğrıTR05AmasyaTR06Ankara
TR07AntalyaTR08ArtvinTR09Aydın
TR10BalıkesirTR11BilecikTR12Bingöl
TR13BitlisTR14BoluTR15Burdur
TR16BursaTR17ÇanakkaleTR18Çankırı
TR19ÇorumTR20DenizliTR21Diyarbakır
TR22EdirneTR23ElazığTR24Erzincan
TR25ErzurumTR26EskişehirTR27Gaziantep
TR28GiresunTR29GümüşhaneTR30Hakkari
TR31HatayTR32IspartaTR33İçel
TR34İstanbulTR35İzmirTR36Kars
TR37KastamonuTR38KayseriTR39Kırklareli
TR40KırşehirTR41KocaeliTR42Konya
TR43KütahyaTR44MalatyaTR45Manisa
TR46KahramanmaraşTR47MardinTR48Muğla
TR49MuşTR50NevşehirTR51Niğde
TR52OrduTR53RizeTR54Sakarya
TR55SamsunTR56SiirtTR57Sinop
TR58SivasTR59TekirdağTR60Tokat
TR61TrabzonTR62TunceliTR63Şanlıurfa
TR64UşakTR65VanTR66Yozgat
TR67ZonguldakTR68AksarayTR69Bayburt
TR70KaramanTR71KırıkkaleTR72Batman
TR73ŞırnakTR74BartınTR75Ardahan
TR76IğdırTR77YalovaTR78Karabük
TR79KilisTR80OsmaniyeTR81Düzce

Tanzanian (TZ) states

CodeStateCodeStateCodeState
TZ01ArushaTZ02Dar es SalaamTZ03Dodoma
TZ04IringaTZ05KageraTZ06Pemba North
TZ07Zanzibar NorthTZ08KigomaTZ09Kilimanjaro
TZ10Pemba SouthTZ11Zanzibar SouthTZ12Lindi
TZ13MaraTZ14MbeyaTZ15Zanzibar West
TZ16MorogoroTZ17MtwaraTZ18Mwanza
TZ19CoastTZ20RukwaTZ21Ruvuma
TZ22ShinyangaTZ23SingidaTZ24Tabora
TZ25TangaTZ26ManyaraTZ27Geita
TZ28KataviTZ29NjombeTZ30Simiyu

Serbian (RS) districts

CodeStateCodeStateCodeState
RS00BelgradeRS14BorRS11Braničevo
RS02Central BanatRS10DanubeRS23Jablanica
RS09KolubaraRS08MačvaRS17Morava
RS20NišavaRS01North BačkaRS03North Banat
RS24PčinjaRS22PirotRS13Pomoravlje
RS19RasinaRS18RaškaRS06South Bačka
RS04South BanatRS07SremRS12Šumadija
RS21ToplicaRS05West BačkaRS15Zaječar
RS16ZlatiborRS25KosovoRS26Peć
RS27PrizrenRS28Kosovska MitrovicaRS29Kosovo-Pomoravlje
RSKMKosovo-MetohijaRSVOVojvodina

Ukrainian (UA) oblasts

CodeStateCodeStateCodeState
VNVinnytsia OblastVLVolyn OblastDPDnipropetrovsk Oblast
DTDonetsk OblastZTZhytomyr OblastZKZakarpattia Oblast
ZPZaporizhzhia OblastIFIvano-Frankivsk OblastKVKyiv Oblast
KHKirovohrad OblastLHLuhansk OblastLVLviv Oblast
MYMykolaiv OblastODOdessa OblastPLPoltava Oblast
RVRivne OblastSMSumy OblastTPTernopil Oblast
KKKharkiv OblastKSKherson OblastKMKhmelnytskyi Oblast
CKCherkasy OblastCHChernihiv OblastCVChernivtsi Oblast

Ugandan (UG) districts

CodeStateCodeStateCodeState
UG314AbimUG301AdjumaniUG322Agago
UG323AlebtongUG315AmolatarUG324Amudat
UG216AmuriaUG316AmuruUG302Apac
UG303AruaUG217BudakaUG218Bududa
UG201BugiriUG235BugweriUG420Buhweju
UG117BuikweUG219BukedeaUG118Bukomansimbi
UG220BukwaUG225BulambuliUG416Buliisa
UG401BundibugyoUG430BunyangabuUG402Bushenyi
UG202BusiaUG221ButalejaUG119Butambala
UG233ButeboUG120BuvumaUG226Buyende
UG317DokoloUG121GombaUG304Gulu
UG403HoimaUG417IbandaUG203Iganga
UG418IsingiroUG204JinjaUG318Kaabong
UG404KabaleUG405KabaroleUG213Kaberamaido
UG427KagadiUG428KakumiroUG101Kalangala
UG222KaliroUG122KalunguUG102Kampala
UG205KamuliUG413KamwengeUG414Kanungu
UG206KapchorwaUG236KapelebyongUG126Kasanda
UG406KaseseUG207KatakwiUG112Kayunga
UG407KibaaleUG103KibogaUG227Kibuku
UG432KikuubeUG419KiruhuraUG421Kiryandongo
UG408KisoroUG305KitgumUG319Koboko
UG325KoleUG306KotidoUG208Kumi
UG333KwaniaUG228KweenUG123Kyankwanzi
UG422KyegegwaUG415KyenjojoUG125Kyotera
UG326LamwoUG307LiraUG229Luuka
UG104LuweroUG124LwengoUG114Lyantonde
UG223ManafwaUG320MarachaUG105Masaka
UG409MasindiUG214MayugeUG209Mbale
UG410MbararaUG423MitoomaUG115Mityana
UG308MorotoUG309MoyoUG106Mpigi
UG107MubendeUG108MukonoUG334Nabilatuk
UG311NakapiripiritUG116NakasekeUG109Nakasongola
UG230NamayingoUG234NamisindwaUG224Namutumba
UG327NapakUG310NebbiUG231Ngora
UG424NtorokoUG411NtungamoUG328Nwoya
UG331OmoroUG329OtukeUG321Oyam
UG312PaderUG332PakwachUG210Pallisa
UG110RakaiUG429RubandaUG425Rubirizi
UG431RukigaUG412RukungiriUG111Sembabule
UG232SerereUG426SheemaUG215Sironko
UG211SorotiUG212TororoUG113Wakiso
UG313YumbeUG330Zombo

United States Minor Outlying Islands (UM)

CodeStateCodeStateCodeState
81Baker Island84Howland Island86Jarvis Island
67Johnston Atoll89Kingman Reef71Midway Atoll
76Navassa Island95Palmyra Atoll79Wake Island

United States (US) states

CodeStateCodeStateCodeState
ALAlabamaAKAlaskaAZArizona
ARArkansasCACaliforniaCOColorado
CTConnecticutDEDelawareDCDistrict Of Columbia
FLFloridaGAGeorgiaHIHawaii
IDIdahoILIllinoisINIndiana
IAIowaKSKansasKYKentucky
LALouisianaMEMaineMDMaryland
MAMassachusettsMIMichiganMNMinnesota
MSMississippiMOMissouriMTMontana
NENebraskaNVNevadaNHNew Hampshire
NJNew JerseyNMNew MexicoNYNew York
NCNorth CarolinaNDNorth DakotaOHOhio
OKOklahomaOROregonPAPennsylvania
RIRhode IslandSCSouth CarolinaSDSouth Dakota
TNTennesseeTXTexasUTUtah
VTVermontVAVirginiaWAWashington
WVWest VirginiaWIWisconsinWYWyoming
AAArmed Forces (AA)AEArmed Forces (AE)APArmed Forces (AP)

Uruguayan (UY) states

CodeStateCodeStateCodeState
UY-ARArtigasUY-CACanelonesUY-CLCerro Largo
UY-COColoniaUY-DUDuraznoUY-FSFlores
UY-FDFloridaUY-LALavallejaUY-MAMaldonado
UY-MOMontevideoUY-PAPaysandúUY-RNRío Negro
UY-RVRiveraUY-RORochaUY-SASalto
UY-SJSan JoséUY-SOSorianoUY-TATacuarembó
UY-TTTreinta y Tres

Venezuelan (VE) states

CodeStateCodeStateCodeState
VE-ACapitalVE-BAnzoáteguiVE-CApure
VE-DAraguaVE-EBarinasVE-FBolívar
VE-GCaraboboVE-HCojedesVE-IFalcón
VE-JGuáricoVE-KLaraVE-LMérida
VE-MMirandaVE-NMonagasVE-ONueva Esparta
VE-PPortuguesaVE-RSucreVE-STáchira
VE-TTrujilloVE-UYaracuyVE-VZulia
VE-WFederal DependenciesVE-XLa Guaira (Vargas)VE-YDelta Amacuro
VE-ZAmazonas

South African (ZA) states

CodeStateCodeStateCodeState
ECEastern CapeFSFree StateGPGauteng
KZNKwaZulu-NatalLPLimpopoMPMpumalanga
NCNorthern CapeNWNorth WestWCWestern Cape

Zambian (ZM) provinces

CodeStateCodeStateCodeState
ZM-01WesternZM-02CentralZM-03Eastern
ZM-04LuapulaZM-05NorthernZM-06North-Western
ZM-07SouthernZM-08CopperbeltZM-09Lusaka
ZM-10Muchinga

How to Use WooCommerce Country Codes in Your Store

When customers visit your WooCommerce store and proceed to checkout, the default country and state must be set correctly to provide a smooth experience.

By default, WooCommerce uses your store address to guess the customer’s location. However, you can explicitly set the default country and state to match your primary market or most frequent customer base. This helps reduce friction and speeds up the checkout process.

How to set it:

  1. Go to your WordPress admin dashboard.
  2. Navigate to WooCommerce > Settings > General.
  3. Find the Selling location(s) and Default customer location options.
  4. Under Default customer location, select Specific country, and pick the country using the two-letter ISO country code (e.g., US for the United States, CA for Canada).
  5. To set the default state, you may need to add a small snippet of code or use a plugin that allows setting default states by country codes.

Using the correct country and state codes ensures the checkout fields are pre-filled with the right default values, enhancing the user experience.

Restricting Sales to Specific Countries or States Using Country Codes

If you want to restrict where you sell or ship products, WooCommerce allows you to limit sales to specific countries — or even states — using country/state codes.

Why restrict sales?

  • You only want to sell to countries where you can ship.
  • Tax regulations require limiting sales by location.
  • Business strategy dictates regional availability.

How to set it:

  1. Go to WooCommerce > Settings > General.
  2. Under Selling location(s), select Sell to specific countries.
  3. Enter the ISO country codes of the countries you want to sell to, separated by commas (e.g., US,CA,GB).
  4. To restrict by states or provinces, use a plugin or customization that accepts codes like US-NY for New York or CA-ON for Ontario.

Adding Custom Countries or States (Step-by-Step Guide)

Sometimes you may want to add custom countries or states not available in WooCommerce by default — e.g., territories or special regions.

Step 1: Add a custom country

add_filter( 'woocommerce_countries', 'add_custom_country' );

function add_custom_country( $countries )

{

    $countries['XX'] = 'Customland'; // 'XX' = new country code

    return $countries;

<span style="font-weight: 400;">}

Step 2: Add states to that custom country

add_filter( 'woocommerce_states', 'add_custom_country_states' );

function add_custom_country_states( $states ) {

    $states['XX'] = array(

        'XX-01' => 'Custom State 1',

        'XX-02' => 'Custom State 2',

    );

    return $states;

}

Step 3: Use them in WooCommerce settings

Your custom country and states will now show up throughout WooCommerce — including checkout, shipping zones, and tax rules.

Modifying Country or State Names Shown to Users

You can also change how country or state names appear to customers — ideal for localization, branding, or translations.

Rename a country’s display name:

add_filter( 'woocommerce_countries', 'modify_country_names' );

function modify_country_names( $countries ) {

    if ( isset( $countries['US'] ) ) {

        $countries['US'] = 'United States of Awesome';

    }

    return $countries;

}

Rename a state’s display name:

add_filter( 'woocommerce_states', 'modify_state_names' );

function modify_state_names( $states ) {

    if ( isset( $states['US']['CA'] ) ) {

        $states['US']['CA'] = 'California Dreamin\'';

    }

    return $states;

}

Using Country Codes in Shipping & Tax Plugins

Most WooCommerce shipping and tax plugins rely on country and state codes to work properly.

Examples include:

  • Shipping Zones — configured using country/state codes (e.g., US, US-TX).
  • Tax Rules — applied to specific regions using codes for correct tax calculation.
  • Third-Party Plugins: such as the powerful Tax Display by Country for WooCommerce plugin, which displays product prices inclusive/exclusive of tax based on the customer’s country code.

Using official ISO country and state codes ensures compatibility and prevents configuration errors.

 

WooCommerce and cache – Part 2: new Cache Handler plugin

Read Part 1: WooCommerce Currency Switcher and cache – Making them work together

Some months ago, we wrote about one of the most common issues faced by merchants who run highly dynamic websites, which include multi-currency, multi-pricing, geolocation features: stale content served by rigid caching systems.

In brief, there are quite a few caching systems designed with the assumption that the content of a site is the same for anyone. No matter who is opening a page, they serve the same information. This is correct for relatively static sites, such as blogs, which show the same articles to every member of the audience, or simple e-shops, where the prices are set, and are the same for every customer.

In a few words, many caching systems assume that, given a page on a site, the content of such page will always be the same, without exception. As we explained, this is incorrect when a site is highly dynamic. A shop that handles multiple currencies may be showing different prices to different visitors, or it might need to show a different tax rate (this is actually a requirement in many countries), on the exact same page.

With a static caching system, the result is that users may end up seeing the wrong content. This makes for a worse user experience, and can have an impact on conversion.

After an in-depth analysis, and several experiments, we came to a conclusion: issues caused by the caching system must be solved by the caching system. Based on this approach, we prepared an algorithm for dynamic caching that handles the needs of a multi-currency, multi-pricing, multi-language shop as it should, without compromising on the performance. This, in our opinion, is the correct way to address the issue.

The status of Dynamic Caching today

We keep contacting as many hosting providers as possible, explaining them how they should update their caching systems to bring them up to speed. Our objective is to make it clear that handling highly dynamic caching is a must, not just a “frill”.

Quite a few providers agreed with our approach, and allow their customers to customise the caching logic as required. Others, like the WP Engine team, showed interest in our solution, and are currently reviewing it, for future implementation. There are some who are still “lagging behind”, and there are a few, such as CloudFlare, who only offer dynamic caching on their most expensive plans.

Due to these limitations, imposed by an obsolete architecture, merchants have make a difficult decision:

  • Change hosting/service provider and move to one that handles caching as it should. This would make sense, but it’s not always possible. Besides, merchants might have invested a significant sum in current service.
  • Disable the caching system they are using, and for which they might have been paying a service fee.
  • Abandon the idea of a multi-currency, multi-language site, potentially risking to drive away audience.

While we still maintain that caching issues must be addressed on the caching layer, we wanted to find a solution that would help merchants, at least temporarily, while the service providers update their system.

Welcome our new plugin: WooCommerce Cache Handler

Thanks to our customers’ support, we are happy to announce the release of the WooCommerce Cache Handler plugin (currently in Beta stage). This new plugin can be used as a workaround with rigid caching systems, such as CloudFlare, SiteGround “Dynamic” Cache (which is actually static), as well as plugins that don’t support dynamic caching, such as W3 Total Cache.

Please note that our recommendation is still to consider switching to a more flexible solution, but this plugin will cover you until you are ready for that change.

How it works

The WooCommerce Cache Handler is simple to use. All you have to do after installing the plugin is go to WooCommerce Settings > Cache Handler and choose the handler you prefer.

WooCommerce Cache Handler - Configuration page

Configuring WooCommerce Cache Handler is extremely easy. Simply choose your favourite handler, clear the cache, and you are ready to go!

After that simple selection, the Cache Handler will support our Currency Switcher, Prices by Country, Tax Display by Country, and all our other WooCommerce plugins.

Currently, there are three options available.

1. Disabled

As the name implies, this disable all the features of the plugin. It can be useful for testing.

2. Redirect

This option is an almost exact equivalent of the “caching support” feature implemented by WooCommerce, which is enabled when the Default Customer Address is set to Geolocate (with page caching support).

The major difference from the standard feature is that our handler takes into account details such as the currency, customer’s country, customer’s state, customer’s tax exemption, and so on, ensuring that the correct content is served to customers based on these parameters. Like the original workaround from which it was derived, this handler appends a random string to URLs.

Benefits and drawbacks

+ The Redirect handler is based on the original workaround implemented by WooCommerce.
+ This solution works on a page level, thus it can produce the correct content with any configuration, or 3rd party plugins.
– The URLs look “ugly”, due to the string appended to them to work around the limitations of caching.

3. Ajax Loader

The Ajax Loader is an alternative to the Redirect, and it’s more elegant, as it doesn’t alter page URLs with ugly, random text. This handler loads all pricing elements via Ajax, when the page load is completed. The result is the following:

  1. A visitor connects to your site from the US. He would like to see USD.
  2. The rigid caching system has the page cached in EUR, and serves it to the customer.
  3. The Ajax Loader kicks in as soon as the page is loaded, requesting the updated prices from the server. After a brief moment, all elements that were displayed in EUR are changed to USD, as the visitor would expect.This update is very quick, and, at the moment, it processes the following standard elements :
    – Product prices
    – Currency selectors
    – Price filter widget
    – Custom prices displayed with the Currency Switcher shortcodes.

Benefits and drawbacks

+ The Ajax Loader is a more elegant solution than reloading the page after appending a random string to the URL.
+ Page load is faster, as there is no redirect.
+ URLs are not altered. There is no random text appended to them.
– The Ajax Loader can only process standard elements on the page. If 3rd party plugins add their own pricing elements, such addon prices, custom totals, etc, those won’t be updated. It will be up to the 3rd party plugins’ authors to “hook” into the Ajax Loader and refresh their elements via Ajax.

How to get the WooCommerce Cache Handler

The WooCommerce Cache Handler is available free of charge. Please feel free to download and try it, and see how it works for you. Whether you are using CloudFlare, SiteGround, WP Engine, Flywheel, or any other service with static caching, the Cache Handler got you covered!

Questions? Feedback?

The Cache Handler is still in Beta stage and that, as any free plugin, it’s not covered our free support. We would recommend to try it on a staging copy of your site, so that the live site won’t not affected by bugs that we eventually have to address.

We also would like to encourage you to share your feedback by contacting us. If you wish to contribute to the development of this plugin, you are more than welcome to do so!

Thanks for reading, and see you soon on aelia.co!

The Aelia Team

WooCommerce Currency Switcher and cache – Making them work together

This article continues in WooCommerce and cache – Part 2: new Cache Handler plugin

One of the most common questions we receive from our customers is how to make a highly dynamic, multi-currency, multi-pricing, geolocation-enabled sites work properly with caching enabled. This is not always an easy task, because caching systems are designed with the assumption that the content served by a site doesn’t change depending on the visitor. Such assumption holds true in many cases, as a large number of sites does indeed serve the same content to whoever views a page. In such case, the standard behaviour of caching systems, which is storing one copy of each page in the cache, is acceptable.

As soon as multi-currency features are added, the same behaviour proves itself too limited, because the assumption behind it becomes incorrect. A multi-currency shop serves different content to different visitors, depending on the currency and other criteria (applicable taxes, regional pricing, etc). Quite simply, having one cached copy of each page just doesn’t cut it anymore.

Until recently, the only way to prevent caching from interfering with the multi-currency features was to disable it on catalogue pages. Doing so ensures that the shop can produce content dynamically, showing the correct information to each visitor. In some cases, when the caching system in use is too rigid, this is still the only solution.

How WooCommerce handles the issue

WooCommerce itself has to deal with caching since its team introduced geolocation features in it. The WC team added a workaround to “trick” caching systems into letting WooCommerce serve the correct data. Such workaround works by reloading the shop pages in a way that cache is ignored. This ensures that the page shows the correct content but, in our opinion, it’s not an ideal approach. We certainly appreciate the effort put into it, and the fact that there isn’t much more that a plugin can do to correct the behaviour of the caching system. However, we decided to find an alternative, more robust solution.

Our solution

Our opinion is that caching systems should adapt to your site, not the other way round. Issues caused by caching should be solved by fixing the caching. With this in mind, instead of implementing a workaround, we tackled the issue at its root, and wrote an algorithm for dynamic caching that takes into account the needs of a multi-currency website.

The algorithm is straightforward, and solves the issue by addressing its cause: instead of one copy of each page, it allows caching systems and plugins to store multiple copies of each page (such as one for each currency). With that in place, visitors from all over the world will see the content that applies to them, with the correct currency and taxes applied. If visitors choose another currency, or country, then our plugins track their choice, and the dynamic caching logic uses it to serve them the correct content.

Our solution grants top performance, with maximum flexibility.

Supported Systems

Dynamic caching is a great solution for highly dynamic, multi-currency sites. However, it can only work if the caching system in use supports it. As of October 2015, the following plugins and systems support, or are planning to support, dynamic caching.

WordPress Plugins

Caching Systems

For caching plugins and systems that do not support dynamic caching, disabling cache on catalogue pages is still necessary to allow the multi-currency features to work correctly.

How to add dynamic caching to your site

Adding it to your site can be as simple as copying one file, or changing one configuration file. In order to allow you to get started quickly, we wrote an implementation of dynamic caching for the following systems:

  • ZenCache/Comet Cache
  • Nginx

You can find detailed instructions to install and configure each of our solutions, as well as indications for other systems, in our knowledge base: How to add dynamic caching to your site.

We also discussed the implementation extensively with the WP Rocket Team, and provided them with code examples for integration. They confirmed that they are going to add support for dynamic caching and multi-currency sites directly in their plugin.

With dynamic caching and our Currency Switcher, your WooCommerce site will be faster and more flexible than ever!

What about systems that don’t support dynamic caching?

Plugins and caching systems that don’t support dynamic caching still have to be disabled on the catalogue, at least until they are updated. We believe that caching systems should be flexible, and support for dynamic caching is not particularly difficult to implement.

If you are using a plugin, or a caching system that doesn’t support dynamic caching, we recommend thar you get in touch with its authors and express your interest in such feature. You can also suggest them to contact us directly, if they have any questions. We will be happy to provide them with all the information they need to improve their solution.

Questions? Feedback?

We hope that you enjoyed this great news. A faster e-commerce means more customers, and that is always good! If you have any questions about our solutions, or if you would like to send us your feedback, please feel free to contact us. We will get back to you in no time.

Thank for your time and continued support.

The Aelia Team