CartThrob 9 documentation for ExpressionEngine commerce teams Visit CartThrob.com
CartThrob.com

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

  1. This is an immediate-execution single tag.
  2. Input is normalized through alpha3_country_code(...) before lookup.
  3. Lookup uses CartThrob locales country list (all_countries()).
  4. If no country match is found, the tag returns the original country_code value.
  5. If country_code is 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}