Hey everyone,
I am having a tough time finding an answer for this, so naturally the forums were the next stop. I am working on authentication/cart/checkout flow, currently from the angle of a user logging in.
So far, I have no problem logging a user in and generating a new cart. From there, the user can add to cart and the items are displayed correctly. The problem is when that user logs back in, how do I grab the cart without having the cartId? The only information that we have available to us is the customerAccessToken that is generated on login and pragmatically, I assumed I would be able to use that token to get the user’s cart (this is seen in other JWT based authentication flows - you can use the accessToken to grab customer-centric data).
If you think about the flow of the user, there is not a single bit of data that can be used to access the cart. I was hoping the cartId could be pulled through the customer mutations but that’s not the case either.
So, to summarize:
New User - No cart:
User logs in ===> Cart is Generated (I do this before an item is even added) ====> Cart can be used to add/remove lines
Returning User - Cart already Created in past session:
User Logins ===> How do I find a cart without a cartId?
I could permanently persist the cartId on the client side but let’s say someone else logs on that same computer, that cartId would be replaced in localStorage and I’ll be back to square one. I need a backend tie that is accessible through the API for ease of use. Also, when a user logs out, I will be wiping all that data from localStorage anyway.
I am assuming I am missing something glaring but I am struggling to find any good help online.