Sha256: 3afc8800d8680f12f6de696a719b942ffd6c5d03f17e477207efaaf9623dee90

Contents?: true

Size: 463 Bytes

Versions: 11

Compression:

Stored size: 463 Bytes

Contents

# A rule to limit a promotion to a specific user.
module Spree
  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' ? :>= : :>, BigDecimal.new(preferred_amount.to_s))
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
spree_promo-1.0.7 app/models/spree/promotion/rules/item_total.rb
spree_promo-1.0.6 app/models/spree/promotion/rules/item_total.rb
spree_promo-1.0.4 app/models/spree/promotion/rules/item_total.rb
spree_promo-1.0.3 app/models/spree/promotion/rules/item_total.rb
spree_promo-1.0.2 app/models/spree/promotion/rules/item_total.rb
spree_promo-1.0.1 app/models/spree/promotion/rules/item_total.rb
spree_promo-1.0.0 app/models/spree/promotion/rules/item_total.rb
spree_promo-1.0.0.rc4 app/models/spree/promotion/rules/item_total.rb
spree_promo-1.0.0.rc3 app/models/spree/promotion/rules/item_total.rb
spree_promo-1.0.0.rc2 app/models/spree/promotion/rules/item_total.rb
spree_promo-1.0.0.rc1 app/models/spree/promotion/rules/item_total.rb