Open navigation

How to change the currency keyword to currency symbol in recommendation banners?

It is possible to change the currency keyword (i.e. USD) showing up in the recommendation banners to a currency symbol (i.e. $) with the help of a minor script change.

The following script should be added below the "https://js.klevu.com/recs/v2/klevu-recs.js" file in your source code.

You can use the following script as it is for the currency keyword "USD":

klevu.coreEvent.attach("setRemoteConfigRecsBaseUpdates", {
    name: "klevuRECSCustomizationCurrency",
    fire: function () {
        klevu.recs.base.getScope().chains.search.control.add({
            name: "productCurrencyRECS",
            fire: function (data, scope) {
                var parentScope = scope.recsScope;
                parentScope.searchObject.getScope().currency.setCurrencys({
                    'USD': {
                        string: "$",
                        format: "%s %s",
                        atEnd: true,
                        precision: 2,
                        thousands: ".",
                        decimal: ",",
                        grouping: 3
                    }
                });
                parentScope.searchObject.getScope().currency.mergeToGlobal();
            }
        });
    }
});

You can add additional currencies in the above script if your store uses multiple currencies. Below is the snippet for your reference:

 string: "€",
       format: "%s %s",
       atEnd: true,
       precision: 2,
       thousands: " ",
       decimal: ",",
       grouping: 3
},
'GBP': {
       string: "£",
       format: "%s%s",
       atEnd: true,
       precision: 2,
       thousands: " ",
       decimal: ".",
       grouping: 3
}

Please feel free to reach out to our support team at support@klevu.com if you need further assistance.

Did you find it helpful? Yes No

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