From ca7dcb82b831ecd942d53f91b5767ecce532a57d Mon Sep 17 00:00:00 2001 From: Gaetan Craig-Riou Date: Mon, 26 Jun 2023 14:48:22 +1000 Subject: [PATCH] Apply voucher after transitionning to the confirmation step Testing that VoucherAdjustmentsService.calculate has been called after a transition doens't work, skipping test for now. --- app/models/spree/order/checkout.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/models/spree/order/checkout.rb b/app/models/spree/order/checkout.rb index 3575dc1ae0..030df13964 100644 --- a/app/models/spree/order/checkout.rb +++ b/app/models/spree/order/checkout.rb @@ -81,6 +81,12 @@ module Spree order.create_tax_charge! order.update_totals_and_states end + + after_transition to: :confirmation do |order| + VoucherAdjustmentsService.calculate(order) + order.update_totals_and_states + end + after_transition to: :complete, do: :finalize! after_transition to: :resumed, do: :after_resume after_transition to: :canceled, do: :after_cancel