Class: Spree::CheckoutController

Inherits:
StoreController show all
Includes:
Spree::Checkout::AddressBook
Defined in:
app/controllers/spree/checkout_controller.rb

Overview

This is somewhat contrary to standard REST convention since there is not actually a Checkout object. There’s enough distinct logic specific to checkout which has nothing to do with updating an order that this approach is waranted.

Instance Method Summary collapse

Methods inherited from StoreController

#account_link, #api_tokens, #cart_link, #ensure_cart, #forbidden, #unauthorized

Instance Method Details

#updateObject

Updates the order and advances to the next state (when possible.)



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'app/controllers/spree/checkout_controller.rb', line 33

def update
  if @order.update_from_params(params, permitted_checkout_attributes, request.headers.env)
    @order.temporary_address = !params[:save_user_address]
    unless @order.next
      flash[:error] = @order.errors.full_messages.join("\n")
      redirect_to(checkout_state_path(@order.state)) && return
    end

    if @order.completed?
      @current_order = nil
      flash['order_completed'] = true
      redirect_to completion_route
    else
      redirect_to checkout_state_path(@order.state)
    end
  else
    render :edit
  end
end