-
-
Notifications
You must be signed in to change notification settings - Fork 86
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
Give aiblity to use database instead of session #103
Comments
Is this what that migration was for? I see there's a migration with cart_session_id. A nice feature would be following; When a user is logged in (that exists in de database), and adds an item to his/her cart, and then leaves it would be saved to their account, so whenever they log back in, they have their cart filled up again fromout the data that has been saved. |
That's basically what that does :-) |
Unless they logout >< |
I think that it would be nice to have the option to persist the session in the DB aswell. So if a user logs out and logs in to have the option to have that information in the DB aswell ;) |
I dont think it would be to difficult, currently its loading it from the session data, we could serialize up the cart and produce the same results. Now for the proper way of doing it. Ill need to spend time actually designing the database migrations. Im currently working on a new project so it may be a couple of weeks before I can do this. |
It would be a nice to, if you need an extra pair of hands I might be able to help you a bit. But don't worry about the timing at all. The library is already really good as it is. |
Yah wouldn't mind some help on this if your up to the challenge. |
@umbertix , can you either add me on skype or something ? Would like see how your thinking of doing this , feel free to add me : luke.a.policinski If your on another timezone (im on est) Im willing to work around that as well. And on that note have you seen the new docs ? http://laracart.lukepolo.com/ |
Nice jobs with the new docs, this library is great. I'm also interested in persistent carts. I'll play with it this week. |
Take a look at the 2.0 branch, I think I started the database version , been swamped with a new project. 2.0 is highly not done though. |
Nice, It's looking good. I will try to get into it and contribute soon. Quick question related to the current method where the cart is stored in the session, is that information saved on the tmp folder in Linux? so if apache fails or the tmp folder is emptied all shopping carts would be lost? How reliable using the session to store data is ? Thanks! |
So, what ever session your using as your default for laravel is being used to store that data. For the reliability take a look at your session expires time and that is how reliable that is. |
Ok, Now I understand. I just took a look at config/session.php So it makes me feel better that this is currently saved by laravel using a file system. I could change the lifetime as a quick fix. A better solution for now I think is serializing the cart content and saving that to the database and then unserialize it. So I could save the contents of the cart by doing following: and then unserialize it and convert it back to a object (not sure how to do that yet, need to google it). Thanks! |
Sorry, I must have missed documenting something that is very useful here |
when you unserialize it , it will be an instance of Laracart ready for you to use. |
@daniel-farina Only one big issue with this you will need to set it to the session manually, (if you want add it in and Ill accept it as a PR) Read : |
Have you been able to make any progress on this? I was curious :) |
I have not :-(. I've been working on too many projects as of late to finish this. I've started a 2.0 branch a year ago that could be a good starting point. |
I am looking forward for this. I think this is a good case for Abandoned Checkouts functionality. |
I try the serialize and unserialize to use LaraCart object but it's not working. How can I load it as a LaraCart object ? You say : But I have the entire object in a variable. |
This should work : Below : #103 (comment) |
Hi, thanks for your solution I try this :
When I call Laracart via :
The result is an empty array. I think I must load the session in LaraCart object but how can I do ? |
I try a json_encode and json_decode on the object cause serialize is not working event with SuperClosure package. |
Ok got it to work :
|
It's working perfectly, the key was the cart attribute of the returned method LaraCart::get(). |
Will create a database version for those looking for it.
The text was updated successfully, but these errors were encountered: