countries

This component renders a form select element of all country names and country codes by default, and can also be used to output country codes/names to a Liquid collection.

{% component type: "countries" %}

Parameters and Options

Parameter Values Required Description
type countries

This is the name of the entity that needs to be used for the component retrieving function.

layout <path/to/layout>
Path to file that will contain the Liquid layout content to be parsed.

If an empty string, nothing will be rendered.
If paramater is not included, the default virtual layout will be rendered (see below).

allowedCountries <LIST OF COUNTRY CODES>
Restricts the output to only those countries indicated by a comma separated list of country codes (eg: US,AU)

If an empty string, or if paramater is not included, all countries will be listed by default.

collectionVariable <yourLiquidVariableName>
Assigns the data to a Liquid collection enabling further access to the data on the Page or Template using Liquid.

Your collectionVariable value must only contain English letters, numbers or underscores. Spaces or special characters are not supported.

Liquid Output

The below output shows the list of country data:

{
  "items": [
  {
    "code": "AF",
    "displayName": "AFGHANISTAN"
  },
  {
    "code": "AL",
    "displayName": "ALBANIA"
  },
  {
    "code": "DZ",
    "displayName": "ALGERIA"
  },
  {
    "code": "AS",
    "displayName": "AMERICAN SAMOA"
  },
  {
    "code": "AD",
    "displayName": "ANDORRA"
  },
  {
    "code": "AO",
    "displayName": "ANGOLA"
  },
  {
    "code": "AQ",
    "displayName": "ANTARCTICA"
  },
  {
    "code": "AG",
    "displayName": "ANTIGUA AND BARBUDA"
  },
  {
    "code": "AR",
    "displayName": "ARGENTINA"
  },
  {
    "code": "AM",
    "displayName": "ARMENIA"
  },
  {
    "code": "AW",
    "displayName": "ARUBA"
  },
  {
    "code": "AU",
    "displayName": "AUSTRALIA"
  },
  {
    "code": "AT",
    "displayName": "AUSTRIA"
  },
  {
    "code": "AZ",
    "displayName": "AZERBAIJAN"
  },
  {
    "code": "BS",
    "displayName": "BAHAMAS"
  },
  {
    "code": "BH",
    "displayName": "BAHRAIN"
  },
  {
    "code": "BD",
    "displayName": "BANGLADESH"
  },
  {
    "code": "BB",
    "displayName": "BARBADOS"
  },
  {
    "code": "BY",
    "displayName": "BELARUS"
  },
  {
    "code": "BE",
    "displayName": "BELGIUM"
  },
  {
    "code": "BZ",
    "displayName": "BELIZE"
  },
  {
    "code": "BJ",
    "displayName": "BENIN"
  },
  {
    "code": "BM",
    "displayName": "BERMUDA"
  },
  {
    "code": "BT",
    "displayName": "BHUTAN"
  },
  {
    "code": "BO",
    "displayName": "BOLIVIA"
  },
  {
    "code": "BA",
    "displayName": "BOSNIA AND HERZEGOVINA"
  },
  {
    "code": "BW",
    "displayName": "BOTSWANA"
  },
  {
    "code": "BV",
    "displayName": "BOUVET ISLAND"
  },
  {
    "code": "BR",
    "displayName": "BRAZIL"
  },
  {
    "code": "IO",
    "displayName": "BRITISH INDIAN OCEAN TERRITORY"
  },
  {
    "code": "BN",
    "displayName": "BRUNEI DARUSSALAM"
  },
  {
    "code": "BG",
    "displayName": "BULGARIA"
  },
  {
    "code": "BF",
    "displayName": "BURKINA FASO"
  },
  {
    "code": "BI",
    "displayName": "BURUNDI"
  },
  {
    "code": "KH",
    "displayName": "CAMBODIA"
  },
  {
    "code": "CM",
    "displayName": "CAMEROON"
  },
  {
    "code": "CA",
    "displayName": "CANADA"
  },
  {
    "code": "CV",
    "displayName": "CAPE VERDE"
  },
  {
    "code": "KY",
    "displayName": "CAYMAN ISLANDS"
  },
  {
    "code": "CF",
    "displayName": "CENTRAL AFRICAN REPUBLIC"
  },
  {
    "code": "TD",
    "displayName": "CHAD"
  },
  {
    "code": "CL",
    "displayName": "CHILE"
  },
  {
    "code": "CN",
    "displayName": "CHINA"
  },
  {
    "code": "CX",
    "displayName": "CHRISTMAS ISLAND"
  },
  {
    "code": "CC",
    "displayName": "COCOS (KEELING) ISLANDS"
  },
  {
    "code": "CO",
    "displayName": "COLOMBIA"
  },
  {
    "code": "KM",
    "displayName": "COMOROS"
  },
  {
    "code": "CG",
    "displayName": "CONGO"
  },
  {
    "code": "CD",
    "displayName": "CONGO, THE DEMOCRATIC REPUBLIC OF THE"
  },
  {
    "code": "CK",
    "displayName": "COOK ISLANDS"
  },
  {
    "code": "CR",
    "displayName": "COSTA RICA"
  },
  {
    "code": "CI",
    "displayName": "CÔTE D'IVOIRE"
  },
  {
    "code": "HR",
    "displayName": "CROATIA"
  },
  {
    "code": "CU",
    "displayName": "CUBA"
  },
  {
    "code": "CY",
    "displayName": "CYPRUS"
  },
  {
    "code": "CZ",
    "displayName": "CZECH REPUBLIC"
  },
  {
    "code": "DK",
    "displayName": "DENMARK"
  },
  {
    "code": "DJ",
    "displayName": "DJIBOUTI"
  },
  {
    "code": "DM",
    "displayName": "DOMINICA"
  },
  {
    "code": "DO",
    "displayName": "DOMINICAN REPUBLIC"
  },
  {
    "code": "EC",
    "displayName": "ECUADOR"
  },
  {
    "code": "EG",
    "displayName": "EGYPT"
  },
  {
    "code": "SV",
    "displayName": "EL SALVADOR"
  },
  {
    "code": "GQ",
    "displayName": "EQUATORIAL GUINEA"
  },
  {
    "code": "ER",
    "displayName": "ERITREA"
  },
  {
    "code": "EE",
    "displayName": "ESTONIA"
  },
  {
    "code": "ET",
    "displayName": "ETHIOPIA"
  },
  {
    "code": "FK",
    "displayName": "FALKLAND ISLANDS (MALVINAS)"
  },
  {
    "code": "FO",
    "displayName": "FAROE ISLANDS"
  },
  {
    "code": "FJ",
    "displayName": "FIJI"
  },
  {
    "code": "FI",
    "displayName": "FINLAND"
  },
  {
    "code": "FR",
    "displayName": "FRANCE"
  },
  {
    "code": "GF",
    "displayName": "FRENCH GUIANA"
  },
  {
    "code": "PF",
    "displayName": "FRENCH POLYNESIA"
  },
  {
    "code": "TF",
    "displayName": "FRENCH SOUTHERN TERRITORIES"
  },
  {
    "code": "GA",
    "displayName": "GABON"
  },
  {
    "code": "GM",
    "displayName": "GAMBIA"
  },
  {
    "code": "GE",
    "displayName": "GEORGIA"
  },
  {
    "code": "DE",
    "displayName": "GERMANY"
  },
  {
    "code": "GH",
    "displayName": "GHANA"
  },
  {
    "code": "GI",
    "displayName": "GIBRALTAR"
  },
  {
    "code": "GR",
    "displayName": "GREECE"
  },
  {
    "code": "GL",
    "displayName": "GREENLAND"
  },
  {
    "code": "GD",
    "displayName": "GRENADA"
  },
  {
    "code": "GP",
    "displayName": "GUADELOUPE"
  },
  {
    "code": "GU",
    "displayName": "GUAM"
  },
  {
    "code": "GT",
    "displayName": "GUATEMALA"
  },
  {
    "code": "GN",
    "displayName": "GUINEA"
  },
  {
    "code": "GW",
    "displayName": "GUINEA-BISSAU"
  },
  {
    "code": "GY",
    "displayName": "GUYANA"
  },
  {
    "code": "HT",
    "displayName": "HAITI"
  },
  {
    "code": "HM",
    "displayName": "HEARD ISLAND AND MCDONALD ISLANDS"
  },
  {
    "code": "HN",
    "displayName": "HONDURAS"
  },
  {
    "code": "HK",
    "displayName": "HONG KONG"
  },
  {
    "code": "HU",
    "displayName": "HUNGARY"
  },
  {
    "code": "IS",
    "displayName": "ICELAND"
  },
  {
    "code": "IN",
    "displayName": "INDIA"
  },
  {
    "code": "ID",
    "displayName": "INDONESIA"
  },
  {
    "code": "IR",
    "displayName": "IRAN, ISLAMIC REPUBLIC OF"
  },
  {
    "code": "IQ",
    "displayName": "IRAQ"
  },
  {
    "code": "IE",
    "displayName": "IRELAND"
  },
  {
    "code": "IL",
    "displayName": "ISRAEL"
  },
  {
    "code": "IT",
    "displayName": "ITALY"
  },
  {
    "code": "JM",
    "displayName": "JAMAICA"
  },
  {
    "code": "JP",
    "displayName": "JAPAN"
  },
  {
    "code": "JO",
    "displayName": "JORDAN"
  },
  {
    "code": "KZ",
    "displayName": "KAZAKHSTAN"
  },
  {
    "code": "KE",
    "displayName": "KENYA"
  },
  {
    "code": "KI",
    "displayName": "KIRIBATI"
  },
  {
    "code": "KP",
    "displayName": "KOREA, DEMOCRATIC PEOPLE'S REPUBLIC OF"
  },
  {
    "code": "KR",
    "displayName": "KOREA, REPUBLIC OF"
  },
  {
    "code": "KW",
    "displayName": "KUWAIT"
  },
  {
    "code": "KG",
    "displayName": "KYRGYZSTAN"
  },
  {
    "code": "LA",
    "displayName": "LAO PEOPLE'S DEMOCRATIC REPUBLIC (LAOS)"
  },
  {
    "code": "LV",
    "displayName": "LATVIA"
  },
  {
    "code": "LB",
    "displayName": "LEBANON"
  },
  {
    "code": "LS",
    "displayName": "LESOTHO"
  },
  {
    "code": "LR",
    "displayName": "LIBERIA"
  },
  {
    "code": "LY",
    "displayName": "LIBYAN ARAB JAMAHIRIYA"
  },
  {
    "code": "LI",
    "displayName": "LIECHTENSTEIN"
  },
  {
    "code": "LT",
    "displayName": "LITHUANIA"
  },
  {
    "code": "LU",
    "displayName": "LUXEMBOURG"
  },
  {
    "code": "MO",
    "displayName": "MACAO"
  },
  {
    "code": "MK",
    "displayName": "MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF"
  },
  {
    "code": "MG",
    "displayName": "MADAGASCAR"
  },
  {
    "code": "MW",
    "displayName": "MALAWI"
  },
  {
    "code": "MY",
    "displayName": "MALAYSIA"
  },
  {
    "code": "MV",
    "displayName": "MALDIVES"
  },
  {
    "code": "ML",
    "displayName": "MALI"
  },
  {
    "code": "MT",
    "displayName": "MALTA"
  },
  {
    "code": "MH",
    "displayName": "MARSHALL ISLANDS"
  },
  {
    "code": "MQ",
    "displayName": "MARTINIQUE"
  },
  {
    "code": "MR",
    "displayName": "MAURITANIA"
  },
  {
    "code": "MU",
    "displayName": "MAURITIUS"
  },
  {
    "code": "YT",
    "displayName": "MAYOTTE"
  },
  {
    "code": "MX",
    "displayName": "MEXICO"
  },
  {
    "code": "FM",
    "displayName": "MICRONESIA, FEDERATED STATES OF"
  },
  {
    "code": "MD",
    "displayName": "MOLDOVA, REPUBLIC OF"
  },
  {
    "code": "MC",
    "displayName": "MONACO"
  },
  {
    "code": "MN",
    "displayName": "MONGOLIA"
  },
  {
    "code": "ME",
    "displayName": "MONTENEGRO"
  },
  {
    "code": "MS",
    "displayName": "MONTSERRAT"
  },
  {
    "code": "MA",
    "displayName": "MOROCCO"
  },
  {
    "code": "MZ",
    "displayName": "MOZAMBIQUE"
  },
  {
    "code": "MM",
    "displayName": "MYANMAR"
  },
  {
    "code": "NA",
    "displayName": "NAMIBIA"
  },
  {
    "code": "NR",
    "displayName": "NAURU"
  },
  {
    "code": "NP",
    "displayName": "NEPAL"
  },
  {
    "code": "NL",
    "displayName": "NETHERLANDS"
  },
  {
    "code": "AN",
    "displayName": "NETHERLANDS ANTILLES"
  },
  {
    "code": "NC",
    "displayName": "NEW CALEDONIA"
  },
  {
    "code": "NZ",
    "displayName": "NEW ZEALAND"
  },
  {
    "code": "NI",
    "displayName": "NICARAGUA"
  },
  {
    "code": "NE",
    "displayName": "NIGER"
  },
  {
    "code": "NG",
    "displayName": "NIGERIA"
  },
  {
    "code": "NU",
    "displayName": "NIUE"
  },
  {
    "code": "NF",
    "displayName": "NORFOLK ISLAND"
  },
  {
    "code": "MP",
    "displayName": "NORTHERN MARIANA ISLANDS"
  },
  {
    "code": "NO",
    "displayName": "NORWAY"
  },
  {
    "code": "OM",
    "displayName": "OMAN"
  },
  {
    "code": "PK",
    "displayName": "PAKISTAN"
  },
  {
    "code": "PW",
    "displayName": "PALAU"
  },
  {
    "code": "PS",
    "displayName": "PALESTINIAN TERRITORY, OCCUPIED"
  },
  {
    "code": "PA",
    "displayName": "PANAMA"
  },
  {
    "code": "PG",
    "displayName": "PAPUA NEW GUINEA"
  },
  {
    "code": "PY",
    "displayName": "PARAGUAY"
  },
  {
    "code": "PE",
    "displayName": "PERU"
  },
  {
    "code": "PH",
    "displayName": "PHILIPPINES"
  },
  {
    "code": "PN",
    "displayName": "PITCAIRN"
  },
  {
    "code": "PL",
    "displayName": "POLAND"
  },
  {
    "code": "PT",
    "displayName": "PORTUGAL"
  },
  {
    "code": "PR",
    "displayName": "PUERTO RICO"
  },
  {
    "code": "QA",
    "displayName": "QATAR"
  },
  {
    "code": "RE",
    "displayName": "RÉUNION"
  },
  {
    "code": "RO",
    "displayName": "ROMANIA"
  },
  {
    "code": "RU",
    "displayName": "RUSSIAN FEDERATION"
  },
  {
    "code": "RW",
    "displayName": "RWANDA"
  },
  {
    "code": "SH",
    "displayName": "SAINT HELENA"
  },
  {
    "code": "KN",
    "displayName": "SAINT KITTS AND NEVIS"
  },
  {
    "code": "LC",
    "displayName": "SAINT LUCIA"
  },
  {
    "code": "PM",
    "displayName": "SAINT PIERRE AND MIQUELON"
  },
  {
    "code": "VC",
    "displayName": "SAINT VINCENT AND THE GRENADINES"
  },
  {
    "code": "WS",
    "displayName": "SAMOA"
  },
  {
    "code": "SM",
    "displayName": "SAN MARINO"
  },
  {
    "code": "ST",
    "displayName": "SAO TOME AND PRINCIPE"
  },
  {
    "code": "SA",
    "displayName": "SAUDI ARABIA"
  },
  {
    "code": "SN",
    "displayName": "SENEGAL"
  },
  {
    "code": "RS",
    "displayName": "SERBIA"
  },
  {
    "code": "SC",
    "displayName": "SEYCHELLES"
  },
  {
    "code": "SL",
    "displayName": "SIERRA LEONE"
  },
  {
    "code": "SG",
    "displayName": "SINGAPORE"
  },
  {
    "code": "SK",
    "displayName": "SLOVAKIA"
  },
  {
    "code": "SI",
    "displayName": "SLOVENIA"
  },
  {
    "code": "SB",
    "displayName": "SOLOMON ISLANDS"
  },
  {
    "code": "SO",
    "displayName": "SOMALIA"
  },
  {
    "code": "ZA",
    "displayName": "SOUTH AFRICA"
  },
  {
    "code": "GS",
    "displayName": "SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS"
  },
  {
    "code": "ES",
    "displayName": "SPAIN"
  },
  {
    "code": "LK",
    "displayName": "SRI LANKA"
  },
  {
    "code": "SD",
    "displayName": "SUDAN"
  },
  {
    "code": "SR",
    "displayName": "SURINAME"
  },
  {
    "code": "SJ",
    "displayName": "SVALBARD AND JAN MAYEN"
  },
  {
    "code": "SZ",
    "displayName": "SWAZILAND"
  },
  {
    "code": "SE",
    "displayName": "SWEDEN"
  },
  {
    "code": "CH",
    "displayName": "SWITZERLAND"
  },
  {
    "code": "SY",
    "displayName": "SYRIAN ARAB REPUBLIC"
  },
  {
    "code": "TW",
    "displayName": "TAIWAN"
  },
  {
    "code": "TJ",
    "displayName": "TAJIKISTAN"
  },
  {
    "code": "TZ",
    "displayName": "TANZANIA, UNITED REPUBLIC OF"
  },
  {
    "code": "TH",
    "displayName": "THAILAND"
  },
  {
    "code": "TL",
    "displayName": "TIMOR-LESTE"
  },
  {
    "code": "TG",
    "displayName": "TOGO"
  },
  {
    "code": "TK",
    "displayName": "TOKELAU"
  },
  {
    "code": "TO",
    "displayName": "TONGA"
  },
  {
    "code": "TT",
    "displayName": "TRINIDAD AND TOBAGO"
  },
  {
    "code": "TN",
    "displayName": "TUNISIA"
  },
  {
    "code": "TR",
    "displayName": "TURKEY"
  },
  {
    "code": "TM",
    "displayName": "TURKMENISTAN"
  },
  {
    "code": "TC",
    "displayName": "TURKS AND CAICOS ISLANDS"
  },
  {
    "code": "TV",
    "displayName": "TUVALU"
  },
  {
    "code": "UG",
    "displayName": "UGANDA"
  },
  {
    "code": "UA",
    "displayName": "UKRAINE"
  },
  {
    "code": "AE",
    "displayName": "UNITED ARAB EMIRATES"
  },
  {
    "code": "GB",
    "displayName": "UNITED KINGDOM"
  },
  {
    "code": "US",
    "displayName": "UNITED STATES"
  },
  {
    "code": "UM",
    "displayName": "UNITED STATES MINOR OUTLYING ISLANDS"
  },
  {
    "code": "UY",
    "displayName": "URUGUAY"
  },
  {
    "code": "UZ",
    "displayName": "UZBEKISTAN"
  },
  {
    "code": "VU",
    "displayName": "VANUATU"
  },
  {
    "code": "VE",
    "displayName": "VENEZUELA"
  },
  {
    "code": "VN",
    "displayName": "VIET NAM"
  },
  {
    "code": "VG",
    "displayName": "VIRGIN ISLANDS, BRITISH"
  },
  {
    "code": "VI",
    "displayName": "VIRGIN ISLANDS, U.S."
  },
  {
    "code": "WF",
    "displayName": "WALLIS AND FUTUNA"
  },
  {
    "code": "EH",
    "displayName": "WESTERN SAHARA"
  },
  {
    "code": "YE",
    "displayName": "YEMEN"
  },
  {
    "code": "ZM",
    "displayName": "ZAMBIA"
  },
  {
    "code": "ZW",
    "displayName": "ZIMBABWE"
  }
]
}

Virtual Layout

If not using any custom layout or collection, the default virtual layout will output as a form select element:

{% assign destinationCountryCode = shoppingCartData.destinationCountry.code %}
{% if  shoppingCartData.destinationCountry.code == "" or shoppingCartData.destinationCountry.code == null%}
{% assign destinationCountryCode = shoppingCartData.domainCountry.code %}
{% endif %}
{% if this.items.size > 0 %}
<div class="cms_fake_select">
    <select data-cms_cart_countries="">
        <option value="">Please select</option>
    {% for item in this.items %}
        <option value="{{item.code}}" {% if destinationCountryCode == item.code %} selected="true" {% endif %}>{{item.displayName}}</option>
    {% endfor %}
    </select>
</div>
{% endif %}

Accessing the Data

This data is also accessible directly on the Page or Template via a Liquid Collection by adding collectionVariable to the Component.

An example using collectionVariable with value "countryCollection":

{% component type: "countries", collectionVariable: "countryCollection" %}

Accessing a specific item within the collection. In this case the third item (zero based index), which in our example would render the value ALGERIA

{{countryCollection.items[2]['DisplayName']}}


Related Articles

  • Domains
    The Treepl CMS Domain settings allow you to control default domain, landing pages, domain authentication for system emails along with country and cultural settings like number and currency formatting.
  • Payment Settings
  • Orders
  • Advanced CRM Groups
  • {{ order }} object
    This liquid object will output the order details of a submitted payment. {% capture data...
  • module (Catalogs)
    This module component fetches data relating to eCommerce Catalogs and can be used to render Catalog structures and Products within them.
  • module (Products)
    This module component fetches data relating to eCommerce Products and can be used to render Product information.
  • ecommerce_add_to_cart
    This component renders an anchor element allowing the javascript function to add the item to the shopping cart.
  • ecommerce_buy_now
    This component renders an anchor element allowing the javascript function to add the item to the shopping cart and then proceeding directly to the shopping cart page.
  • ecommerce_item_quantity
    This component renders a form input element allowing a quantity to be set for when the source item is added to the shopping cart.
  • item_attributes
    This component fetches all attributes/options for a specified product. By default, each attribute group is rendered, with its options and any prices, according to their specified form inputs.
  • related_items
    This component fetches related items of a specific source item, such as a Product that has had Related Products assign to it.
  • grouped_items
    This component fetches grouped items of a specific source item, such as a Product that has been Grouped with other Products and allows the ability to navigate between grouped items.
  • currencies
    This component renders a form select element of all currency names, codes and symbols by default, and can also be used to output currency data to a Liquid collection.
  • shopping_cart
    This component fetches data relating to the shopping cart, such as any products added, order totals, tax, shipping, etc.
  • shipping_options
    This component renders a form select element of all shipping options configured on the site, and can also be used to output shipping option data to a Liquid collection.
  • shippingProvidesFields
  • tax_codes
    This component renders a form select element of all tax codes configured on the site, and can also be used to output tax code data to a Liquid collection.
  • payment_form_fields
    This component is used to render payment fields, and payment related validation errors, within a form using the capabilities provided by your configured payment gateway.
  • orders
    This component fetches Orders from the CRM, either owned by the logged-in user or for all customer Orders.
  • Getting Started
    With the recent release of eCommerce features there are some advanced system components that are...
  • Products
    Products are one of the most powerful and flexible modules in Treepl CMS. Create customised product schemas with multiple price points, catalogs, inventory tracked attributes/variables, SEO optimisation and more.
  • Catalogs
    When organising any eCommerce store, Catalogs are crucial to your Products structure and browserbility. Easily create and customise unlimited product catalogs for your online store.
  • Discount codes
    Provide discount code functionality for your Treepl CMS shopping cart. Ideal for promotions, customer loyalty and conversions or to help move more stock.
  • Gift vouchers
    Gift vouchers can be issued to your customers or purchased by them online via the shopping cart.
  • Taxes
    Create any number of required tax codes specific to the shipping country selected in your Treepl CMS shopping cart.
  • domain_settings
    This module component retrieves settings associated with the current domain, or optionally from another specified domain configured in the site instance.
  • Shipping options
    Treepl CMS provides the ability to configure custom shipping options based on a variety of conditions during the shopping cart stage.
  • Settings
  • Migrating to Advanced Payment Flow
    This article describes differences and possible required actions for migrating to the Advanced Payment Gateway flow.

External Resources

There are currently no external resources available.

Please let us know if you have any other contributions or know of any helpful resources you'd like to see added here.


Questions?

We are always happy to help with any questions you may have.
Visit the Treepl Forum for community support and to search previously asked questions or send us a message at support@treepl.co and we will consult you as soon as possible.