Class: Spree::Promotion::Rules::Product
- Inherits:
-
Spree::PromotionRule
- Object
- ActiveRecord::Base
- Spree::PromotionRule
- Spree::Promotion::Rules::Product
- Defined in:
- app/models/spree/promotion/rules/product.rb
Constant Summary collapse
- MATCH_POLICIES =
%w(any all)
Instance Method Summary collapse
- #eligible?(order, options = {}) ⇒ Boolean
-
#eligible_products ⇒ Object
scope/association that is used to test eligibility.
- #product_ids_string ⇒ Object
- #product_ids_string=(s) ⇒ Object
Instance Method Details
#eligible?(order, options = {}) ⇒ Boolean
19 20 21 22 23 24 25 26 |
# File 'app/models/spree/promotion/rules/product.rb', line 19 def eligible?(order, = {}) return true if eligible_products.empty? if preferred_match_policy == 'all' eligible_products.all? {|p| order.products.include?(p) } else order.products.any? {|p| eligible_products.include?(p) } end end |
#eligible_products ⇒ Object
scope/association that is used to test eligibility
15 16 17 |
# File 'app/models/spree/promotion/rules/product.rb', line 15 def eligible_products products end |
#product_ids_string ⇒ Object
28 29 30 |
# File 'app/models/spree/promotion/rules/product.rb', line 28 def product_ids_string product_ids.join(',') end |
#product_ids_string=(s) ⇒ Object
32 33 34 |
# File 'app/models/spree/promotion/rules/product.rb', line 32 def product_ids_string=(s) self.product_ids = s.to_s.split(',').map(&:strip) end |