Hi Roger,
yes, after you add the same product multiple times and process checkout.

there is a quantity field in the current_item which helps you find that
condition (same book > 2) out.
just to clarify,
you should determine by the quantity of products, instead of number of
orders.

  def add_product(product)
    current_item = @items.find {|item| item.product == product}
    if current_item
      current_item.increment_quantity
    else
      current_item = CartItem.new(product)
      @items << current_item
    end
    current_item
  end

Cheers,
Eddie Lau


2009/8/28 Roger Goessens <[email protected]>

>  Hi,
> the following sentence in the homework excercise troubles me:
>
> "Apply discount only when the number of orders of a particular book is 2
> or above"
>
> During the function "add to chart" it is not possible to give a quantity
> number.
>
> So the only way to have a number of orders > 1 is to click "add to chart"
> different times in succession for the same book and then activate
> "checkout".
>
> Am I right ??
>
> roger
>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "ruby-on-rails-programming-with-passion" group.
To unsubscribe from this group, send email to
ruby-on-rails-programming-with-passion+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/ruby-on-rails-programming-with-passion?hl=en?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to