2

I'm facing a strange error from commerce engine v. 8.2.1

If I add a product to cart as guest, all the pipelines work flawlessly and the product is added to the cart. Instead, as a registered user, the same products make the engine abort the operation: the product isn't added to the cart and this exception appears in the log:

25 13:20:50 DEBUG Request starting HTTP/1.1 GET http://localhost:5000/api/Carts('Default%7B7e7328e7-8caa-4a3d-bf2f-856466fac77c%7Dstorefront')?$expand=Lines($expand=CartLineComponents($expand=ChildComponents)),Components application/json 
25 13:20:50 DEBUG Executing action method "Sitecore.Commerce.Plugin.Carts.CartsController.Get (Sitecore.Commerce.Plugin.Carts)" with arguments (["Default{7e7328e7-8caa-4a3d-bf2f-856466fac77c}storefront"]) - ModelState is Valid
25 13:20:50 INFO MemCache.GetInventoryItem.Hit: ItemKey=Habitat_Master|Prod1|Prod1Variant
25 13:20:50 INFO Inventory.block.PopulateLineItemInventory.ItemAvailabilityComponent.Expired: EffectiveDate=08/04/2018 11:20:50 +00:00|Expires=08/04/2018 11:16:48 +00:00|ItemId=Habitat_Master|Prod1|Prod1Variant
25 13:20:50 INFO PopulateLineItemAvailability.ComponentUpdated.Habitat_Master|Prod1|Prod1Variant: Count=1500
26 13:20:51 INFO MemCache.GetInventoryItem.Hit: ItemKey=Habitat_Master|Prod2|Prod2-1
26 13:20:51 INFO Inventory.block.PopulateLineItemInventory.ItemAvailabilityComponent.Expired: EffectiveDate=08/04/2018 11:20:51 +00:00|Expires=08/04/2018 11:16:48 +00:00|ItemId=Habitat_Master|Prod2|Prod2-1
26 13:20:51 INFO PopulateLineItemAvailability.ComponentUpdated.Habitat_Master|Prod2|Prod2-1: Count=10
26 13:20:51 INFO MemCache.GetInventoryItem.Hit: ItemKey=Habitat_Master|Prod3|Prod3_1
26 13:20:51 INFO Inventory.block.PopulateLineItemInventory.ItemAvailabilityComponent.Expired: EffectiveDate=08/04/2018 11:20:51 +00:00|Expires=08/04/2018 11:16:48 +00:00|ItemId=Habitat_Master|Prod3|Prod3_1
26 13:20:51 INFO PopulateLineItemAvailability.ComponentUpdated.Habitat_Master|Prod3|Prod3_1: Count=999
26 13:20:51 ERROR CtxMsg.Error.LineIsNotPurchasable: Text=Item 'Prod1Variant' is not purchasable.
26 13:20:51 ERROR CtxMsg.Error.LineIsNotPurchasable: Text=Item 'Prod2_1' is not purchasable.
26 13:20:51 ERROR CtxMsg.Error.LineIsNotPurchasable: Text=Item 'Prod3' is not purchasable.
26 13:20:51 ERROR PipelineAbort:Cart 'Default{7e7328e7-8caa-4a3d-bf2f-856466fac77c}storefront' has invalid lines.
26 13:20:51 ERROR PipelineAbort:Cart 'Default{7e7328e7-8caa-4a3d-bf2f-856466fac77c}storefront' has invalid lines.
25 13:20:51 DEBUG Executing ObjectResult, writing value "Microsoft.AspNetCore.Mvc.ControllerContext".
26 13:20:51 DEBUG Executed action "Sitecore.Commerce.Plugin.Carts.CartsController.Get (Sitecore.Commerce.Plugin.Carts)" in 578.7314ms

Trying to troubleshot the problem I found that the error comes from the Plugin.Catalog.ValidateCartLinesPriceBlock in the pipeline ICalculateCartLinesPipeline. If this one doesn't find a PurchaseOptionMoneyPolicy in the cartline's policy, it throws the error.

This policy should come from the previous block CalculateCartLinesPriceBlock which calls in turn IGetSellableItemPipeline: this last one should get the list and sell price of the sellable item in order to allow the CalculateCartLinesPriceBlock to set a valid PurchaseOptionMoneyPolicy.

However I didn't understand why the problem shows up only when the user is logged in.

6
  • this error appear when the default currency of your currencyset is USD for example and you only added a price in EUR. Can you verify if this one is the issue? Apr 8, 2018 at 18:18
  • My default currency is EUR and in my product I only added a price in EUR. So maybe this is not the case. Where can I check if the engine is correctly using EUR instead of USD? In the HabitatAuthoring environment I already changed USD to EUR everywhere Apr 8, 2018 at 22:01
  • Ok I knew those settings anche I checked them. It's all correct here. Apr 9, 2018 at 7:40
  • I have the same error in Sitecore XC 9 Update 1. Any updates here? @user1624411 were you able to solve it?
    – n-develop
    Aug 8, 2018 at 13:01

1 Answer 1

1

If you are not using SXA and your default currency is not USD, for one or the products, add a dummy List Price in USD (e.g. zero) and see if that item is now purchasable.

If you using the Habitat Retail Demo code as a reference, it makes a the default calls (with default USD underlying). Therefore, even if you change the currency to EUR in storefront settings in Sitecore and shop default currency in config, the engine will still make a call using USD.

In order to confirm the currency being passed in the call made to the Commerce Engine, you need to use Wireshark to inspect the calls made to the engine. For a guide on how to do this, follow this excellent article by Kazim Nami: https://kazimnami.com/2017/11/18/wireshark-and-sitecore-commerce-engine/

For more details on this error, please refer to my blog post here: https://sitecoredude.com/sitecore-xc9-add-cart-line-error-item-is-not-purchasable/

Your Answer

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

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