SaaS CMS has officially launched! Learn more now.

Commerce newbie question CurrencyCode vs Cart.BillingCurrency

Vote:
 

Hi 

I am currently working on a legacy system (EPiServer Commerce 1R2 - SP2), both CurrencyCode (from SiteContext.Current) and BillingCurrency (from CartHelper.Cart) have been used in the solution from different user controls. 

I searched 1R3 SDK, it said CurrencyCode was deprecated. 

My questions is if I want to format the currency in 1R2, which method should I use? Does BillingCurrency alway have value set for both anonymous user and eixsting customer?

Thanks

#87607
Jun 18, 2014 2:47
Vote:
 

Can any one help to clarify my question?

#87663
Jun 19, 2014 3:20
Vote:
 

Hi.

BillingCurrency should always be populated for both exisiting users and anonymous. The Code listet below is from the CartHelper implementation. This code sample is from 7.5, but I do not think this implementation has changed appart from Market. The market feature was included in R3 (API) and fully functional from 7.5.

  public Cart GetCart(string name, Guid customerId, MarketId marketId)
        {
            Cart cart = Cart.LoadCartsByCustomerAndName(customerId, name).SingleOrDefault<Cart>((Cart c) => c.MarketId == marketId) ?? this.CreateCart(name, customerId, marketId);
            return cart;
        }

  private Cart CreateCart(string name, Guid customerId, MarketId marketId)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentException("Name parameter can't be null or empty", "name");
            }
            if (customerId == Guid.Empty)
            {
                throw new ArgumentException("CustomerId parameter can't be null or empty", "customerId");
            }
            Cart currencyCode = (Cart)OrderContext.Current.ShoppingCartClassInfo.CreateInstance();
            currencyCode.Name = name;
            currencyCode.BillingCurrency = CommonSettingsManager.GetDefaultCurrency().CurrencyCode;
            currencyCode.CustomerId = customerId;
            currencyCode.MarketId = marketId;
            return currencyCode;
        }

#87727
Jun 20, 2014 12:12
Vote:
 

Mediachase.Commerce.Shared.CurrencyFormatter.FormatCurrency(YourPrice, DefaultCart.BillingCurrency)

DefaultCart is Mediachase.Commerce.Orders.Cart

/K

#87730
Jun 20, 2014 12:34
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.