Quantcast
Channel: Developer to developer
Viewing all articles
Browse latest Browse all 9076

If user is signed in with Owin, Commerce's _customerContext.CurrentContactId changes constantly for user. Why is that?

$
0
0

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 the start of, and during the 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 (pages that are not related to the checkout flow). Signin is with Owin (in 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, it won't find any 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 signed 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 with this _customerContext.CurrentContactId and its constant change of value when signed in with Owin?

Commerce version is 11.8.3.


Viewing all articles
Browse latest Browse all 9076

Trending Articles