Sha256: 2195cdcb2437e151769c24769ca8030e7764c986409279ab3345d452238d4061

Contents?: true

Size: 802 Bytes

Versions: 1

Compression:

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

          reload

          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 app/decorators/models/solidus_subscriptions/spree/order/finalize_creates_subscriptions.rb