Shopping cart remains cached after setting address

Matthew Butler asked on September 23, 2022 12:37

I have a post back which calls _shoppingService.SetBillingAddress, I then redirect to a payment page which calls var cart = _shoppingService.GetCurrentShoppingCart();

But the billing address come through as unset, unless I navigate back and forward again.

Any ideas on how to clear cache after setting addresses?

If I call

(Details)Create Customer and login

(Details)_shoppingService.SetBillingAddress(address);

(Details)_shoppingService.GetCurrentShoppingCart();

Works, but (Details)Create Customer and login

(Details)_shoppingService.SetBillingAddress(address);

(Details)return RedirectToAction(nameof(Delivery));

(Delivery) var cart = _shoppingService.GetCurrentShoppingCart();

doesn't

Correct Answer

Matthew Butler answered on September 23, 2022 18:03

So setting a customer linked to a user doesn't set userId on the cart, so after logging in the GetCurrentCart links to the cart and clears the data.

I've updated the UserID on the cart once the customer is linked and this appears to solve the issue, but not ideal.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Matthew Butler answered on September 23, 2022 15:00

It looks like the act of logging in means the GetCurrentShoppingCart works in the calling function, but then fails once redirected, until you navigate away and back

0 votesVote for this answer Mark as a Correct answer

Matthew Butler answered on September 23, 2022 16:25

So it looks like calling login on a cart that was just linked to that user clears the shipping and billing addresses??

0 votesVote for this answer Mark as a Correct answer

Dmitry Bastron answered on September 30, 2022 09:24

Hi Matthew,

The "merge" of the shopping carts happens upon login. You can read more in the documentation on how to customize this behaviour. Have a look at these TakeOver methods for more details.

0 votesVote for this answer Mark as a Correct answer

Matthew Butler answered on September 30, 2022 10:09

Thanks Dmitry, I guess my issue is I don't understand why the shopping cart doesn't set the userid from the customer when it links the customer to the cart as this solves the issue

0 votesVote for this answer Mark as a Correct answer

Dmitry Bastron answered on September 30, 2022 17:39

Customer and user are different entities in Kentico. When you're going through this flow is there any difference depending on the user logged in or not when they start the checckout?

0 votesVote for this answer Mark as a Correct answer

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