Hi
I am currently working on a new feature on our B2B shop, that will allow some users to claim ownership of carts created by other users within the same company/organization.
Example on use case: Person A creates a new cart, and saves it as a draft. Person B then takes ownership of that cart, in order to add more products and complete the order.
Our current implementation requires that the CustomerId on the cart matches the ID of the current user.
I have already made the logic, that succesfully updates the CustomerId along with some properties in the "Data" field. I have verified that everything looks corrent in the database after the cart is saved with the new CustomerId.
That means that everything is working for Person B in the above example.
The cart is updated using this EPiServer method.
orderRepository.Save(cart);
My problem is that the cart is still returned when we load carts belonging to Person A, for a periode of time after the update.
I have come to the conclusion, that this is due to the cache inside the OrderRepository.
Carts are loaded using this EpiServer method.
orderRepository.Load<ICart>(userGuid, cartName);
For a period of time, the updated cart is still returned when carts are loaded for Person A.
In that result, the cart still contains the CustomerId of Person A.
Can any of you think of a way to solve this problem?
Is it somehow possible to refresh the cache of Person A, when Person B takes ownership of one of his/her carts?