# Expanding Shopping Cart Tutorial

**URL:** <https://www.ruby-forum.com/t/expanding-shopping-cart-tutorial/73238>\
**Category:** Rails\
**Created:** [October 23, 2006, 4:50am UTC](https://www.ruby-forum.com/t/expanding-shopping-cart-tutorial/73238 "2006-10-23T04:50:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vgkids](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/a5b964/32.png) [@vgkids](https://www.ruby-forum.com/u/vgkids)\
**Post date:** [October 23, 2006, 4:50am UTC](https://www.ruby-forum.com/t/expanding-shopping-cart-tutorial/73238/1 "2006-10-23T04:50:11Z")

</div>

I’m following the Agile Development with Rails shopping cart tutorial,  
and while some of its sticking, I’m still far from proficient.  
Basically, I’m trying to use their shopping cart example as the base  
for my store, but I need products in the store to have line items  
themselves- for example:

my site sells custom printed t-shirts wholesale. I’m imagining a  
customer will add a t-shirt order to their cart, and then from there,  
be able to add line items - 5 smalls, 5 mediums, etc. Anyone have any  
general suggestions on how I should set the tables up and associate the  
line items with the products? So that a customer could have multiple  
shirt orders, each with it’s own set of line items?

Many thanks in advance, and I’m happy to trade printing for code.

---

<div class="post-metadata">

**Author:** ![vgkids](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/a5b964/32.png) [@vgkids](https://www.ruby-forum.com/u/vgkids)\
**Post date:** [October 23, 2006, 2:53pm UTC](https://www.ruby-forum.com/t/expanding-shopping-cart-tutorial/73238/2 "2006-10-23T14:53:15Z")

</div>

You might be interested in my book about building ecommerce sites  
using Rails:

[http://www.agilewebdevelopment.com/rails-ecommerce](http://www.agilewebdevelopment.com/rails-ecommerce)

---

<div class="post-metadata">

**Author:** ![vgkids](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/a5b964/32.png) [@vgkids](https://www.ruby-forum.com/u/vgkids)\
**Post date:** [October 23, 2006, 5:27am UTC](https://www.ruby-forum.com/t/expanding-shopping-cart-tutorial/73238/3 "2006-10-23T05:27:18Z")

</div>

One idea…

Rather than deal with two tables - order line and shirt-order-line as  
you’ve suggested in your op, add a size column to your order lines table  
to indicate the size for the shirt on this order line. In your product  
listing, add a small form for each product listed with a quantity box  
for each size. The user inputs quantities of each size he/she wants,  
then clicks “add”. “Add” is actually the submit button for the form.  
Your “add” action in the controller adds one order line for each size of  
the shirt the user wanted.

So, if user puts in 4 smalls, 5 mediums and 10 larges then clicks “add”,  
the result is 3 order lines. You could easily adapt the AWDWR shopping  
cart to do this.

I’ve been working on a shopping cart for a  
screen-print-frames-and-supplies company that is not the usual “catalog  
with a picture and add-to-cart button” that you might want to have a  
look at. Drop me a line at “house -at- balara -dot- com” if you’d like  
to discuss further.

c.

vgkids wrote:

> I’m following the Agile Development with Rails shopping cart tutorial,  
> and while some of its sticking, I’m still far from proficient.  
> Basically, I’m trying to use their shopping cart example as the base  
> for my store, but I need products in the store to have line items  
> themselves- for example:
> 
> my site sells custom printed t-shirts wholesale. I’m imagining a  
> customer will add a t-shirt order to their cart, and then from there,  
> be able to add line items - 5 smalls, 5 mediums, etc. Anyone have any  
> general suggestions on how I should set the tables up and associate the  
> line items with the products? So that a customer could have multiple  
> shirt orders, each with it’s own set of line items?
> 
> Many thanks in advance, and I’m happy to trade printing for code.
