Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

How do I implement quantity editing? #5

Open
marcamillion opened this Issue Dec 16, 2012 · 6 comments

Comments

Projects
None yet
5 participants

Using the models recommended by the guide, and even the example application, I have the following in my shopping_cart_item.html.erb.

<td><%= shopping_cart_item.item.name %></td>
<td><%= shopping_cart_item.item.price %></td>
<td><%= shopping_cart_item.quantity %></td>

But I want to allow users to change the quantity - from say a drop-down menu (so a select tag from a collection).

But I am not quite sure how to approach that.

I would also like to add other attributes to my item - like a size of an item, color, etc.

I would like my store owner to be able to specify those things (i.e. size, color, etc.).

How do I do that?

Thanks.

mada41 commented Feb 1, 2013

Maybe you can do it manually like
ShoppingCartItem.update(cart_id, quantity: params[:your_params])

mada41 commented Apr 15, 2013

Yup,, maybe the documentation page must be comprehensive

@marcamillion - how did you solve quantity editing of shopping cart item?

I know the method .update_quantity must be included in a controller action. But how did you manage to include it in your controller and views?

I can't recall @muhammadn to be honest

It's been almost 2 years...sorry :(

spchetan11 commented Sep 30, 2016 edited

Just add a 3rd parameter for the quantity in the controller create action. @shopping_cart.add(@Product, @product.price, params[:quantity].to_i)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment