Open GoogleCodeExporter opened 8 years ago
Not just that, it lets you add more items that the quantity that is available if
inventory control is checked, if you add the maximum quantity available several
times, it does not check what is already in the cart.
At the end it do it right on checkout anyway, and delete those items.
My doubt here is if the add_to_cart_ajax method should really block everything
that
passes the quantity available if the inventory is checked and dont block
anything if
unchecked.
Original comment by edmundo...@gmail.com
on 18 Jun 2008 at 6:20
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
Original comment by patrickb...@gmail.com
on 13 Aug 2008 at 4:40
Original comment by subim...@gmail.com
on 16 Aug 2008 at 3:43
looks like a good patch.
Original comment by rogerpack2005
on 8 Oct 2008 at 6:17
but needs some double checking
Original comment by rogerpack2005
on 21 Feb 2009 at 5:20
Original issue reported on code.google.com by
rogerpack2005
on 18 Jun 2008 at 5:50