Answer the question
In order to leave comments, you need to log in
How to store carts and other user data for guests and registrants?
The server needs information about shopping carts, favorites, viewed products and similar data. Therefore, storing in cookies and sessions is not an option. Keeping data about both kinds of users together, via a user alias (a single identifier for both) is not an option.
Chosen as a solution: create duplicate tables. Registered users are identified by an integer id, guests by uuid. This results in the following list of tables
user: id
cart: id, user_id, order_id
cart_item: id, cart_id, product_id
favorites: id, user_id, product_id
guest: uuid
guest_cart: uuid, guest_uuid
guest_cart_item: uuid, cart_uuid, product_id
guest_favorites: uuid, guest_uuid, product_id
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question