Shopify themes, liquid, logos, and UX
Hi, I have mentioned price in GBP on a button attaching image for that, now I want it to change automatically if the user in USA. It should change its price to USD and its value as well, I have mentioned price in some texts as well, I want it to get change automatically, how can I do that.
Store Url - https://www.abimax.com/
hi @hem0903
To automatically fluctuate the price depending on where the user is located, you can utilize Shopify's Geolocation API or use a currency exchange app. This is how to do it:
Solution 1: Utilize Shopify Markets (If Enabled)
In case Shopify Markets is activated, Shopify automatically picks up where the user is and adjusts the price according to their currency setting.
Navigate to Settings > Markets within your Shopify admin.
Enable international pricing and configure currency conversion for various regions.
Make sure you have a currency selector activated in your theme.
Solution 2: Dynamic Currency Conversion using JavaScript
If you prefer to implement currency conversion manually on buttons and text, you can use JavaScript with an exchange rate API (such as Shopify's currency data or Open Exchange Rates).
fetch('https://ipapi.co/json/')
.then(response => response.json())
.then(data => {
let userCountry = data.country_code;
let priceElement = document.getElementById("price-button");
if (userCountry === "US") {
let priceInGBP = 50; // Example GBP price
let exchangeRate = 1.25; // Example GBP to USD rate
let priceInUSD = (priceInGBP * exchangeRate).toFixed(2);
priceElement.innerText = `$${priceInUSD} USD`;
}
});
Steps to Use:
Substitute "price-button" with the actual ID/class of the button where the price is shown.
You can use this script for all fields where the price is stated.
Dotsquares Ltd
Problem Solved? ✔ Accept and Like solution to help future merchants.
Hey Community 👋 Did you know that March 15th is National Everything You Think Is W...
By JasonH Apr 1, 2025Discover how to increase the efficiency of commerce operations with Shopify Academy's l...
By Jacqui Mar 26, 2025Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025