Class: Spree::Promotion::Rules::ItemTotal

Inherits:
Spree::PromotionRule show all
Defined in:
app/models/spree/promotion/rules/item_total.rb

Constant Summary collapse

OPERATORS =
['gt', 'gte']

Instance Method Summary collapse

Instance Method Details

#eligible?(order, options = {}) ⇒ Boolean


12
13
14
15
# File 'app/models/spree/promotion/rules/item_total.rb', line 12

def eligible?(order, options = {})
  item_total = order.line_items.map(&:amount).sum
  item_total.send(preferred_operator == 'gte' ? :>= : :>, BigDecimal.new(preferred_amount.to_s))
end