Class: Spree::Promotion::Rules::OneUsePerUser
Instance Method Summary
collapse
#actionable?, #eligibility_errors, for, #human_description, #human_name, #key
Instance Method Details
#applicable?(promotable) ⇒ Boolean
5
6
7
|
# File 'app/models/spree/promotion/rules/one_use_per_user.rb', line 5
def applicable?(promotable)
promotable.is_a?(Spree::Order)
end
|
#eligible?(order, _options = {}) ⇒ Boolean
9
10
11
12
13
14
15
16
17
18
19
|
# File 'app/models/spree/promotion/rules/one_use_per_user.rb', line 9
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
|