Move shipping method id setting code to OrderWorkflow service

This commit is contained in:
Luis Ramos
2020-07-28 23:50:47 +01:00
parent c3f99050fd
commit 9cbcf14485
2 changed files with 7 additions and 5 deletions

View File

@@ -175,9 +175,7 @@ class CheckoutController < Spree::StoreController
return if redirect_to_payment_gateway
end
@order.select_shipping_method(shipping_method_id) if @order.state == "delivery"
next if OrderWorkflow.new(@order).next
next if OrderWorkflow.new(@order).next({ shipping_method_id: shipping_method_id })
return update_failed
end

View File

@@ -13,9 +13,13 @@ class OrderWorkflow
advance_order!(advance_order_options)
end
def next
def next(options = {})
tries ||= 3
order.next
result = order.next
after_transition_hook(options)
result
rescue ActiveRecord::StaleObjectError
retry unless (tries -= 1).zero?
false