Pass Locale parameter using Buy Button

Tofolux
Tourist
9 0 5

Is it possible to pass the locale using the buy button?

For example, here is the same checkout page with the string "&locale=“ to the end of the link which displays the same page but in different languages.

EN: (English)

https://checkout.shopify.com/10190495/checkouts/6e63cfb3922db5ded985e63084293394?api_key=dd956ac8aca...

 

FR: (French)

https://checkout.shopify.com/10190495/checkouts/6e63cfb3922db5ded985e63084293394?api_key=dd956ac8aca422ce0fc3ee14e92f418d&locale=fr

So, what i need is to customize the generated buy button code to launch whatever locale I choose.

Hope that makes sense?

Thilo_Kirsch
New Member
1 0 0

Hey, I have the same question. I noticed that if I append '&locale=fr' to the checkout url, the checkout is loaded with French gui. BUT, how to add this to my Buy Button code?

Thank you so much
Thilo

0 Likes
marcd
Excursionist
14 1 3

Anyone found a solution for this?

 

Found it (not mine solution)

 

I needed to add a local parameter to the checkout URL and I manage to do it. Here's what I did.
On the cart object, I added an event :

 

events: {
	afterInit: (cart) => {
		cart.onCheckout = () => {
			const checkoutUrl = cart.model.webUrl + '&locale=en';
			// we dynamically change the checkout function.
			cart.checkout.open(checkoutUrl);
		};
	},
},
0 Likes
Benlaf
New Member
1 0 0

Wow, I was looking for this kind of code for months! Thank you

0 Likes