| Issue 100: | unable to add to cart ajax unless you have at least a 1 for the items' quantity | |
| 3 people starred this issue and may be notified of changes. | Back to list |
In general, if you uncheck Use inventory control? in preferences it doesn't work. At the least, if you have products without quantities, you can't add them within add_to_cart_ajax. I hope to eventually get around to patching this and posting the patch.
Jun 18, 2008
#1
edmundo...@gmail.com
Aug 12, 2008
I've switched to the add_to_cart non-ajax method. Let me know if there's a better way
to do this.
def add_to_cart
@cart = find_cart
product = Product.find(params[:id])
if !session[:cart].items.empty?
for i in session[:cart].items do
if i.item_id == product.id
quantity = i.quantity.to_i + params[:quantity].to_i
else
quantity = params[:quantity]
quantity ||= 1
end
end
else
quantity = params[:quantity]
quantity ||= 1
end
if quantity.to_i > product.quantity.to_i
flash[:notice] = "Your cart already contains the maximum quantity for this item."
redirect_to :action => 'show', :id => product.code
else
@cart.add_product(product, quantity.to_i)
show_cart and return
end
rescue
redirect_to_index("Sorry, you tried to buy a product that we don't carry any
longer.")
end
Aug 15, 2008
(No comment was entered for this change.)
Status:
Accepted
Labels: -Priority-Medium Priority-Low
Oct 7, 2008
looks like a good patch.
Feb 21, 2009
but needs some double checking |