Skip to content

Commit

Permalink
remove checkout controller
Browse files Browse the repository at this point in the history
  • Loading branch information
abdellani committed Jun 1, 2023
1 parent eb1d909 commit 214021f
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 671 deletions.
187 changes: 0 additions & 187 deletions app/controllers/checkout_controller.rb

This file was deleted.

8 changes: 0 additions & 8 deletions app/controllers/concerns/order_stock_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ def valid_order_line_items?
def handle_insufficient_stock
return if sufficient_stock?

reset_order_to_cart

flash[:error] = Spree.t(:inventory_error_flash_for_insufficient_quantity)
redirect_to main_app.cart_path
end
Expand Down Expand Up @@ -43,10 +41,4 @@ def check_order_cycle_expiry
def sufficient_stock?
@sufficient_stock ||= @order.insufficient_stock_lines.blank?
end

def reset_order_to_cart
return if OpenFoodNetwork::FeatureToggle.enabled? :split_checkout, spree_current_user

OrderCheckoutRestart.new(@order).call
end
end
7 changes: 2 additions & 5 deletions app/models/spree/order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ class Order < ApplicationRecord
order.update_totals
order.payment_required?
}
go_to_state :confirmation, if: ->(order) {
OpenFoodNetwork::FeatureToggle.enabled? :split_checkout, order.created_by
}
go_to_state :confirmation
go_to_state :complete
end

Expand Down Expand Up @@ -320,8 +318,7 @@ def ship_total
# Creates new tax charges if there are any applicable rates. If prices already
# include taxes then price adjustments are created instead.
def create_tax_charge!
return if state.in?(["cart", "address", "delivery"]) &&
OpenFoodNetwork::FeatureToggle.enabled?(:split_checkout)
return if state.in?(["cart", "address", "delivery"])

clear_legacy_taxes!

Expand Down
85 changes: 0 additions & 85 deletions app/services/checkout/form_data_adapter.rb

This file was deleted.

25 changes: 0 additions & 25 deletions app/services/permitted_attributes/checkout.rb

This file was deleted.

21 changes: 6 additions & 15 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,24 +84,15 @@
get "/stripe/authorize/:order_number", to: "stripe#authorize", as: :authorize_stripe
end

constraints FeatureToggleConstraint.new(:split_checkout) do
get '/checkout', to: 'split_checkout#edit'
get '/checkout', to: 'split_checkout#edit'

constraints step: /(details|payment|summary)/ do
get '/checkout/:step', to: 'split_checkout#edit', as: :checkout_step
put '/checkout/:step', to: 'split_checkout#update', as: :checkout_update
end

# Redirects to the new checkout for any other 'step' (ie. /checkout/cart from the legacy checkout)
get '/checkout/:other', to: redirect('/checkout')
constraints step: /(details|payment|summary)/ do
get '/checkout/:step', to: 'split_checkout#edit', as: :checkout_step
put '/checkout/:step', to: 'split_checkout#update', as: :checkout_update
end

# When the split_checkout feature is disabled for the current user, use the legacy checkout
constraints FeatureToggleConstraint.new(:split_checkout, negate: true) do
get '/checkout', to: 'checkout#edit'
put '/checkout', to: 'checkout#update', as: :update_checkout
get '/checkout/:state', to: 'checkout#edit', as: :checkout_state
end
# Redirects to the new checkout for any other 'step' (ie. /checkout/cart from the legacy checkout)
get '/checkout/:other', to: redirect('/checkout')

get 'embedded_shopfront/shopfront_session', to: 'application#shopfront_session'
post 'embedded_shopfront/enable', to: 'application#enable_embedded_styles'
Expand Down
Loading

0 comments on commit 214021f

Please sign in to comment.