Class: SolidusPromotions::Conditions::PriceProduct
- Inherits:
-
SolidusPromotions::Condition
- Object
- Spree::Base
- SolidusPromotions::Condition
- SolidusPromotions::Conditions::PriceProduct
- Includes:
- ProductCondition
- Defined in:
- app/models/solidus_promotions/conditions/price_product.rb
Overview
A condition to apply a promotion only to prices with or without selected products
Constant Summary collapse
- MATCH_POLICIES =
%w[include exclude].freeze
Instance Method Summary collapse
Methods included from ProductCondition
included, #preload_relations, #product_ids_string, #product_ids_string=
Methods inherited from SolidusPromotions::Condition
#applicable?, applicable_to, #eligibility_errors, #eligible?, eligible_method_for, inherited, #level, #preload_relations, #to_partial_path, #updateable?
Instance Method Details
#price_eligible?(price, _options = {}) ⇒ Boolean
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/models/solidus_promotions/conditions/price_product.rb', line 13 def price_eligible?(price, = {}) price_matches_products = products.include?(price.variant.product) success = exclude_configured_products? ? !price_matches_products : price_matches_products unless success = exclude_configured_products? ? :has_excluded_product : :no_applicable_products eligibility_errors.add( :base, (), error_code: ) end success end |