Open navigation

Customize Multi-Currency

Follow the steps below to enable currency switching in Klevu search results.

  1. Login into Shopify Admin
  2. Go to Online Store → Custom theme → Edit HTML/CSS
  3. Go to Edit layout
  4. Open theme.liquid file
  5. Add below code before </body> tag
    <script>
     function getCurrencyRatesObject() {
       var currencySymbol,
        rates = Currency.rates,
        klevu_rates = [],
        appendCurrencyAtEnd = [];
        
      for (var prop in rates) {
        currencySymbol = prop === "USD" ? "$" : prop;
        klevu_rates[prop] = (1 / rates[prop]) + ":" + currencySymbol + ":" +
                            (appendCurrencyAtEnd.indexOf(prop) > -1);
        }
        return klevu_rates;
     }
     var klevu_currentCurrencyRates = getCurrencyRatesObject();
     var klevu_currentCurrencyCode = "CAD";
     </script>
  6. Refresh your browser cache.
In appendCurrencyAtEnd array, add currency codes for the currencies which you want to show after amount, e.g. {amount} EUR, as follows:
appendCurrencyAtEnd = ["EUR","SEK"];
Please note, the value of the variable klevu_currentCurrencyCode should be set and updated as per the currently selected currency on the store.
The format of klevu_currentCurrencyRates Object is as follows.
{ currencyCode : "currencyRate:currencySymbol", .... }
If you need to update the currencySymbols, you could do so by updating the following code in the getCurrencyRatesObject function.
currencySymbol = prop === "USD" ? "$" : prop;
On search landing page, if the user selects another currency, please update the value of klevu_currentCurrencyCode and call the following function to reload the results with new currency.
klevu_getSearchResults();

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.