Sha256: 979fb933c7f895da0ae9acf81b9ceabe4e319c13d1709f83d2c7fa8ae613a28d

Contents?: true

Size: 932 Bytes

Versions: 5

Compression:

Stored size: 932 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

5 entries across 5 versions & 1 rubygems

Version Path
solidus_subscriptions-2.0.0 app/models/solidus_subscriptions/promotion/rules/subscription_installment_order.rb
solidus_subscriptions-1.1.0 app/models/solidus_subscriptions/promotion/rules/subscription_installment_order.rb
solidus_subscriptions-1.0.1 app/models/solidus_subscriptions/promotion/rules/subscription_installment_order.rb
solidus_subscriptions-1.0.0 app/models/solidus_subscriptions/promotion/rules/subscription_installment_order.rb
solidus_subscriptions-1.0.0.rc1 app/models/solidus_subscriptions/promotion/rules/subscription_installment_order.rb