-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Markets and currencies #826
Comments
Having the same issue. Would love to know the solution. |
Hey all, The trick is to manually create a checkout with the Shopify SDK who is built-in with the buy button. var client = ShopifyBuy.buildClient({
domain: '',
storefrontAccessToken: '',
language: getLanguage()
});
var input = {
buyerIdentity: {
countryCode: getCountry(),
},
};
var localStorageCheckoutKey = `${client.config.storefrontAccessToken}.${client.config.domain}.checkoutId`;
client.checkout.create(input).then((checkout) => {
localStorage.setItem(localStorageCheckoutKey, checkout.id)
ShopifyBuy.UI.onReady(client).then(function (ui) {
[...]
});
}); |
Thanks Simon for posting your solution! jsyk -- I got reply from Shopify.
Good luck everyone trying to fix this :-) |
In case someone else stumbles upon this issue looking for a solution, I've been able to set the country using a similar method as @simoncrypta and calculating the country from the browser timezone. const client = await ShopifyBuy.buildClient({
domain: '',
storefrontAccessToken: '',
})
const input = {
buyerIdentity: {
countryCode: getUserCountryCode() // See blogpost link below
},
}
const localStorageCheckoutKey = `${client.config.storefrontAccessToken}.${client.config.domain}.checkoutId`
// Prevent creating a checkout if there is already one available
if (!localStorage.getItem(localStorageCheckoutKey)) {
const checkout = await client.checkout.create(input)
localStorage.setItem(localStorageCheckoutKey, checkout.id)
}
const ui = await ShopifyBuy.UI.init(client) Regargind the country calculation, check this blog post: https://www.techighness.com/post/get-user-country-and-region-on-browser-with-javascript-only/ Shopify country codes can be seen here: https://help.shopify.com/en/manual/payments/shopify-payments/multi-currency/international-pricing#country-codes |
All the above is helpfull. Is there also a way to pass the buyerIdentity/countryCode to the product UI as well? We have a WordPress site and utilize the Buy Button for our commerce. We are expanding into Canada and will regionalize our WordPress site. Therefore when a user is in the CA region, we want the price to be the Shopify converted price for CA to show instead of USD. |
@mocodev If you have the price as a css class based element on your CA site, you can create a js function that checks the domain of the client and changes the price to CA based on that, so it will show the client a CA price. Example Buy Button
Hope, that makes sense. |
Just wanted to thank @simoncrypta this solution really works! |
I will also add that - if you expect it to work well with COD then just don't. It's pain - we ended up creating a second store. Shame on @shopify-admins for not solving this for years. I bet investors are happy to have AI features in the latest "editions" all over the place - now please do what Shopify should do. Sell shit... same goes for manual stuff like wire transfers. |
@Toooorch btw here is the answer from Shopify support I got yesterday 19.12.2023 > It is not currently possible to configure multiple local currencies in your existing store. However, setting up a new store with the desired currency is indeed a viable option for you to consider. I want to assure you that your feedback has been duly noted and shared with our team. We greatly appreciate your input and suggestions, as they play a crucial role in shaping future updates to the Shopify system. |
Oh my! What are the @shopify-admins thinking? Duplicating all these products just for currency variations seems excessive, especially since I already have a shop with nearly 700 products... Additionally, while @simoncrypta's solution works for calculating the card sum, it's not accurately retrieving the price in the correct currency. |
@sercan-uzun you are right, regarding the pricing a workaround for few products is to duplicate the product and then set the price to the target currencies price so e.g. Product 600 EUR I 700 CHF And then pull the duplicated product into the cart with converted currency. This way the user sees the correct price on the front end and when they proceed to the next step the price is either already correct, or gets adjusted to the correct price by Shopify. But this is not really feasable for 700 products |
@simoncrypta hi, would you mind letting me know where to paste this code? i am wanting to fix the same problem...i tried just pasting it at the the top of my embedded buy button, but it disabled it... i don't know anything about js. many thanks. |
Hello friends, I have forked a version of the buybutton that supports customAttributes (thx Innovation-Magic-LLC/buy-button-js-customattributes) and added/hacked support for the new cart graphQL API. This means that this version has support for pricing per market and has also line item displayed in the right language. Hope this helps. |
Hello,
We now use markets (and Shopify Payments) to allow our customers to pay in their local currency.
We had already integrated the possibility of retrieving the translated content of the store by setting up the client:
How is it possible to set the currency (or market country)?
When the customer adds a product to the cart and proceeds to payment, the local currency is displayed correctly only when he has entered his delivery address (step 2).
Is it possible to also force the opening of the cart in a certain currency (other than the base currency of the store)?
(we also had to adapt the script to force the language of the shopping cart because the configuration of the language at the client level was not sufficient:
)
Thanks!
The text was updated successfully, but these errors were encountered: