# Updating quantity of product (Shopping cart)

**URL:** <https://discuss.rubyonrails.org/t/updating-quantity-of-product-shopping-cart/20691>\
**Category:** rubyonrails-talk\
**Created:** [November 21, 2007, 12:51pm UTC](https://discuss.rubyonrails.org/t/updating-quantity-of-product-shopping-cart/20691 "2007-11-21T12:51:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nicholas\_Henry](https://avatars.discourse-cdn.com/v4/letter/n/919ad9/32.png) [@Nicholas\_Henry](https://discuss.rubyonrails.org/u/Nicholas_Henry)\
**Post date:** [November 21, 2007, 12:51pm UTC](https://discuss.rubyonrails.org/t/updating-quantity-of-product-shopping-cart/20691/1 "2007-11-21T12:51:26Z")

</div>

If you change this line from:

\<td\>\<input id="quantity" name = "quantity" type="text" value="\<%= item.quantity %\>" size="1" /\>\</td\>

to:

text\_field\_tag "items[#{item.id}]", item.quantity, :id =\> "items\_#{item.id}"

it will create a hash of values params[:items] that you can then cycle through and update your cart items.

e.g. params[:items].each { | id, qty | ...update routine.... }

HTH, Nicholas
