blob: df377ba0180918ff235370d9219e0c6bb5b9c346 (
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
|
module SolidusSubscriptions
module SubscriptionLineItemBuilder
private
def create_subscription_line_item(line_item)
SolidusSubscriptions::LineItem.create!(
subscription_params.merge(spree_line_item: line_item)
)
# Rerun the promotion handler to pickup subscription promotions
Spree::PromotionHandler::Cart.new(line_item.order).activate
if Spree.solidus_gem_version >= Gem::Version.new('2.4.0')
line_item.order.recalculate
else
line_item.order.update!
end
end
def subscription_params
params.require(:subscription_line_item).permit(
SolidusSubscriptions::Config.subscription_line_item_attributes
)
end
end
end
|