DOCS

Currency conversion

/

Currency conversion

Use Hello to handle currency conversion on your site.

SKILLS NEEDED : Advanced developer skills

You can provide Zonos Hello with the CSS selectors for the price elements on your site. Zonos Hello will take the text of the elements and use foreign exchange rates to convert them to display the foreign currency. You can pass the CSS selectors into config with the currencySelectors property.

Hello integration script

1
zonos.config({ currencySelectors: ".money, .price, #subtotal" });

You can re-trigger the currency conversion by calling the following JavaScript:

Hello integration script

zonos.displayCurrency();

Calling displayCurrency may be needed if your site is loading product information dynamically after the page has loaded.

If further customization is needed, you can provide a custom converter. The converter should be a Javascript function that takes three arguments.

  1. A function that takes a number and returns a string with the converted price formatted for display.
  2. A function that takes a number and returns the converted price as a number.
  3. A function that takes a number in the foreign currency and returns a string formatted for display.
zonos.config({
  currencyConverter: (convertAndFormat, convert, format) => {
    // a price from your page
    const price = 12.34;

    // a formatted string (ie "CA$17.60")
    const displayPrice = convertAndFormat(price);

    // a number (ie. 17.6)
    const foreignPrice = convert(price);

    // a formatted string (ie "CA$17.60")
    const displayPriceAgain = format(foreignPrice);
  },
});

Frequently asked questions 

I'm not a developer and need assistance. What are my options?

Zonos offers custom development work at an additional cost. Pricing depends on the amount of work requested.

Was this page helpful?