Sha256: 34c3902a8f3ac3d3a6303267c90173f02ed6098284d9459d76ce126f4599996c

Contents?: true

Size: 510 Bytes

Versions: 2

Compression:

Stored size: 510 Bytes

Contents

# frozen_string_literal: true

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

        def eligible?(order, _options = {})
          if order.user.blank?
            eligibility_errors.add(:base, eligibility_error_message(:no_user_specified), error_code: :no_user_specified)
          end
          eligibility_errors.empty?
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
solidus_legacy_promotions-4.4.1 app/models/spree/promotion/rules/user_logged_in.rb
solidus_legacy_promotions-4.4.0 app/models/spree/promotion/rules/user_logged_in.rb