Class: SolidusFriendlyPromotions::Conditions::OneUsePerUser
- Inherits:
-
SolidusFriendlyPromotions::Condition
- Object
- Spree::Base
- SolidusFriendlyPromotions::Condition
- SolidusFriendlyPromotions::Conditions::OneUsePerUser
- Includes:
- OrderLevelCondition
- Defined in:
- app/models/solidus_friendly_promotions/conditions/one_use_per_user.rb
Instance Method Summary collapse
Methods included from OrderLevelCondition
Methods inherited from SolidusFriendlyPromotions::Condition
#applicable?, #eligibility_errors, #level, #preload_relations, #to_partial_path, #updateable?
Instance Method Details
#eligible?(order, _options = {}) ⇒ Boolean
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/models/solidus_friendly_promotions/conditions/one_use_per_user.rb', line 8 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 |