Further guidance on building E-commerce

Hi Alex, After completing the Etsydemo course, I spent a lot of time looking for new tutorials and information on how to add a shopping cart to an e-commerce application. I found many options that showed how to build the cart itself, but not how to integrate it into an existing application (specifically regarding actually completing an order and saving it to the database). My attempts to fill-in the gaps myself have proven incredibly challenging, and I was wondering if you had specific guidance on how to get to the next step of fully integrating a cart into a web-app. Do you have any suggestions? Best, Brian

Posted almost 2 years ago by Brian
Posted almost 2 years ago by Alex Yang

Adding a shopping cart certainly adds more complexity (that's why we decided to leave it out of Etsydemo, as it's a bit too advanced for beginners). If you're giving it a shot though, I'd be happy to help you walk through some of the logic of setting it up.

The basic logic is that each user has a Cart and can add individual Listings as LineItems to their Cart. When the user is ready to check out, a new Order is created where each LineItem in the Cart is added to the Order (a LineItem can belong to either a Cart or an Order) and deleted from the Cart. Does that make sense?

The first time I created a shopping cart, I modeled it off the example in the book Agile Web Development with Rails. There may be a more updated version available, but it may be helpful to see the complete example (though outdated) here:

Hope that helps!