I've been having periodic problems where when an item is added to the shopping cart it does not immediately appear in the shopping cart.
We add the items in code in the page code-behind (productcontainer.ascx) and I can see them get added to the database. If the user has logged in then they appear with the shoppingcartuserid set. If not then that column is null.
I have tried to associated the CMSShoppingCart cookie with the generated cart guid (in productcontainer.ascx) so it keeps with the user session.
What often happens is that the first item appears but when I go to add a second one it adds to the database (with the row linked to the cart guid) but only the first item appears in the shopping cart.
I then tried clearing the cache (without success).
I then tried re-starting the application (in the UI). After i did that the second row appeared.
I'm sure I must be missing something.
Does something need to be done to refresh this somehow? I did read that there can be a mismatch from the db to the session. If so then how should this be managed. I am using out of the box web controls for all of the shopping cart. Only the code-behind in the productcontainer.ascx is new.
Further research suggests that we may be missing a call to refresh the cache of the shopping cart. It looks like when you use the existing web parts and controls to add an item to the basket they have events hook that into the cache and update the cart immediately. Since we are using the Api directly I think this isn't happening. What would then be the case is that the row gets added to the database but the cache knows nothing about it until some point in time when it gets refreshed. This would explain the fact that i would come back later to view the cart and the items would be in it.
My question now is how is it possible to access the cache and update it immediately?