You must be familiar with Adobe Commerce module development in order to create a new one.

Please refer to the following topics in our developer documentation before attempting to create a new module:

Required Information

A new country must have a unique Name, Country ID, ISO2, and ISO3 codes throughout Adobe Commerce.

Module structure

In this example, we are going to create a new module called `ExtraCountries` with the following directory structure:

(To find out more about the module structure, see Module overview in our developer documentation).


 |
 
 | |
 | config.xml
 | di.xml
 | module.xml
 |
 
 | |
 | 
 |   |
 |   
 |     |
 |     TranslatedListsPlugin.php
 |
 
 | |
 | 
 |   |
 |   
 |     |
 |     AddDataForAbstractCountry.php
 |
 composer.json
 registration.php
NOTE
Each Header section of this article describes files from the module structure section.

ExtraCountries/etc/config.xml

A new module configuration is defined in this XML file. The following configurations and tags can be edited in order to adjust the new country default settings.

  • allow - To add the newly added country to the “Allow Countries” list by default, append the new Country Code to the end of the allow tag content. Country codes are comma separated. Please note that this tag will overwrite the data from the Directory module configuration file (Directory/etc/config.xml) allow tag, that’s why we repeat all the codes here plus adding the new one.
  • optional_zip_countries - If the zip code for the newly added country should be optional, append the country code to the end of the content of the optional_zip_countries tag. Country codes are comma separated. Please note that this tag will overwrite the data from the Directory module configuration file (Directory/etc/config.xml) optional_zip_countries tag, that’s why we repeat all the codes here plus adding the new one.
  • eu_countries - If the newly added country must be a part of the European Union Countries list by default, append the country code to the end of the content of the eu_countries tag. Country codes are comma separated. Please note that this tag will overwrite the data from the Store module configuration file (_Store/etc/config.xml_) eu_countries tag, that’s why we repeat all the codes here plus adding the new one.
  • config.xml file example
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
    <default>
        <general>
            <country>
                <!-- append a new country codes to the end of this list -->
                <allow>AF,AL,DZ,AS,AD,AO,AI,AQ,AG,AR,AM,AW,AU,AT,AX,AZ,BS,BH,BD,BB,BY,BE,BZ,BJ,BM,BL,BT,BO,BQ,BA,BW,BV,BR,IO,VG,BN,BG,BF,BI,KH,CM,CA,CD,CV,KY,CF,TD,CL,CN,CX,CW,CC,CO,KM,CG,CK,CR,HR,CU,CY,CZ,DK,DJ,DM,DO,EC,EG,SV,GQ,ER,EE,ET,FK,FO,FJ,FI,FR,GF,PF,TF,GA,GM,GE,DE,GG,GH,GI,GR,GL,GD,GP,GU,GT,GN,GW,GY,HT,HM,HN,HK,HU,IS,IM,IN,ID,IR,IQ,IE,IL,IT,CI,JE,JM,JP,JO,KZ,KE,KI,KW,KG,LA,LV,LB,LS,LR,LY,LI,LT,LU,ME,MF,MO,MK,MG,MW,MY,MV,ML,MT,MH,MQ,MR,MU,YT,FX,MX,FM,MD,MC,MN,MS,MA,MZ,MM,NA,NR,NP,NL,AN,NC,NZ,NI,NE,NG,NU,NF,KP,MP,NO,OM,PK,PW,PA,PG,PY,PE,PH,PN,PL,PS,PT,PR,QA,RE,RO,RS,RU,RW,SH,KN,LC,PM,VC,WS,SM,ST,SA,SN,SC,SL,SG,SK,SI,SB,SO,ZA,GS,KR,ES,LK,SD,SR,SJ,SZ,SE,CH,SX,SY,TL,TW,TJ,TZ,TH,TG,TK,TO,TT,TN,TR,TM,TC,TV,VI,UG,UA,AE,GB,US,UM,UY,UZ,VU,VA,VE,VN,WF,EH,XK,YE,ZM,ZW,XX</allow>
​
                <!-- if added countries need to belong to the European Union Countries list by default, append their codes to the end of this list -->
                <eu_countries>AT,BE,BG,CY,CZ,DK,EE,FI,FR,DE,GR,HR,HU,IE,IT,LV,LT,LU,MT,NL,PL,PT,RO,SK,SI,ES,SE,GB,XX</eu_countries>
​
                <!-- if added countries are not require zip code, append it's code to the end of this list -->
                <optional_zip_countries>HK,IE,MO,PA,GB,XX</optional_zip_countries>
            </country>
        </general>
    </default>
</config>

For more information on the module configuration files, see PHP Developer Guide > Define Configurations files in our developer documentation.

Note that these changes are optional and will only affect the default belonging of the new country to the “Allow Countries”, “Zip/Postal Code is Optional for”, and “European Union Countries” lists. If this file is skipped from the module structure, a new country will still be added, but it will have to be manually configured at the Admin > Stores > Settings > Configuration > General > Country Options settings page.