Class: Spree::OrdersController
Instance Method Summary
collapse
#account_link, #api_tokens, #cart_link, #ensure_cart, #forbidden, #unauthorized
Instance Method Details
#edit ⇒ Object
Shows the current incomplete order from the session
35
36
37
38
39
40
|
# File 'app/controllers/spree/orders_controller.rb', line 35
def edit
@order = current_order || Order.incomplete.
includes(line_items: [variant: [:images, :product, option_values: :option_type]]).
find_or_initialize_by(token: cookies.signed[:token])
associate_user
end
|
#empty ⇒ Object
42
43
44
45
46
|
# File 'app/controllers/spree/orders_controller.rb', line 42
def empty
current_order.try(:empty!)
redirect_to spree.cart_path
end
|
#show ⇒ Object
12
13
14
|
# File 'app/controllers/spree/orders_controller.rb', line 12
def show
@order = Order.includes(line_items: [variant: [:option_values, :images, :product]], bill_address: :state, ship_address: :state).find_by!(number: params[:id])
end
|
#update ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'app/controllers/spree/orders_controller.rb', line 16
def update
@variant = Spree::Variant.find(params[:variant_id]) if params[:variant_id]
if Cart::Update.call(order: @order, params: order_params).success?
respond_with(@order) do |format|
format.html do
if params.key?(:checkout)
@order.next if @order.cart?
redirect_to checkout_state_path(@order.checkout_steps.first)
else
redirect_to cart_path
end
end
end
else
respond_with(@order)
end
end
|