cart configuration and sessions

Hi,

I guess as many people, I am very new to Rails. I used a book to create a shopping cart and then modified the code to try and fit it to my project's requirements. I have been trying figure this out for the last week and starting to get really discouraged about the prospects of solving this. I know what needs to be done but I'm at a loss for how to achieve it. So, I wanted to ask, for help. Please please please.

Background: I have the following classes: customer, product, cart, cart_items, order, order_items A customer needs to login to even see the "Add to cart" links -- so the same goes for viewing cart and checkout. (which is achieved). Things I have trouble with: 1) The sessions are stored in the db. Right now, customer session and cart session are separate. I need to assoociate them together. So, when a customer loggs out and a new customer logs in, they have different carts. If the session can remember the cart items, if the same customer logs in again, that would be great. The customer id will also need to be stored in the orders tables as well. 2) I suddently have trouble even trying to add an item to the cart. 3) I need to figure out a way to update the quantity of items (products) in the cart. 4) And lastly, my checkout page doesn't come up suddenly as well

Please can anyone have a look and help me solve this? Any help will be so much appreciated, Thanks, Elle

While what you are asking is about 20 questions, I will answer this. The functionality you are looking for with your shopping cart would really require you to persist the card and items as a database table. Then write logic to save it when things are added/removed and to recall it from the DB when a use logs in. A session is not the right place for this type of functionality. The problem with long running carts, is that if you change the price on something you may have a persisted cart item that has a differnet price, so you need to decide if you persist the price when the user adds items to the cart, or you keep it linked to the product that may change over time.

-Jake