My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
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
Status:  Accepted
Owner:  ----


 
Reported by rogerpack2005, Jun 18, 2008
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
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.
Aug 12, 2008
#2 patrickb...@gmail.com
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
Project Member #3 subim...@gmail.com
(No comment was entered for this change.)
Status: Accepted
Labels: -Priority-Medium Priority-Low
Oct 7, 2008
#4 rogerpack2005
looks like a good patch.
Feb 21, 2009
#5 rogerpack2005
but needs some double checking

Powered by Google Project Hosting