blob: 3f83b8225a2bbc2339403847309b19e66715d19b (
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
|
# 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)
|