I have an online shop website that, in order to add items to the basket, you have to first be logged in.
This is great and works all fine
However, a requirement has arisen to allow users to add items to the basket without being logged in first, and if/when they do log in, any items in the basket they added prior to logging in will be added to their "logged-in" basket.
Basket items are held in an Orders database table, with a pending status (amongst other things) and a user id. Id's are Guids.
If not logged in, use a userid held in a cookie (created if doesn't exist) that is passed via ajax to add to the basket.
When log in, get any items in the order table with user id matching that of the cookie to be updated to the user id of the logged in user.
But to me the doesn't sound or feel like a suitable solution in many ways. Also updating user id's in the orders table doesn't seema good thing either.
Although I can not think of another way of achieving this approach with the basket. Is it bad practice?
Is there a defined sort of way to be able to do the above?
S
Aucun commentaire:
Enregistrer un commentaire