vanilophp / framework

The truly Laravel E-commerce Framework
https://vanilo.io
MIT License
810 stars 102 forks source link

How to reassign Cart to User after Login #19

Closed chellmann closed 5 years ago

chellmann commented 6 years ago

Hi,

how can it be achieved that the last saved cart is re-loaded into the session when a user comes back and log in?

fulopattila122 commented 6 years ago

This scenario is currently not covered, only these: https://vanilo.io/docs/0.3/cart#associating-with-users

It conflicts with the current approach since the current strategy is to keep the cart with the session.

I would say what you're describing is a different strategy (keep the cart with the user) and I've seen this quite many times, so it also makes perfect sense. It would work like this: if the user logs out, the cart (what the user sees in the browser) becomes empty, but if logs back in (even on another device) the cart will be reverted to the last state.

Do I understand correctly? If yes, then I think I'll add it as a new feature. To also keep the current behavior, you'll be able to choose between the strategies in the configuration (eg. vanilo.cart.keep_with either session or user.