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

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Spree::PromotionRule

#actionable?, additional_permitted_attributes, #eligibility_errors, for, human_description, #human_description, human_name, #human_name, #key

Class Method Details

.api_typeObject

Wire-format shorthand is ‘customer_logged_in` (the model is still `UserLoggedIn` pre-6.0 rename, see docs/plans/6.0-platform-auth.md).



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

def self.api_type
  'customer_logged_in'
end

Instance Method Details

#applicable?(promotable) ⇒ Boolean

Returns:



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

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

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

Returns:



15
16
17
18
19
20
# File 'app/models/spree/promotion/rules/user_logged_in.rb', line 15

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