Hi I have a problem implementing add to cart functionality in my rails e-commerce app. Here I am not talking about check out function. Just "add to cart". Items can be added to cart without requiring users to log in to their accounts. Once the user finishes adding to cart, then before check out user will log in. My problem here is what is the best way to store those items added to the cart. I am trying to use session. I can easily implement this if the user adds to cart JUST one product with any quantity. But how to store the information temporarily if user checks out multiple items with different quantities. I need a data structure to store this information but don't know which data structure to use. I mean something like this:
Session_id | product_id | quantity
wisidiri4i | 1234 | 3
349sksksks | 3452 | 6
And so on.....
Using hash I can store one item, but how to store multiple items?? Using DB table, I can do this but how to delete those records from the table if user leaves with items added to cart but without check out?
I am stuck here. Any help would be appreciated. Thanks