Manthan Kanani
Manthan Kanani

Reputation: 56

How to do currency conversion with js in shopify using AJAX shopify api?

I'm building a Shopify app and need to implement currency conversion for various international currencies. I'm looking for an shopify API that provides accurate and reliable exchange rates with good uptime.

I understand that most currency conversion APIs might not guarantee 100% uptime, but I'm seeking recommendations for an shopify API if possible that offers the best reliability and support.

Any suggestions for a suitable shopify API that integrates well with Shopify?

Upvotes: -3

Views: 322

Answers (1)

Manthan Kanani
Manthan Kanani

Reputation: 56

One option you can consider is the Shopify's own currency conversion API, which is powered by the Cloudflare CDN and provides good reliability. Here's the link to the API

https://cdn.shopify.com/s/javascripts/currencies.js

Note that this API doesn't provide data in pure JSON format, but you can still use it in your frontend implementation. I've used this API in my projects, and it has been quite stable with minimal downtime.

Remember to review the API documentation and terms of use before integrating it into your Shopify app.

Use this following code and loop through it for all currency box which has been wrapped with specific html class or tag.

var amountInUSD = 100;
var convertedAmount = Currency.convert(amountInUSD, 'USD', 'EUR');
console.log(convertedAmount);
<script type="text/javascript" src="https://cdn.shopify.com/s/javascripts/currencies.js"></script>

Upvotes: 0

Related Questions