summaryrefslogtreecommitdiff
path: root/app/models/solidus_subscriptions/subscription_order_promotion_rule.rb
blob: b78b96a20e3911c138c582f09074b9f83ca48d60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
module SolidusSubscriptions
  class SubscriptionOrderPromotionRule < ::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