View Converted Currency
view_converted_currency converts through the cartthrob_view_converted_currency extension hook only. The hook receives the sanitized amount and returns the final output.
Without that hook, the tag formats the original amount without converting it. use_prefix="yes" adds the prefix selected by new_currency_code; template debugging explains that no conversion hook is installed. CartThrob makes no external currency request of its own.
See also:
Parameters
- price
- new_currency_code
- use_prefix
- Legacy currency_code and api_key
price
Amount supplied to the hook, or formatted unchanged when no hook is active. Non-numeric characters are sanitized out and the amount is converted to an absolute number before the hook runs. If price is missing, output is empty.
price="10"
new_currency_code
Currency code for the unconverted fallback’s prefix when use_prefix="yes". Defaults to the store’s Currency Code setting (number_format_defaults_currency_code). It does not supply an exchange rate.
new_currency_code="GBP"
use_prefix
Optional boolean-style value; default no. Without a hook, a true value adds the currency prefix selected by new_currency_code, such as $, £ or €, before number formatting.
use_prefix="yes"
currency_code
The tag does not read this parameter. A custom conversion hook may read it from the tag parameters if that integration needs a source currency.
api_key
This parameter is ignored; CartThrob makes no built-in exchange-rate request.
Behavior and Constraints
The hook receives the sanitized price only. It can read other tag parameters itself, perform the conversion and return the final formatted output. Its return value is used directly: CartThrob does not apply fallback formatting or a currency prefix afterward.
When no hook is active, changing new_currency_code changes only the optional prefix, not the amount. The default prefix currency uses the store’s Currency Code setting (number_format_defaults_currency_code).
Examples
With a conversion hook installed, its implementation decides how to use the requested currency:
{exp:cartthrob:view_converted_currency price="10" new_currency_code="GBP"}
Without a hook, this formats the original amount with a Euro prefix; it does not convert 25.99 to another currency:
{exp:cartthrob:view_converted_currency
price="25.99"
new_currency_code="EUR"
use_prefix="yes"}