Sha256: 3853b30a6ecb5b9a5c4072b0af11be12cb2a824cc358eb41bb21dd4210dfc6bb

Contents?: true

Size: 408 Bytes

Versions: 10

Compression:

Stored size: 408 Bytes

Contents

# A rule to limit a promotion to a specific user.
class Promotion::Rules::ItemTotal < PromotionRule

  preference :amount, :decimal, :default => 100.00
  preference :operator, :string, :default => '>'

  OPERATORS = ['gt', 'gte']

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
spree_promo-0.70.7 app/models/promotion/rules/item_total.rb
spree_promo-0.70.6 app/models/promotion/rules/item_total.rb
spree_promo-0.70.5 app/models/promotion/rules/item_total.rb
spree_promo-0.70.4 app/models/promotion/rules/item_total.rb
spree_promo-0.70.3 app/models/promotion/rules/item_total.rb
spree_promo-0.70.2 app/models/promotion/rules/item_total.rb
spree_promo-0.70.1 app/models/promotion/rules/item_total.rb
spree_promo-0.70.0 app/models/promotion/rules/item_total.rb
spree_promo-0.70.0.rc2 app/models/promotion/rules/item_total.rb
spree_promo-0.70.RC1 app/models/promotion/rules/item_total.rb