Convert Country Code
convert_country_code converts a supplied country code to a country name.
Unlike view_country_name, this tag normalizes Alpha-2 codes to Alpha-3 first, so it can handle both formats in most cases.
See also:
Parameters
country_code
Country code to convert to a country name.
Accepted input can be Alpha-3 (USA) or Alpha-2 (US).
country_code="USA"
country_code="US"
Behavior and Constraints
- This is an immediate-execution single tag.
- Input is normalized through
alpha3_country_code(...)before lookup. - Lookup uses CartThrob locales country list (
all_countries()). - If no country match is found, the tag returns the original
country_codevalue. - If
country_codeis missing, output is empty.
Example
Basic conversion:
{exp:cartthrob:convert_country_code country_code="USA"}
Alpha-2 conversion:
{exp:cartthrob:convert_country_code country_code="US"}
Use with customer data:
{exp:cartthrob:customer_info}
{exp:cartthrob:convert_country_code country_code="{customer_country_code}"}
{/exp:cartthrob:customer_info}