If looking to Enoteca case then you need to enable Marketplace selection in header.
Go to HeaderCommands.ascx and look for 'MarketPicker' control, set Visibility to 'True'.
This will give you possibility to change markets. By changing markets we can see code:
SiteContext.Current.Currency = currentMarket.DefaultCurrency;
Which will set your new currency and create a cookie for you to store preferred cuurency and restore SiteContext during next request.
Hope this helps!
How does the MarkedPicker work? Where can I add more "Markets"?
Is this the prefered way of letting the customer select language and currency? (instead of the langage picker that existed in the ClickTalk demo site)
I would try to distinquish between UI culture (by setting that you should be able to change display language for the site) and market culture (by setting this you actually are switching differnet market / currency). ClickTalk and Enoteca is mixed-match these things in my opinion.
"New markets" are available via Mediachase.Commerce.Markets.IMarketService.
we are still having big issues with the languages :)
when I change language on a "normal" cms page it works and I get "/en-us/page-title" but when I change language while on a product page it just changes back to EN-US. My languagepicker changes like this:
public void SetCurrentLanguage(CultureInfo culture)
{
ContentLanguage.PreferredCulture = culture;
SiteContext.Current.LanguageName = culture.Name;
CatalogContext.MetaDataContext.UseCurrentUICulture = true;
Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture = culture;
}
And then I have added a custom PageBase with an overridden InitializeCulture
protected override void InitializeCulture()
{
var currentLang = ContentLanguage.PreferredCulture.Name;
var currentCulture = new CultureInfo(currentLang);
ContentLanguage.PreferredCulture = currentCulture;
SiteContext.Current.LanguageName = currentLang;
CatalogContext.MetaDataContext.UseCurrentUICulture = true;
Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture = currentCulture;
}
To make sure that it right at all time, but as I said, the PreferedCulture is set to "de-de" when I change the dropdown but then when the page is loaded the PreferedCulture is "en-us" again.
Seems something is setting the fallback culture or something.
PreferredCulture is stored in current HttpContext Items collection which is survives only current request.
If you take a look at EPiServer.Business.Commerce.Providers.CatalogEntryPageRoute class it's using ICurrentMarket implementation to restore preferred content culture.
On next request (when preferred culture is reset back to en-US) what does this guy return?
ServiceLocator.Current.GetInstance<ICurrentMarket>().GetCurrentMarket().DefaultLanguage.Name
Thank you for your answer!
ServiceLocator.Current.GetInstance<ICurrentMarket>().GetCurrentMarket().DefaultLanguage.Name returns "en-us", which seems wrong.
But how do you suggest I change the culture?
When I contacted the support about the Markets I got this answer, telling me that I should not use Markets.
Dear Andreas,
Market is a new concept that was introduced in Commerce R3 to better support prices in different markets as several countries can have the same currency but maybe not the same price.
However, Markets can't be used in R3 and will be properly introduced in Commerce 7. Right now you will have to use the old system of fetching prices by specifing the currency, just like R2 and earlier versions. The only differance is that you can use the IPriceService to get prices instead.
Best regards,
EPiServer Developer Support
I'm working with Enoteca sample site, it is R3 running on EPiServer 7.
I'm trying to change the default en-US site language so that SiteContext.Current.Currency becomes NOK (Norwegian).
My steps (so far):
If I try to navigate to startpage enoteca/nb-NO I'm automatically redirected to enoteca/en-US. The currency is still USD.
I'm obviously missing something here. How can I change SiteContext.Current.Currency? (I assume currency is set based on currect language...)