We been working on a website using the teacommerce-project.
But while devolping the website, we ran into a little problem which we can't figure out - how to solve.
The website is have several languages, DE, UK and DK. and we wish to use different currencies for each country.
DE = € DK = DKK UK = £
We've set up the countries in the Teacommerce tab, we've set up the currencies, we've connected currencies and countries and we've set up the cultures on the pages.
So if we visit the DK-part of the site, it show the danish dictionary items and if we visit the DE-part of the site, it shows the german dictionary items. But the teacommerce:GetCurrentCountry() -extension keep returning the country that we selected as "Default".
So how do I get the teacommerce:GetCurrentCountry() to return the country that matches the culture that the page im visiting is using, instead of it allways returning the default?
The setup sounds like its done the right way. The default country is independent of the hostname/culture and that is why the default country is always returned. The right way to implement this is to hook into the WebshopEvents.OrderCreated. Here you check which node/url is active at the moment and depending on that you set the order.CountryId and save the order. This will set the initial country for the order and then if you still want the customer to be able to change the country in the cart flow he can do that.
We've been working on the solution that you mentioned withWebshopEvents.OrderCreated.
Our purpose is that a new visitor who is looking at the product list, before he put any products in the basket - will be presented with the correct currency.
Are there allways an order? so it's possible to call WebshopEvents.OrderCreated, even if the basket is empty?
A basket is created when ever you use it or interact with it. So if you need your setup you will have to create an order for each visitor ( because its created the first time you need info from the order - in this case a country which you need to set at the order to get the correct currency). Another option is to implement your own Session variable for the current country and use that for presenting the prices. I can send you the code for our "GetPrices" method in the xslt library. So we could try and get your case to work properly :)
We are having the same problem as above, but unfortunatly I do not understand what you mean by "hook into the WebshopEvents.OrderCreated". As far as I can tell, we only have access to the XSLT files, surely there must be some way to make this work using just that?
Here is where I think the problem is, but I might be wrong:
You are right that you can send a specific culture name to the FormatPrice method to format the price using a specific method. So you can just change here to another one.
Okay, but that still changs it to a specific currency. Like the OP I would like to use the currency of the culture of the page. Isn't there an automatic way to do that?
Almost 5 years later this solution does not work for me.
Umbraco 7.5.13, TC 3.2.2, 2 languages in Content and in TC Setting, 2 currencies.
GetPrice returns always default culture price.
I tried to hooked into OrderCreated event, but there is not such property as Order.CountrId. I've found Order.LanguageID, but it is always null and there is no difference if I set it to something else.
What is your case? Try give as much info as possible. The price returned is using the default country (store setting) and the default currency of that country. If you want to switch currency when the user switch country then either you need to only have one currency available in the country and TC will automatically switch. If the currency is still available in the new country then you as a developer need to make the switch.
I think I have same case as Kim (first post): two (so far) nodes in Content with different domains and different languages (da-DK and de-DE in my case).
In TC Settings I have two Countries (Danmark and Germany) and two Currencies (DKK and Euro). I will have one Currency per Country. DKK has CultureName set to da-DK, Euro to de-DE. I'm not sure what about Region Code in Country. Do it need to be the same as CultureName?
All I wish is that when I open danish site, currency is set to DKK, and when I open german site, currency is set to Euro. I won't have any currency picker...
Rememeber, at I have to different domains per language (more to come).
Tea Commerce does not handle that for you. You will have to set the correct currency based on the URL that is loaded and then somewhere in your master template set the currency on page load or something like that.
Ahh that is because the currency was only available in one country each of them and in that case you need to change the country instead and the currency will change automatically.
Multilingual with multiple currencies
Hi there,
We been working on a website using the teacommerce-project.
But while devolping the website, we ran into a little problem which we can't figure out - how to solve.
The website is have several languages, DE, UK and DK. and we wish to use different currencies for each country.
DE = €
DK = DKK
UK = £
We've set up the countries in the Teacommerce tab, we've set up the currencies, we've connected currencies and countries and we've set up the cultures on the pages.
So if we visit the DK-part of the site, it show the danish dictionary items and if we visit the DE-part of the site, it shows the german dictionary items. But the teacommerce:GetCurrentCountry() -extension keep returning the country that we selected as "Default".
So how do I get the teacommerce:GetCurrentCountry() to return the country that matches the culture that the page im visiting is using, instead of it allways returning the default?
Hi Kim
The setup sounds like its done the right way. The default country is independent of the hostname/culture and that is why the default country is always returned. The right way to implement this is to hook into the WebshopEvents.OrderCreated. Here you check which node/url is active at the moment and depending on that you set the order.CountryId and save the order. This will set the initial country for the order and then if you still want the customer to be able to change the country in the cart flow he can do that.
Makes sense? :)
Kind regards
Anders
Hi Anders, thank you for your reply.
Makes perfect sense.
I thought there where some sort of connection between the country and and hostname/culture.
But we'll try walking down the path that you described :)
Hi again
We've been working on the solution that you mentioned with WebshopEvents.OrderCreated.
Our purpose is that a new visitor who is looking at the product list, before he put any products in the basket - will be presented with the correct currency.
Are there allways an order? so it's possible to call WebshopEvents.OrderCreated, even if the basket is empty?
Hi Kim
A basket is created when ever you use it or interact with it. So if you need your setup you will have to create an order for each visitor ( because its created the first time you need info from the order - in this case a country which you need to set at the order to get the correct currency). Another option is to implement your own Session variable for the current country and use that for presenting the prices. I can send you the code for our "GetPrices" method in the xslt library. So we could try and get your case to work properly :)
Kind regards
Anders
Hi Kim
Did you get this to function the way you want?
Kind regards
Anders
Hi Anders
We are having the same problem as above, but unfortunatly I do not understand what you mean by "hook into the WebshopEvents.OrderCreated". As far as I can tell, we only have access to the XSLT files, surely there must be some way to make this work using just that?
Here is where I think the problem is, but I might be wrong:
line 23
<xsl:variable name="currentCurrency" select="teacommerce:GetCurrentCurrency()"/>
line 68
<xsl:variable name="price" select="teacommerce:FormatPriceWithSpecificCulture($priceUnFormatted, $currentCurrency/@cultureName)" />
Hi Allan
You are right that you can send a specific culture name to the FormatPrice method to format the price using a specific method. So you can just change here to another one.
Kind regards
Anders
Okay, but that still changs it to a specific currency. Like the OP I would like to use the currency of the culture of the page. Isn't there an automatic way to do that?
There is no automatic way to do that. You will have to do some work your self :)
Hi Anders,
Almost 5 years later this solution does not work for me.
Umbraco 7.5.13, TC 3.2.2, 2 languages in Content and in TC Setting, 2 currencies.
GetPrice returns always default culture price.
I tried to hooked into OrderCreated event, but there is not such property as Order.CountrId. I've found Order.LanguageID, but it is always null and there is no difference if I set it to something else.
Any help will be appreciated.
Regards
Tomasz
Hi Thomasz
What is your case? Try give as much info as possible. The price returned is using the default country (store setting) and the default currency of that country. If you want to switch currency when the user switch country then either you need to only have one currency available in the country and TC will automatically switch. If the currency is still available in the new country then you as a developer need to make the switch.
https://docs.teacommerce.net/v3.0.0/reference#setcurrentcurrency
Kind regards
Anders
Hi Anders,
Thank you for quick response.
I think I have same case as Kim (first post): two (so far) nodes in Content with different domains and different languages (da-DK and de-DE in my case).
In TC Settings I have two Countries (Danmark and Germany) and two Currencies (DKK and Euro). I will have one Currency per Country. DKK has CultureName set to da-DK, Euro to de-DE. I'm not sure what about Region Code in Country. Do it need to be the same as CultureName?
All I wish is that when I open danish site, currency is set to DKK, and when I open german site, currency is set to Euro. I won't have any currency picker...
Rememeber, at I have to different domains per language (more to come).
I hope this is more understandable now :)
Kind regards Tomasz
Hi Tomasz
Tea Commerce does not handle that for you. You will have to set the correct currency based on the URL that is loaded and then somewhere in your master template set the currency on page load or something like that.
Kind regards
Anders
I've tried changing Currency "on-page-load" before, but it didn't work.
Now I tried changing payment country (TC.SetCurrentPaymentCountry) instead and now it works as supposed!
Thank you for help!
Kind regards
Tomasz
Ahh that is because the currency was only available in one country each of them and in that case you need to change the country instead and the currency will change automatically.
Kind regards
Anders
is working on a reply...