Shopify Exchange Rates: Local Prices, Converter, Market Sync
Step by step: add a currency converter to Shopify product pages, show an estimated local price, or sync fixed market prices nightly through the Admin API.
With Shopify Payments and Shopify Markets, Shopify converts checkout prices at its own rates, and you can set a manual rate per market in the Markets settings. This guide covers what Markets does not do: a converter on product pages, an estimated local price on a store that sells in one currency, and fixed market prices set from a rate and rounding rule you control.
Before you start
- Shopify admin access with permission to edit themes (Parts A and B). Part C also needs a custom app with Admin API access. Fixed-price availability depends on your Shopify plan, so check Shopify's Markets documentation.
- Which rate you want. This guide uses live mid-market rates for 160+ currencies, not a central bank table. For bookkeeping at an official rate, see the finance team guides.
- An AllRatesToday account (free, no card). Needed for Parts B and C. Create one here.
Part A: Embed a currency converter (no code)
A converter on the product page, pre-filled with the product's price. It uses the daily ECB reference rates (30+ major currencies).
-
Open the theme editor
Go to Online Store → Themes and click Customize on your live theme. Switch the page selector at the top to your product template.
-
Add a Custom Liquid block
In the product section, click Add block and choose Custom Liquid. Paste this:
<div class="art-currency-widget" data-base="{{ cart.currency.iso_code }}" data-target="EUR" data-amount="{{ product.selected_or_first_available_variant.price | divided_by: 100.0 }}"></div> <script async src="https://allratestoday.com/widget.js"></script>Change
data-targetto the currency you want to show. Don't adddata-api-keyin a theme, because theme code is public. See the widget reference. -
Save and preview
Click Save and open a product page.
You should see: a converter under the product, showing the price in your shop currency and the target currency.
Part B: Show an estimated price in the visitor's currency
Detect the visitor's currency with the IP-to-currency endpoint, then fetch the live rate (160+ currencies) through a small proxy. A theme's JavaScript is visible to anyone, so never put your API key in the theme. A developer does steps 3 and 4 once.
-
Copy your API key
Log in and open Profile → API Keys. Click Copy next to the key that starts with
art_live_. -
Test it in your browser
Paste this into the address bar, with your key in place of the example:
https://allratestoday.com/api/v1/rates?source=USD&target=EUR&api_key=art_live_your_keyYou should see: a short JSON answer with
"rate"(EUR per 1 USD) and"time"(when the rate was taken).This test is the only place the key goes in a URL. In the store it lives in the proxy (next step).
-
Deploy a rate proxy
Create a Cloudflare Worker with this code. Add your API key as the secret
ALLRATES_KEYand your store's URL asSTORE_ORIGIN. Each Cloudflare location fetches a currency pair at most once every 15 minutes, however much traffic you get, so a busy store still uses only a few thousand calls a month.// Cloudflare Worker (free plan is enough): holds your key, caches each rate 15 min. export default { async fetch(req, env, ctx) { const url = new URL(req.url); const from = (url.searchParams.get('from') || '').toUpperCase(); const to = (url.searchParams.get('to') || '').toUpperCase(); if (!/^[A-Z]{3}$/.test(from) || !/^[A-Z]{3}$/.test(to)) { return new Response('{"error":"from and to must be ISO 4217 codes"}', { status: 400 }); } const cacheKey = new Request(`https://rates.internal/${from}-${to}`); let res = await caches.default.match(cacheKey); if (!res) { const r = await fetch( `https://allratestoday.com/api/v1/rates?source=${from}&target=${to}`, { headers: { Authorization: `Bearer ${env.ALLRATES_KEY}` } } ); if (!r.ok) return new Response('{"error":"rate unavailable"}', { status: 502 }); const [{ rate }] = await r.json(); res = new Response(JSON.stringify({ from, to, rate }), { headers: { 'Content-Type': 'application/json', 'Cache-Control': 'max-age=900' }, }); ctx.waitUntil(caches.default.put(cacheKey, res.clone())); } const out = new Response(res.body, res); out.headers.set('Access-Control-Allow-Origin', env.STORE_ORIGIN); // e.g. https://yourstore.com return out; }, };You should see: opening
https://rates.yourname.workers.dev/?from=USD&to=EURreturnsfrom,toandrate. -
Add the snippet to your product template
Go to Online Store → Themes, open the … menu on your theme and click Edit code. Add this under the price in your product section (or paste it in a Custom Liquid block as in Part A). Replace
rates.yourname.workers.devwith your Worker's address.{%- comment -%} sections/main-product.liquid, under the price {%- endcomment -%} <p class="approx-local-price" hidden data-amount="{{ product.selected_or_first_available_variant.price | divided_by: 100.0 }}" data-currency="{{ cart.currency.iso_code }}"></p> <script> (async () => { const el = document.querySelector('.approx-local-price'); if (!el) return; try { // 1. Visitor's currency from their IP const { currency } = await fetch('https://allratestoday.com/api/open/geo').then(r => r.json()); if (!currency || currency === el.dataset.currency) return; // 2. Rate through your Worker, so the key stays private const { rate } = await fetch( 'https://rates.yourname.workers.dev/?from=' + el.dataset.currency + '&to=' + currency ).then(r => r.json()); const local = new Intl.NumberFormat(undefined, { style: 'currency', currency }) .format(el.dataset.amount * rate); el.textContent = 'About ' + local + ' (estimate, you pay in ' + el.dataset.currency + ')'; el.hidden = false; } catch (e) { /* leave the shop price on its own */ } })(); </script>product.priceis in cents in the cart's currency, which is why the snippet divides by 100 and converts fromcart.currency.iso_code. Label the result as an estimate if you still charge in your own currency. -
Save and preview
Click Save and open a product page from a different country (or through a VPN).
You should see: "About €… (estimate, you pay in USD)" under the price. Visitors in your shop currency see nothing extra.
Part C: Sync fixed market prices every night
If you sell in several currencies, Markets can use fixed prices from a price list instead of automatic conversion. A nightly job can recompute those prices from the day's mid-market rate and apply your own rounding, so your EUR prices follow the dollar without converting at checkout.
-
Get an Admin API access token
Create a custom app for your store with Admin API access and install it. Copy its Admin API access token. Keep it secret, like your AllRatesToday key.
-
Find the market's price list ID
Each market with fixed prices has a price list. Your developer reads its ID (it looks like
gid://shopify/PriceList/123456789) from the Admin GraphQL API. -
Run the sync script
Set
ALLRATES_KEYandSHOPIFY_ADMIN_TOKENas environment variables, fill in your shop, price list ID and variants, and run it with Node:// sync-market-prices.mjs: run nightly (cron, GitHub Actions, a Worker cron). // Sets fixed EUR prices on a market's price list from today's USD->EUR rate. const SHOP = 'yourstore.myshopify.com'; const PRICE_LIST_ID = 'gid://shopify/PriceList/123456789'; const VARIANTS = [ { id: 'gid://shopify/ProductVariant/111', usd: 49.0 }, { id: 'gid://shopify/ProductVariant/222', usd: 129.0 }, ]; const [{ rate }] = await fetch( 'https://allratestoday.com/api/v1/rates?source=USD&target=EUR', { headers: { Authorization: `Bearer ${process.env.ALLRATES_KEY}` } } ).then(r => r.json()); // Charm pricing: round up to the next whole euro, minus one cent. const charm = (x) => (Math.ceil(x) - 0.01).toFixed(2); const prices = VARIANTS.map(v => ({ variantId: v.id, price: { amount: charm(v.usd * rate), currencyCode: 'EUR' }, })); const res = await fetch(`https://${SHOP}/admin/api/2025-10/graphql.json`, { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Shopify-Access-Token': process.env.SHOPIFY_ADMIN_TOKEN, }, body: JSON.stringify({ query: `mutation($id: ID!, $prices: [PriceListPriceInput!]!) { priceListFixedPricesAdd(priceListId: $id, prices: $prices) { prices { variant { id } price { amount currencyCode } } userErrors { field message } } }`, variables: { id: PRICE_LIST_ID, prices }, }), }).then(r => r.json()); console.log(`USD->EUR ${rate}`, JSON.stringify(res.data.priceListFixedPricesAdd));One run costs a single rate call. For many currencies, request them together (
target=EUR,GBP,CAD) and loop over the rows.You should see: the rate and the list of updated variant prices, with an empty
userErrors. -
Schedule it nightly
Run the script once a night from cron, GitHub Actions or a Worker cron trigger.
Check it worked
- Part A and B: open a product page. The converter or estimate shows under the price.
- Part C: in the Shopify admin, open the market's product pricing. The fixed EUR prices match your rounding rule.
- Checkout in your shop currency is unchanged for Parts A and B.
If something goes wrong
| What you see | What to do |
|---|---|
| Converted price far too big or small | The rate is the wrong way round. source (or from) is the shop currency, target (or to) the visitor's currency. |
401 or "API key" error in the browser | The key is missing or mistyped. Copy it again from Profile. |
| No estimate under the price | The visitor's currency is the same as the shop's, or the request failed. The snippet then leaves the shop price on its own. Check the browser console. |
| Browser console shows a CORS error | STORE_ORIGIN in the Worker does not match your store's address exactly, for example https://yourstore.com. |
Worker returns "rate unavailable" | The Worker could not reach AllRatesToday with its key. Check the ALLRATES_KEY secret. |
Worker returns "from and to must be ISO 4217 codes" | The theme sent an empty or invalid currency. Check the data-currency attribute. |
userErrors in the sync output | Wrong price list ID or variant ID, or the app lacks access. Fix the IDs or the app's Admin API access. |
Which plan do I need?
| Option | Key | Typical usage |
|---|---|---|
| Converter widget | None in the theme (ECB rates) | Unmetered |
| Estimated local price | Paid plan (commercial use), from €4.99/mo | Up to about 2,900 calls/mo per currency pair per Cloudflare location (15-minute cache) |
| Nightly price sync | Paid plan, from €4.99/mo | About 30 calls/mo |
A store is commercial use, which starts on the €4.99 plan. Build and test on the free key first. Plans and limits are on the pricing page.
FAQ
Will this change what customers pay?
Parts A and B only display information, so checkout is unchanged. Part C changes the fixed prices in a market's price list, which customers in that market then pay.
Can I put the API key in my theme?
No. Theme code is public, so anyone could copy the key and use your quota. Keep it in a proxy, as in Part B.
Which rate does Shopify use for automatic conversion?
Shopify's own rates, plus its conversion fee where it applies. This guide doesn't change that. It adds information or sets fixed prices that replace automatic conversion for a market.
Related
Other integrations: Xero · QuickBooks Online · Salesforce · all integrations. Endpoint reference: API documentation.