Class: Spree::Promotion::Rules::OneUsePerUser
- Inherits:
-
Spree::PromotionRule
- Object
- ActiveRecord::Base
- Base
- Spree::PromotionRule
- Spree::Promotion::Rules::OneUsePerUser
- Defined in:
- app/models/spree/promotion/rules/one_use_per_user.rb
Instance Method Summary collapse
Methods inherited from Spree::PromotionRule
#actionable?, #eligibility_errors, #preload_relations, #to_partial_path
Methods inherited from Base
Methods included from Core::Permalinks
#generate_permalink, #save_permalink
Instance Method Details
#applicable?(promotable) ⇒ Boolean
7 8 9 |
# File 'app/models/spree/promotion/rules/one_use_per_user.rb', line 7 def applicable?(promotable) promotable.is_a?(Spree::Order) end |
#eligible?(order, _options = {}) ⇒ Boolean
11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/models/spree/promotion/rules/one_use_per_user.rb', line 11 def eligible?(order, = {}) if order.user.present? if promotion.used_by?(order.user, [order]) eligibility_errors.add(:base, (:limit_once_per_user), error_code: :limit_once_per_user) end else eligibility_errors.add(:base, (:no_user_specified), error_code: :no_user_specified) end eligibility_errors.empty? end |