Module: Workarea::Pricing::Discount::Conditions::ItemQuantity
- Extended by:
- ActiveSupport::Concern
- Included in:
- Workarea::Pricing::Discount::Category, Product, ProductAttribute
- Defined in:
- app/models/workarea/pricing/discount/conditions/item_quantity.rb
Instance Method Summary collapse
- #item_qualifies?(item) ⇒ Boolean
-
#item_quantity? ⇒ Boolean
Whether this discount uses item quantity as a condition.
-
#items_qualify?(order) ⇒ Boolean
Whether this discount’s item quantity passes for this order.
Instance Method Details
#item_qualifies?(item) ⇒ Boolean
35 36 37 |
# File 'app/models/workarea/pricing/discount/conditions/item_quantity.rb', line 35 def item_qualifies?(item) !item_quantity? || item.quantity >= item_quantity end |
#item_quantity? ⇒ Boolean
Whether this discount uses item quantity as a condition.
21 22 23 |
# File 'app/models/workarea/pricing/discount/conditions/item_quantity.rb', line 21 def item_quantity? item_quantity.present? && item_quantity > 0 end |
#items_qualify?(order) ⇒ Boolean
Whether this discount’s item quantity passes for this order.
31 32 33 |
# File 'app/models/workarea/pricing/discount/conditions/item_quantity.rb', line 31 def items_qualify?(order) order.items.any? { |item| item_qualifies?(item) } end |