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

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

Instance Method Summary collapse

Methods inherited from Spree::PromotionRule

#actionable?, #eligibility_errors, for

Methods inherited from Base

page

Methods included from Spree::Preferences::Preferable

#clear_preferences, #default_preferences, #defined_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_type, #set_preference

Instance Method Details

#applicable?(promotable) ⇒ Boolean


5
6
7
# File 'app/models/spree/promotion/rules/user_logged_in.rb', line 5

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

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


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

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