AI OnAI Off
var newCart = _orderRepository.Create<ICart>(cart.CustomerId, Cart.DefaultName);
This will create a cart with the current market. If you have a custom implementation of ICurrentMarket (which you most likely do), you might want to take a look. Alternatively, you can call SetCurrentMarket(MarketId marketId) before to make sure you are in the right market
Hi
We have a customer with a strange bug where the cart replaces market and settings once we save the cart in the IOrderRepository.
We try to save Finnish context but end up saving a Swedish context based cart instead.
The following snippet is where we somehow end up picking up the wrong context, but the question is why?
When we try call the Save method we also receive the following error message:
Mediachase.Commerce.Orders.Exceptions.OrderException: A cart with same CustomerId, Name, and MarketId already exist. Creating duplicated cart is not allowed
at EPiServer.Commerce.Order.Internal.DataAccess.SerializableCartDB.Save(SerializableCart cart)
at EPiServer.Commerce.Order.Internal.SerializableCartProvider.Save(ICart cart)
at EPiServer.Commerce.Order.Internal.DefaultOrderRepository.Save(IOrderGroup order)
We are running EPiServer.Commerce.13.32.1
I am quite new to the commerce installation of Episerver, hence might have some setting or imagination of the context wrong here