Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

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
Open

How do I implement quantity editing? #5

marcamillion opened this issue Dec 16, 2012 · 6 comments

Comments

@marcamillion
Copy link

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
Copy link

mada41 commented Feb 1, 2013

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

@shanemcd
Copy link

It looks like this functionality exists here:

https://github.com/crowdint/acts_as_shopping_cart/blob/master/lib/active_record/acts/shopping_cart_item/instance_methods.rb

item.update_quantity(new_quantity)

@mada41
Copy link

mada41 commented Apr 15, 2013

Yup,, maybe the documentation page must be comprehensive

@muhammadn
Copy link

@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?

@marcamillion
Copy link
Author

I can't recall @muhammadn to be honest

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

@spchetan11
Copy link

spchetan11 commented Sep 30, 2016

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants