mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-13 04:00:21 +00:00
add redirection to correct step
This commit is contained in:
committed by
Jean-Baptiste Bellet
parent
87a0a5846d
commit
0ea968a900
@@ -1,15 +1,17 @@
|
||||
class SplitCheckoutController < CheckoutController
|
||||
def edit
|
||||
redirect_to_step if request.path == "/checkout"
|
||||
super
|
||||
end
|
||||
|
||||
def update
|
||||
byebug
|
||||
params_adapter = Checkout::FormDataAdapter.new(permitted_params, @order, spree_current_user)
|
||||
return action_failed unless @order.update(params_adapter.params[:order] || {})
|
||||
|
||||
checkout_workflow(params_adapter.shipping_method_id, params[:advance_to_state] || "delivery")
|
||||
rescue Spree::Core::GatewayError => e
|
||||
byebug
|
||||
rescue_from_spree_gateway_error(e)
|
||||
rescue StandardError => e
|
||||
byebug
|
||||
flash[:error] = I18n.t("checkout.failed")
|
||||
action_failed(e)
|
||||
ensure
|
||||
@@ -18,9 +20,25 @@ class SplitCheckoutController < CheckoutController
|
||||
|
||||
private
|
||||
|
||||
def redirect_to_step
|
||||
if @order.state = "payment"
|
||||
if @order.payment_method_id.nil?
|
||||
redirect_to checkout_payment_method_path
|
||||
else
|
||||
redirect_to checkout_order_summary_path
|
||||
end
|
||||
elsif @order.state == "cart"
|
||||
redirect_to checkout_your_details_path
|
||||
end
|
||||
end
|
||||
|
||||
def redirect_to_payment_gateway
|
||||
return unless params&.dig(:order)&.dig(:payments_attributes)&.first&.dig(:payments_attributes)
|
||||
|
||||
super
|
||||
end
|
||||
|
||||
def update_response
|
||||
redirect_to checkout_payment_method_path
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user