Class: SolidusSubscriptions::Promotion::Rules::SubscriptionCreationOrder
- Inherits:
-
Spree::PromotionRule
- Object
- Spree::PromotionRule
- SolidusSubscriptions::Promotion::Rules::SubscriptionCreationOrder
- Defined in:
- app/models/solidus_subscriptions/promotion/rules/subscription_creation_order.rb
Instance Method Summary collapse
-
#actionable?(line_item) ⇒ Boolean
Certain actions create adjustments on line items.
-
#applicable?(promotable) ⇒ Boolean
Promotion can be applied to an entire order.
-
#eligible?(order, _options = {}) ⇒ Boolean
An order is eligible if it contains a line item with an associates subscription_line_item.
Instance Method Details
#actionable?(line_item) ⇒ Boolean
Certain actions create adjustments on line items. In this case, only line items with associated subscription_line_items are eligible to be adjusted. Will only return true # if :line_item has an associated subscription.
38 39 40 |
# File 'app/models/solidus_subscriptions/promotion/rules/subscription_creation_order.rb', line 38 def actionable?(line_item) line_item.subscription_line_items.present? end |
#applicable?(promotable) ⇒ Boolean
Promotion can be applied to an entire order. Will only be true for Spree::Order
14 15 16 |
# File 'app/models/solidus_subscriptions/promotion/rules/subscription_creation_order.rb', line 14 def applicable?(promotable) promotable.is_a? ::Spree::Order end |
#eligible?(order, _options = {}) ⇒ Boolean
An order is eligible if it contains a line item with an associates subscription_line_item. This rule applies to order and so its eligibility will always be considered against an order. Will only return true for orders containing Spree::Line item with associated subscription_line_items
27 28 29 |
# File 'app/models/solidus_subscriptions/promotion/rules/subscription_creation_order.rb', line 27 def eligible?(order, = {}) order.subscription_line_items.any? end |