Sha256: c366296c36325f05f7f6b0bcbef2ab1cdf2462e1e60999b5dbc5d4a1fd6362cd

Contents?: true

Size: 935 Bytes

Versions: 2

Compression:

Stored size: 935 Bytes

Contents

# 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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
solidus_subscriptions-2.0.2 app/models/solidus_subscriptions/promotion/rules/subscription_installment_order.rb
solidus_subscriptions-2.0.1 app/models/solidus_subscriptions/promotion/rules/subscription_installment_order.rb