Multi-Currency Convertion vs currency.js

Highlighted
Shopify Partner
2 0 0

We are a developer team of a currency conversion app for Shopify. Our conversion is done via javascript, very similar to what is described here: https://help.shopify.com/en/themes/customization/currencies/show-multiple-currencies

Now I noticed in my DEV store that the multi-currency was enabled in Shopify and I directly customized Geolizr to work with both enabled and disabled multi-currency in Shopify. 
Unfortunately, I noticed that https://cdn.shopify.com/s/javascripts/currencies.js seems to use a different exchange rate than the one used by the server. 
According to google exchange rate 100USD becomes 87,85 Euro.
If I have a product that costs 100 USD, it will cost €89.95 (difference €2.10).
If I use the javascript solution it will cost 100 USD but €88.31 (difference € 0.46).
Is there a special rounding in the server solution - function so that it comes out an even amount?

Best regards
Frank

0 Likes
Highlighted
Shopify Partner
5 0 0

I have the same issue. I wonder what I'm doing wrong


var p = 1099;
var c = Currency.convert(p,'USD','GBP');
var f = 1.5 / 100 * c;
console.log(`Currency(GBP):`, c, f, Math.round(c+f));
// Currency(GBP): 959.9120534907536
// ..should be 963.00
var c = Currency.convert(p,'USD','CAD');
var f = 1.5 / 100 * c;
console.log(`Currency(CAD):`, c, f, Math.round(c+f));
// Currency(CAD): 1612.9794900862967
// ..should be 1,616.00
var c = Currency.convert(p,'USD','EUR');
var f = 1.5 / 100 * c;
console.log(`Currency(EUR):`, c, f, Math.round(c+f));
// Currency(EUR): 1043.1137668555612
// ..should be 1,035.95

0 Likes