SiteContext.Current.Currency

Vote:
 

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):

  • In Commerce Manager, Administration, System Settings, Dictionaries, Languages --> Add Code nb-NO and Norwegian
  • In Commerce Manager, System Settings, Common Settings --> Set default Currency to Norwegian krone
  • In Commerce Manager, Catalogs --> Edit Wine catalog, and added Norwegian to "other languages" (CTRL select)
  • In Commerce Manager, Catalogs --> Add Norwegian text and price to a product SKU
  • In CMS admin and edit --> Enabled Norsk (nb-NO) as site language, and created a Norwegian version of the start page

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...)

#65714
Feb 06, 2013 15:09
Vote:
 

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!

#66034
Feb 18, 2013 17:56
Vote:
 

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)

#75878
Oct 09, 2013 14:56
Vote:
 

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.

#75890
Oct 10, 2013 1:53
Vote:
 

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.

#76557
Edited, Oct 28, 2013 20:31
Vote:
 

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

    

 

#76558
Oct 28, 2013 21:13
Vote:
 

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

#76568
Oct 29, 2013 8:00
Vote:
 

I would look for some custom stateless solution - to write user's selected language back to cookies and restore PreferredCulture back from cookie while processing next request.

#76632
Oct 30, 2013 8:49