Class: Spree::PromotionRule
- Defined in:
- app/models/spree/promotion_rule.rb
Direct Known Subclasses
Spree::Promotion::Rules::Country, Spree::Promotion::Rules::FirstOrder, Spree::Promotion::Rules::ItemTotal, Spree::Promotion::Rules::OneUsePerUser, Spree::Promotion::Rules::OptionValue, Spree::Promotion::Rules::Product, Spree::Promotion::Rules::Taxon, Spree::Promotion::Rules::User, Spree::Promotion::Rules::UserLoggedIn
Class Method Summary collapse
Instance Method Summary collapse
-
#actionable?(_line_item) ⇒ Boolean
This states if a promotion can be applied to the specified line item It is true by default, but can be overridden by promotion rules to provide conditions.
- #applicable?(_promotable) ⇒ Boolean
- #eligibility_errors ⇒ Object
- #eligible?(_promotable, _options = {}) ⇒ Boolean
Methods inherited from Base
belongs_to_required_by_default, page, spree_base_scopes
Methods included from Spree::Preferences::Preferable
#clear_preferences, #default_preferences, #defined_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_type, #set_preference
Class Method Details
.for(promotable) ⇒ Object
10 11 12 |
# File 'app/models/spree/promotion_rule.rb', line 10 def self.for(promotable) all.select { |rule| rule.applicable?(promotable) } end |
Instance Method Details
#actionable?(_line_item) ⇒ Boolean
This states if a promotion can be applied to the specified line item It is true by default, but can be overridden by promotion rules to provide conditions
24 25 26 |
# File 'app/models/spree/promotion_rule.rb', line 24 def actionable?(_line_item) true end |
#applicable?(_promotable) ⇒ Boolean
14 15 16 |
# File 'app/models/spree/promotion_rule.rb', line 14 def applicable?(_promotable) raise 'applicable? should be implemented in a sub-class of Spree::PromotionRule' end |
#eligibility_errors ⇒ Object
28 29 30 |
# File 'app/models/spree/promotion_rule.rb', line 28 def eligibility_errors @eligibility_errors ||= ActiveModel::Errors.new(self) end |
#eligible?(_promotable, _options = {}) ⇒ Boolean
18 19 20 |
# File 'app/models/spree/promotion_rule.rb', line 18 def eligible?(_promotable, = {}) raise 'eligible? should be implemented in a sub-class of Spree::PromotionRule' end |