Tidy up use of @checkout_step

This commit is contained in:
Matt-Yorkley
2021-08-11 16:19:42 +01:00
parent 3c2c3a1801
commit 41ffffe170
3 changed files with 10 additions and 7 deletions

View File

@@ -15,7 +15,6 @@ class SplitCheckoutController < ::BaseController
# Otherwise we fail on duplicate indexes or end up with negative stock.
prepend_around_action CurrentOrderLocker, only: [:edit, :update]
prepend_before_action :set_checkout_step
prepend_before_action :check_hub_ready_for_checkout
prepend_before_action :check_order_cycle_expiry
prepend_before_action :require_order_cycle
@@ -37,7 +36,7 @@ class SplitCheckoutController < ::BaseController
def edit
return handle_redirect_from_stripe if valid_payment_intent_provided?
redirect_to_step unless @checkout_step
redirect_to_step unless checkout_step
# This is only required because of spree_paypal_express. If we implement
# a version of paypal that uses this controller, and more specifically
@@ -68,8 +67,8 @@ class SplitCheckoutController < ::BaseController
private
def set_checkout_step
@checkout_step = params[:step]
def checkout_step
@checkout_step ||= params[:step]
end
def order_params

View File

@@ -123,7 +123,11 @@ module CheckoutHelper
end
end
def checkout_step
params[:step]
end
def checkout_step?(step)
params[:step] == step.to_s
checkout_step == step.to_s
end
end

View File

@@ -2,5 +2,5 @@
= inject_saved_credit_cards
%div.checkout-step.medium-6
= form_with url: checkout_update_path(@checkout_step), model: @order, method: :put do |f|
= render "split_checkout/#{@checkout_step}", f: f
= form_with url: checkout_update_path(checkout_step), model: @order, method: :put do |f|
= render "split_checkout/#{checkout_step}", f: f