Hi
I have this method which checks if a cart already exists:
protected ICart GetExistingCart(string name) => _orderRepository.LoadCart<ICart>(_customerContext.CurrentContactId, name, _currentMarket.GetCurrentMarket().MarketId);
If the method returns null, I create a new cart:
cart = _orderRepository.Create<ICart>(_customerContext.CurrentContactId, name);
SaveCart(cart);
This is used in a checkout flow.
Now, the thing is that our site generally allows for a user to signin to access some non-public areas of the site. Signin is via Azure.
If the user is logged in, and afterwards decides to go to the checkout flow, Commerce's _customerContext.CurrentContactId
changes constantly, and thus every time I call GetExistingCart
for the same user I get a new cart. If I debug the code in Visual Studio, I can see that for every line I step over, _customerContext.CurrentContactId
changes.
If however, user is not logged in already, _customerContext.CurrentContactId
stays the same, and cart can be created and retrieved as expected during checkout.
Anyone knows what the problem can be?
Commerce version is 11.8.3.