Skip to content

Commit 0f2fcd8

Browse files
committed
Run legacy promotion handler "cart" if legacy promo system present
In the legacy promotion system, there's a separation of tasks between `order.recalculate` and `PromotionHandler::Cart`. `order.recalculate` will only recalculate already existing promotion adjustments, but will not check for any new promotions that might need to be applied. In the new promotion system, both of these tasks are handled by `order.recalculate`. If the legacy promotion system is present, but not active, calling this promotion handler will result in a single database call, which is an acceptable price to pay I think.
1 parent f78e322 commit 0f2fcd8

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

lib/solidus_subscriptions/checkout.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ def populate_order(order)
4242
end
4343

4444
def finalize_order(order)
45+
# Rerun the legacy promotion handler
46+
# `solidus_promotions` does not need this handler, and will pickup promotions in `order.recalculate`
47+
::Spree::PromotionHandler::Cart.new(order).activate if defined?(::Spree::PromotionHandler::Cart)
4548
order.recalculate
4649

4750
order.checkout_steps[0...-1].each do

lib/solidus_subscriptions/subscription_line_item_builder.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ def create_subscription_line_item(line_item)
99
subscription_params.merge(spree_line_item: line_item)
1010
)
1111

12+
# Rerun the legacy promotion handler to pickup subscription promotions
13+
# `solidus_promotions` does not need this handler, and will pickup promotions in `order.recalculate`
14+
::Spree::PromotionHandler::Cart.new(line_item.order).activate if defined?(::Spree::PromotionHandler::Cart)
1215
line_item.order.recalculate
1316
end
1417

0 commit comments

Comments
 (0)