Announcement: You can find the guides for Commerce 7.5 and later on the new Elastic Path Documentation site. This Developer Center contains the guides for Commerce 6.13.0 through 7.4.1.Visit new site

This version of Elastic Path Commerce is no longer supported or maintained. To upgrade to the latest version, contact your Elastic Path representative.



When you need an internationalized list of countries and their corresponding sub-countries (states/provinces), you can use the com.elasticpath.domain.misc.Geography class.

Key classes and files

  • GeographyImpl - For retrieving locale specific list of countries and sub-countries
  • Application - The bootstrapping class in cmclient.
  • ResourceRetrievalServiceImpl - Service used by the cmclient rcp application to retrieve resources from the server remotely
  • PropertiesDaoImpl - Provides loading mechanism of the properties files.
  • - This file lists the ISO 3166-2 country codes and their string values.
  • - This file lists the ISO 3166-2 subregion codes and their string values.XX is the ISO 3166-2 country code for the subregions country.

How the Geography Class works

The Geography class requires that the properties files containing geography information is loaded up into its properties map before use. This is done in the domainModel.xml using the com.elasticpath.persistence.dao.impl.GeographyPropertiesDaoLoaderFactoryImpl. This class reads the list of country and subcountry property files.

  1. On startup of the Commerce Manager application, the Spring context is loaded and set to ServiceLocator class
  2. The Geography singleton can be obtained using ServiceLocator.getService(ContextIdNames.GEOGRAPHY) and can be used anywhere in CM to retrieve a map of countries with internationalized names.
i.e.  geography.getCountryDisplayName(tax.getRegionCode(), Locale.getDefault());


Properties files are stored under com.elasticpath.core/WEB-INF/conf/resources.

How Country Files Work

Country names and subregions are stored in two country properties files:

  • - stores ISO 3166-2 country codes and the country string values.
  • - stores the subregions of the country defined in the file. XX is the ISO 3166-2 country code for the for the subregion's parent country.

For example, Canada would be defined as CA=Canada in the and Canada's subregions would be defined in the file.

Country and Subregion Formats follow this format: XX=COUNTRY. The first two letters XX is the ISO 3166-2 country code and COUNTRY is the value shown in Cortex and Commerce Manager. Example:

BE=Belgium follow this format: XX=SUBREGION. The first two letters XX is the ISO 3166-2 subregion code and SUBREGION is the value shown in Cortex and Commerce Manager. Example:

BC=British Columbia

Customizing the Display Order for Countries and Subregions

Countries and subregions are, by default, sorted and displayed alphabetically. You can customize the display order. To customize the Country order, define an index value for the country code. For example, if you wanted Canada to display first and Belgium to display second, you would write the following in


To customize the subregion order, define and index value for the subregion. For example, if you wanted Yukon to display first and then Saskatchewan to display second, you would write the following in


Unexpected results may occur if the countries and subregions are not defined in the proper format.


  • To retrieve sub countries for a given country, you need to pass in the country code.
  • Sub Countries are keyed by country code. Here's a helper method to convert a country code from a country's name if you already have the map of countries.
private String getCountryCode(final String country) {
  String code = "";
  if (countryMap \!= null) {
  Map.Entry<String, String> entry = null;
  for (final Iterator< ? > itr = countryMap.entrySet().iterator(); itr.hasNext();-) {
    entry = (Map.Entry);
    if (entry.getValue().equalsIgnoreCase(country))
    { 	code = entry.getKey();
  return code;