A free, open-source Shopify currency converter app, and how it's built
Most Shopify currency converter apps do one thing: they swap every price on the storefront into the visitor's currency. That is useful, but Shopify Markets already does it for free. What it doesn't do is let a shopper check a conversion themselves, or show the official rate a central bank published, which matters when you quote, invoice or ship goods across a border. So we built a small, free,…
Most Shopify currency converter apps only swap prices into a buyer's currency. However, Shopify Markets lacks a feature enabling shoppers to check conversion rates themselves or display official rates published by central banks. To address this void, the author created a free, open-source Shopify app with two theme blocks: a currency converter and an official rate.
The app, AllRates-Today/allratestoday-shopify, is available on GitHub under the MIT license. This article outlines the app's development process, so readers can use it as is or build upon it for their own theme app extensions.
The app's components are implemented as theme app extensions, which Shopify hosts on its CDN. Merchants add the blocks in the theme editor without modifying theme files. This approach aligns with Shopify's requirement 5.1.1, which mandates the use of theme app extensions for storefront modifications.
The currency converter block renders an empty div with data attributes. JavaScript then transforms this div into the converter. The block accepts settings such as the starting amount, target currency, and theme color. Prices are in cents, so the script divides the product price by 100.0 to obtain a float value. The shopper's currency is utilized instead of the store's currency, ensuring accuracy.
The official rate block functions similarly, accepting attributes such as the bank code, source, target currency, and theme color. It displays the exchange rate along with the date the bank published it, catering to accounting and customs requirements. The app's home page and Shopify API require a Shopify App Store listing, as the review checklist rejects apps without API usage. The app uses App Bridge to obtain an ID token, which is then sent to a small backend for verification.
Rewritten by urgent.news; may contain errors — check the original. How we use AI.
Source: dev.to