add SplitCheckoutController and conditional route

This commit is contained in:
Andy Brett
2021-07-04 09:40:57 -07:00
committed by Jean-Baptiste Bellet
parent 49f026629c
commit af79969d96
3 changed files with 23 additions and 4 deletions

View File

@@ -0,0 +1,9 @@
class SplitCheckoutConstraint
def matches?(request)
Flipper.enabled? :split_checkout, current_user(request)
end
def current_user(request)
@spree_current_user ||= request.env['warden'].user
end
end

View File

@@ -0,0 +1,3 @@
class SplitCheckoutController < CheckoutController
end

View File

@@ -69,10 +69,17 @@ Openfoodnetwork::Application.routes.draw do
resources :webhooks, only: [:create]
end
get '/checkout', to: 'checkout#edit' , as: :checkout
put '/checkout', to: 'checkout#update' , as: :update_checkout
get '/checkout/:state', to: 'checkout#edit', as: :checkout_state
get '/checkout/paypal_payment/:order_id', to: 'checkout#paypal_payment', as: :paypal_payment
constraints(SplitCheckoutConstraint.new) do
get '/checkout', to: 'split_checkout#edit', as: :checkout
put '/checkout', to: 'split_checkout#update', as: :update_checkout
get '/checkout/:state', to: 'split_checkout#edit', as: :checkout_state
get '/checkout/paypal_payment/:order_id', to: 'split_checkout#paypal_payment', as: :paypal_payment
end
get '/checkout', to: 'checkout#edit'
put '/checkout', to: 'checkout#update'
get '/checkout/:state', to: 'checkout#edit'
get '/checkout/paypal_payment/:order_id', to: 'checkout#paypal_payment'
get 'embedded_shopfront/shopfront_session', to: 'application#shopfront_session'
post 'embedded_shopfront/enable', to: 'application#enable_embedded_styles'