Clearing Cache for object like CustomerInfo

Matthew Butler asked on October 6, 2022 15:42

I'm updating the customer record with ICustomerInfoProvider.Set, but my changes aren't being reflected in places like _shoppingService.GetCurrentCustomer()

How do I clear cached version?

Recent Answers


Matthew Butler answered on October 6, 2022 15:58

I Solved with _shoppingService.SetCustomer(customerInfo); But doesn't seem ideal

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on October 6, 2022 16:39

If you're updating the customer record AFTER you've retrieved/set the cart info, you'll need to update the cart info again with the current customer information OR retrieve the cart information again. I don't believe this is a caching thing at all, it's more of a timing thing (when you set/get info vs. when you update it).

0 votesVote for this answer Mark as a Correct answer

Matthew Butler answered on October 6, 2022 18:01

The cart is cached in the session, so re-fetching elsewhere brings back original customer info. e.g.

  1. Customer add products goes to basket
  2. Clicks to update account (Phone number etc..)
  3. Continues browsing site
  4. returns to basket to move to checkout
  5. checkout process shows old information

It doesn't look like there's any dependency tracking on the customer state as part of the cart, so anywhere I update any customer info I need to save to cart to ensure its up to date.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.