From cf0f148dba972055a548bf3b62fbf179e60ce74b Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Wed, 7 Jun 2023 00:50:08 +0100 Subject: [PATCH] Advance order when creating a shipment This action gets called from the order edit page when adding line items and it's one of the places that needs to advance the order *before* redirecting back to the order edit action --- app/controllers/api/v0/shipments_controller.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/controllers/api/v0/shipments_controller.rb b/app/controllers/api/v0/shipments_controller.rb index 0905abe954..98a705e277 100644 --- a/app/controllers/api/v0/shipments_controller.rb +++ b/app/controllers/api/v0/shipments_controller.rb @@ -21,6 +21,10 @@ module Api @shipment.refresh_rates @shipment.save! + if @order.line_items.any? && @order.state.in?(["cart", "address", "delivery"]) + OrderWorkflow.new(@order).advance_to_payment + end + render json: @shipment.reload, serializer: Api::ShipmentSerializer, status: :ok end