Class: Spree::OrdersController
Instance Method Summary
collapse
#account_link, #api_tokens, #cart_link, #ensure_cart
Instance Method Details
#edit ⇒ Object
Shows the current incomplete order from the session
33
34
35
36
37
38
|
# File 'app/controllers/spree/orders_controller.rb', line 33
def edit
@order = current_order || current_store.orders.incomplete.
includes(line_items: [variant: [:images, :product, option_values: :option_type]]).
find_or_initialize_by(token: cookies.signed[:token])
associate_user
end
|
#empty ⇒ Object
40
41
42
43
44
|
# File 'app/controllers/spree/orders_controller.rb', line 40
def empty
cart_empty_service.call(order: current_order)
redirect_to spree.cart_path
end
|
#show ⇒ Object
10
11
12
|
# File 'app/controllers/spree/orders_controller.rb', line 10
def show
@order = current_store.orders.includes(line_items: [variant: [:option_values, :images, :product]], bill_address: :state, ship_address: :state).find_by!(number: params[:id])
end
|
#update ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'app/controllers/spree/orders_controller.rb', line 14
def update
@variant = curret_store.variants.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 spree.checkout_state_path(@order.checkout_steps.first)
else
redirect_to spree.cart_path
end
end
end
else
respond_with(@order, status: :unprocessable_entity)
end
end
|