Improve order workflow shipping method selection

This commit is contained in:
Matt-Yorkley
2021-08-12 12:01:25 +01:00
parent 5fb3943634
commit dbefd95b5e
2 changed files with 11 additions and 5 deletions

View File

@@ -82,9 +82,11 @@ class SplitCheckoutController < ::BaseController
end
def advance_order_state
return if @order.confirmation? || @order.complete?
return if @order.complete?
OrderWorkflow.new(@order).advance_to_confirmation
workflow_options = raw_params.slice(:shipping_method_id)
OrderWorkflow.new(@order).advance_to_confirmation(workflow_options)
end
def checkout_step

View File

@@ -27,8 +27,12 @@ class OrderWorkflow
advance_to_state("payment", advance_order_options)
end
def advance_to_confirmation
advance_to_state("confirmation", advance_order_options)
def advance_to_confirmation(options = {})
if options[:shipping_method_id]
order.select_shipping_method(options[:shipping_method_id])
end
advance_to_state("confirmation")
end
private
@@ -38,7 +42,7 @@ class OrderWorkflow
{ shipping_method_id: shipping_method_id }
end
def advance_to_state(target_state, options)
def advance_to_state(target_state, options = {})
until order.state == target_state
break unless order.next