Sha256: 257ef1646b042183b81442392a2ce0a63fd514480e268088832e9a0e5ee397bc

Contents?: true

Size: 616 Bytes

Versions: 165

Compression:

Stored size: 616 Bytes

Contents

module Spree
  class Promotion
    module Rules
      class OneUsePerUser < PromotionRule
        def applicable?(promotable)
          promotable.is_a?(Spree::Order)
        end

        def eligible?(order, _options = {})
          if order.user.present?
            if promotion.used_by?(order.user, [order])
              eligibility_errors.add(:base, eligibility_error_message(:limit_once_per_user))
            end
          else
            eligibility_errors.add(:base, eligibility_error_message(:no_user_specified))
          end

          eligibility_errors.empty?
        end
      end
    end
  end
end

Version data entries

165 entries across 165 versions & 2 rubygems

Version Path
solidus_core-2.5.1 app/models/spree/promotion/rules/one_use_per_user.rb
spree_core-3.7.0 app/models/spree/promotion/rules/one_use_per_user.rb
spree_core-3.7.0.rc3 app/models/spree/promotion/rules/one_use_per_user.rb
spree_core-3.7.0.rc2 app/models/spree/promotion/rules/one_use_per_user.rb
spree_core-3.7.0.rc1 app/models/spree/promotion/rules/one_use_per_user.rb
spree_core-3.6.6 app/models/spree/promotion/rules/one_use_per_user.rb
spree_core-3.6.5 app/models/spree/promotion/rules/one_use_per_user.rb
spree_core-3.6.4 app/models/spree/promotion/rules/one_use_per_user.rb
spree_core-3.6.3 app/models/spree/promotion/rules/one_use_per_user.rb
spree_core-3.6.2 app/models/spree/promotion/rules/one_use_per_user.rb
spree_core-3.6.1 app/models/spree/promotion/rules/one_use_per_user.rb
spree_core-3.6.0 app/models/spree/promotion/rules/one_use_per_user.rb
spree_core-3.5.0 app/models/spree/promotion/rules/one_use_per_user.rb
spree_core-3.6.0.rc1 app/models/spree/promotion/rules/one_use_per_user.rb
spree_core-3.5.0.rc2 app/models/spree/promotion/rules/one_use_per_user.rb
spree_core-3.5.0.rc1 app/models/spree/promotion/rules/one_use_per_user.rb
spree_core-3.4.5 app/models/spree/promotion/rules/one_use_per_user.rb
solidus_core-2.5.0 app/models/spree/promotion/rules/one_use_per_user.rb
solidus_core-2.5.0.rc1 app/models/spree/promotion/rules/one_use_per_user.rb
solidus_core-2.5.0.beta2 app/models/spree/promotion/rules/one_use_per_user.rb