In case of e-commerce application as we all know, user can use application either by login into the application or can use as guest user and can add/remove item to his cart and do checkout.
So my question is what should be the best approach to handle both scenarios for guest and logged in customer. I think about two approaches but not sure whether theses are best or we can use some better approaches other than i mentioned below.
1) Whenever the customer hit the e-commerce application through the web then i will create guest customer and and return to the front-end application and stored in the the local storage of web, so that i can use the same customerId whenever user is doing any change to his cart.
2) As i mentioned in the point 1, i will create the guest customer but instead of just returning the customerId, i will return the JWT token which has the customerId and has another field which mentioning whether it is guest customer or not.
I am using Angular in the front-end and NodeJs in the back-end and for the logged In customer i am using the JWT token.
So i was thinking to use the point 2, so that the logic should be consistent whether it is logged in or not i will rely on the JWT token to pass the information between front-end and back-end.
But i am not sure cons for these approach.Please give your suggestions
Aucun commentaire:
Enregistrer un commentaire