4

I'm using Sitecore 9.0 Update 1 and XC9 Update 1 in a project for a European customer.

We created our own environment based on the OOTB Habitat-environment. In the config-file we set EUR to be the default currency. USD was always just added as an option.

In my "Currency Configuration" I use the currency set "Default", which has "EUR" assigned as default currency.

Also all prices, that are assigned to the sellable items (wether list prices or price cards / price card snapshots), use just EUR as currency.

But when I try to add a product to the cart, that does not have a USD-price assigned, I get the following error in the commerce engine log:

ERROR CtxMsg.Error.LineIsNotPurchasable: Text=Item 'My Product' is not purchasable.

But if I add a price with currency "USD", it works fine. I assume, I'm doing something wrong, sadly I wasn't able to figure out what it is.

I use the CartServiceProvider from the Sitecore.Commerce.Connect.Core.dll and use it's AddCartLines method.

Here is a simplified version of the code:

var currency = "EUR";
var cartLine = new CommerceCartLine(catalog, product.ProductId, null, product.Quantity);
var request = new AddCartLinesRequest(cart, new[] { cartLine })
{
    CurrencyCode = currency,
    Shop = new Shop { Name = Consts.ShopName }
};

_cartServiceProvider.AddCartLines(request);

UPDATE: I also noticed, that the cart always uses the list price to calculate the totals. That's a weird, because the price is calculated correctly based on the price card snapshots, when I use the PricingServiceProvider and it's GetProductPrices method. To assign price card snapshots to sellable items, we use tags. Maybe it's a problem when the cart tries to calculate the prices based on tags?

8
  • Do you have "Currency Configuration" specified for that particular storefront and EUR as currency is selected there? See more infomration here doc.sitecore.net/sitecore_commerce/commerce_connect_components/… Commented Aug 15, 2018 at 13:12
  • Yes. I use the "Default" currency set, which has "EUR" assigned as the default currency.
    – n-develop
    Commented Aug 15, 2018 at 13:17
  • Then I think the problem is with PriceCard and it's Price Snapshot where you have only USD specified for that particular Snapshot. See commercesdn.sitecore.net/SitecoreXC_9.0/Users-Guide/en-us/… for more information and particular "Create a snapshot" section Commented Aug 15, 2018 at 13:44
  • I defined only one Price Snapshot and that only contains a price for EUR.
    – n-develop
    Commented Aug 15, 2018 at 13:47
  • Can you try adding the item to the cart using the Postman script, but specify the currency "EUR" in the respective header field? Commented Aug 24, 2018 at 6:03

1 Answer 1

7
+50

OOTB Sitecore Commerce 9 uses USD currency as a default currency.

If you want to use different currency you need to do:

  1. Navigate to your Home item and check Control Panel Configuration in Storefront Settings section. There Sitecore store reference to Storefront Configuration for your Sitecore Commerce site.

  2. Navigate to /sitecore/Commerce/Commerce Control Panel/Storefront Settings/Storefronts and find under this item Storefront Configuration, which you are using for your site

  3. Navigate to /sitecore/Commerce/Commerce Control Panel/Storefront Settings/Storefronts/{your_storefront_configuration}/Currency Configuration and find Currency Set. All created/predefined Currency Sets you can find under /sitecore/Commerce/Commerce Control Panel/Shared Settings/Currency Settings/Currency Sets

  4. Navigate to your currency set and select EUR currency in Currencies field and set EUR currency in Default currency field

After that you need to patch commerceEngineConfiguration and replace defaultShopCurrency to:

<defaultShopCurrency>EUR</defaultShopCurrency>

Now all you price calculations will be in EUR currency

If you are not using SXA and you implemented your custom solution:

  1. You need to have reference on home item to Storefront Configuration, which your Storefront uses (or any other place in your site structure)
  2. Implement your own CartManager and for all requests like:

    • AddCartLinesRequest

    • AddPaymentInfoRequest

    • AddPromoCodeRequest

    • AddShippingInfoRequest

    • GetCartsRequest

    • MergeCartRequest

    • RemovePaymentInfoRequest

    • RemoveShippingInfoRequest

    • RemoveCartLinesRequest

    • RemovePartiesRequest

    • RemovePromoCodeRequest

    • UpdateCartLinesRequest

    • LoadCartByNameRequest

you need to set CurrencyCode property to EUR

Like:

var cartResult =
        CartServiceProvider.AddCartLines(new AddCartLinesRequest(cart, cartLineList) {CurrencyCode = "EUR"});

Unfortunately, GetCurrencyCode by shop, doesn't work properly (decompiled code):

namespace Sitecore.Commerce.XA.Foundation.Common.Providers
{
  public class RequestCurrencyProvider : IRequestCurrencyProvider
  {
    public string GetCurrencyCode(Shop shop)
    {
      return ServiceLocator.ServiceProvider.GetService<IStorefrontContext>().CurrentStorefront.SelectedCurrency;
    }
  }
}
2
  • Hi @AndreiPaliakou. Thank you for this great answer. As this is the best answer I got during the 7 days, of course I awarded you the bounty. But on the other hand, it did not fix my problem. As we cannot use SXA in the beforementioned project, we do not have the Sitecore.Commerce.XA binaries. But I implemented my own IRequestCurrencyProvider. Sadly, even that did not fix my problem.
    – n-develop
    Commented Aug 28, 2018 at 20:49
  • NB. When using the SXA Storefront and getting LineIsNotPurchasable error at the checkout confirmation step: verify that <defaultShopCurrency>EUR</defaultShopCurrency> in Sitecore.Commerce.Engine.Connect.config is correctly set.
    – Joost
    Commented Jun 4, 2019 at 12:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.