If you do an add to cart before going to checkout page the cookie gets created just fine. I don't think there's a problem, maybe a note should be made though. I've coded the update to use the CartCookie in the CartItem and it as far as I can see works fine. The only thing I think might be worth noting is not to use the browser cookie for the GUID value when updating a shopping cart item because there are times the cookie might not be there.
Normal workflow: Go to a detail page, click add to cart, the cookie gets created, and all is good.
But:
1. Have items in your cart.
2. Clear cache which deletes the cookie.
3. Open up the web site. Go directly to the checkout page. We generally have this in the menu because people could be leaving things in the cart and returning. At this point the cookie has been erased in step 2 but hasn't been recreated.
4. The custom pipeline code tries to update the cart using the cookie, which doesn't exist because the user hasn't clicked add to cart since clearing the cookies. Kaboom.
5. Solution: At all times the proper GUID looks to be in the CartItem.CartCookie field of the item being updated. Use that instead of the cookie in the browser.
Specific answers:
I may have mis-spoke (mis-typed?) To see the problem you need to clear cookies before one opens the site and goes directly to the checkout page. While deleting the cookies after clicking add to cart and before going to the checkout page would create the error, I agree it's irrational. If one does that they get what they deserve and that's not your or my problem!
On this site, the setting is indeed set to Persist by Login. We're on DNN 9.x.
The cookie is being created every time add to cart is clicked. There's no issue with this. It only happens when you get to the checkout page (or to where you execute pipeline code) without having clicked add to cart.
For a scenario, consider this:
1. User has a browser that is set up to delete cookies when closed. It's a RazorCart site that persists by login and has a link to the Checkout page on the top menu.
2. The user goes into the site and adds 3 items to the cart.
3. The user closes the browser. It deletes the cookies but the items are still in the cart,
4. The user opens the browser again and navigates to the site and logs in.
5. The user clicks on the "Checkout" link and goes straight to the checkout page without ever clicking add to cart and without recreating the cookie, since there are 3 items in their cart and all the user wants is to buy them now.
6. The custom pipeline code calls the UpdateCartItem method, which looks to the cookie for the GUID. But the cookie does not exist. The call fails.
Solution: The GUID is also in the CartItem.CartCookie field. Use that in the update statement instead.
In response to an earlier forum question I was provided sample code showing me how to use UpdateCartItem, which workes great and I am completely grateful for. The example code got the GUID from the cookie and we found the a way to run that code when the cookie didn't exist. It's not normal workflow but scenarios where the error could occur were reasonable. I think it might be safer to get the GUID from the CartItem, The actual cookie in the browser might not exist.
I don't think it's a bug. I think people using custom pipeline code should get the GUID from the CartItem they're updating/deleting and not the browser cookie. I apologize for making a mountain out of a molehill.