Class: Spree::Promotion::Rules::UserLoggedIn

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

Instance Method Summary collapse

Methods inherited from Spree::PromotionRule

#actionable?, #eligibility_errors, for, #to_partial_path

Methods inherited from Base

display_includes, #initialize_preference_defaults, page, preference

Instance Method Details

#applicable?(promotable) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
# File 'core/app/models/spree/promotion/rules/user_logged_in.rb', line 7

def applicable?(promotable)
  promotable.is_a?(Spree::Order)
end

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

Returns:

  • (Boolean)


11
12
13
14
15
16
# File 'core/app/models/spree/promotion/rules/user_logged_in.rb', line 11

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