summaryrefslogtreecommitdiff
path: root/app/models/solidus_subscriptions/promotion/rules/subscription_installment_order.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/solidus_subscriptions/promotion/rules/subscription_installment_order.rb')
-rw-r--r--app/models/solidus_subscriptions/promotion/rules/subscription_installment_order.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/app/models/solidus_subscriptions/promotion/rules/subscription_installment_order.rb b/app/models/solidus_subscriptions/promotion/rules/subscription_installment_order.rb
new file mode 100644
index 0000000..455825d
--- /dev/null
+++ b/app/models/solidus_subscriptions/promotion/rules/subscription_installment_order.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+module SolidusSubscriptions
+ module Promotion
+ module Rules
+ class SubscriptionInstallmentOrder < ::Spree::PromotionRule
+ # Promotion can be applied to an entire order. Will only be true
+ # for Spree::Order
+ #
+ # @param promotable [Object] Any object which could have this
+ # promotion rule applied to it.
+ #
+ # @return [Boolean]
+ def applicable?(promotable)
+ promotable.is_a? ::Spree::Order
+ end
+
+ # An order is eligible if it fulfills a subscription Installment. Will only
+ # return true if the order fulfills one or more Installments
+ #
+ # @param order [Spree::Order] The order which could have this rule applied
+ # to it.
+ #
+ # @return [Boolean]
+ def eligible?(order, **_options)
+ order.subscription_order?
+ end
+ end
+ end
+ end
+end