Sha256: 3d1277c856f0573c7db0205ad4208cf81c27afcce0e587a0a576b4b2c1bf0eeb

Contents?: true

Size: 784 Bytes

Versions: 1

Compression:

Stored size: 784 Bytes

Contents

# frozen_string_literal: true

# Once an order is finalized its subscriptions line items should be converted
# into active subscriptions. This hooks into Spree::Order#finalize! and
# passes all subscription_line_items present on the order to the Subscription
# generator which will build and persist the subscriptions
module SolidusSubscriptions
  module Spree
    module Order
      module FinalizeCreatesSubscriptions
        def finalize!
          SolidusSubscriptions::SubscriptionGenerator.group(subscription_line_items).each do |line_items|
            SolidusSubscriptions::SubscriptionGenerator.activate(line_items)
          end

          super
        end
      end
    end
  end
end

Spree::Order.prepend(SolidusSubscriptions::Spree::Order::FinalizeCreatesSubscriptions)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
solidus_subscriptions-1.0.0.rc1 app/decorators/models/solidus_subscriptions/spree/order/finalize_creates_subscriptions.rb