vanilophp / cart

Cart Module for Vanilo (or any Laravel app)
https://vanilo.io
MIT License
50 stars 17 forks source link

restore carts on users login #5

Closed chellmann closed 6 years ago

chellmann commented 6 years ago

When a User is authenticated, the last stored cart is restored in the session

fulopattila122 commented 6 years ago

Thank you for the PR!

Both checks fail (styleCI and travis). It also breaks existing functionality. Please fix those problems so that I can accept your PR.

Thanks!

chellmann commented 6 years ago

Hi,

i fixed the style errors successfully. I Would like to discuss the behavior that the cart is automatically dissociated from the user. Not only the Cart is removed from the Session, the UserId is set to null in the database. So there is no chance to get this Cart back to the User.

I would recommend to establish a new configuration option "destroy_on_logout" which will - when set to true - whipes the session and removes the UserId in the DB. If set to false the UerId stays unaffected but the Session will be cleaned.

Thanks

fulopattila122 commented 6 years ago

I took your work and modified/completed it (see PR #6) so that it remains compatible with existing functionality. I've also added test coverage for the new feature and documentation. As a collateral effect, the state field on the cart has been introduced as well.

Thanks for your work, I hope this adjusted variant will align your original intent.