Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to guests continue with same cart when they login #670

Open
CODE-AXION opened this issue Jun 4, 2022 · 3 comments
Open

How to guests continue with same cart when they login #670

CODE-AXION opened this issue Jun 4, 2022 · 3 comments

Comments

@CODE-AXION
Copy link

i want to make a shopping cart where if guest user adds items to cart and when he logs in all the guest cart items should be shifted from session to database ? how can i achieve that ?

@bumbummen99
Copy link

Cart is saved in the databse or session. You could save it before login (write to db) and then load it after login (delete & load to session).

@CODE-AXION
Copy link
Author

Cart is saved in the databse or session. You could save it before login (write to db) and then load it after login (delete & load to session).

But how can I store the session to the database , because there might be multiple session for multiple users ? And the session id will also get changed after login ? I am very confused idk how to do it properly 😞.

@bumbummen99
Copy link

bumbummen99 commented Jun 4, 2022

Cart is saved in the databse or session. You could save it before login (write to db) and then load it after login (delete & load to session).

But how can I store the session to the database , because there might be multiple session for multiple users ? And the session id will also get changed after login ? I am very confused idk how to do it properly 😞.

No you dont save the session to the database. The cart can be either in the session or the database but not booth. A loaded cart is not on the database.

$this->getConnection()->table($this->getTableName())

Just store the cart with a tmp identifier and load it after the session is renewed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants