Countries
countries is a tag pair that loops through the configured country list and outputs country code + country name variables for each row.
By default, country codes are Alpha-3 (USA, CAN, GBR). With alpha2, the code output switches to Alpha-2 (US, CA, GB).
To edit the list of countries that are used, see Locales Config.
See also:
Parameters
alpha2
Switches country_code output from Alpha-3 to Alpha-2 format.
Example Alpha-2 output: US, GB, CA, DE.
alpha2="yes"
orderby
Sort key for loop output.
Default: country.
Supported values:
country(sort by country name)country_code(sort by code)countries:countrycountries:country_code
Invalid values fall back to country.
orderby="country_code"
Variables
country_code
Country code for the current loop row.
Default format is Alpha-3 unless alpha2="yes" is set.
{country_code}
USA
country
The name of the country.
{country}
United States of America
countries:country_code
Namespaced alias of country_code.
{countries:country_code}
countries:country
Namespaced alias of country.
{countries:country}
Behavior and Constraints
- This is a looping tag pair; output comes from the tag body.
- Country rows come from
ee()->locales->countries(...)(configured locales/country list). - Sorting is always ascending and uses
orderby. - There is no built-in
limit/offsetparameter on this tag. - If configured locales restrict countries, only allowed countries are returned.
Examples
Default Alpha-3 code output:
<select name="country_code">
{exp:cartthrob:countries}
<option value="{country_code}">{country}</option>
{/exp:cartthrob:countries}
</select>
Alpha-2 codes:
<select name="country_code">
{exp:cartthrob:countries alpha2="yes"}
<option value="{country_code}">{country}</option>
{/exp:cartthrob:countries}
</select>
Sort by country code:
{exp:cartthrob:countries orderby="country_code"}
{country_code} - {country}<br>
{/exp:cartthrob:countries}