Class: Spree::OrdersController
Instance Method Summary
collapse
#cart_link, #unauthorized
Instance Method Details
#accurate_title ⇒ Object
64
65
66
67
68
69
70
|
# File 'app/controllers/spree/orders_controller.rb', line 64
def accurate_title
if @order && @order.completed?
Spree.t(:order_number, :number => @order.number)
else
Spree.t(:shopping_cart)
end
end
|
#check_authorization ⇒ Object
72
73
74
75
76
77
78
79
80
81
|
# File 'app/controllers/spree/orders_controller.rb', line 72
def check_authorization
session[:access_token] = params[:token] if params[:token]
order = Spree::Order.find_by_number(params[:id]) || current_order
if order
authorize! :edit, order, session[:access_token]
else
authorize! :create, Spree::Order
end
end
|
#edit ⇒ Object
Shows the current incomplete order from the session
37
38
39
40
|
# File 'app/controllers/spree/orders_controller.rb', line 37
def edit
@order = current_order || Order.new
associate_user
end
|
#empty ⇒ Object
56
57
58
59
60
61
62
|
# File 'app/controllers/spree/orders_controller.rb', line 56
def empty
if @order = current_order
@order.empty!
end
redirect_to spree.cart_path
end
|
#populate ⇒ Object
Adds a new item to the order (creating a new order if none already exists)
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'app/controllers/spree/orders_controller.rb', line 43
def populate
populator = Spree::OrderPopulator.new(current_order(create_order_if_necessary: true), current_currency)
if populator.populate(params[:variant_id], params[:quantity])
respond_with(@order) do |format|
format.html { redirect_to cart_path }
end
else
flash[:error] = populator.errors.full_messages.join(" ")
redirect_back_or_default(spree.root_path)
end
end
|
#show ⇒ Object
15
16
17
|
# File 'app/controllers/spree/orders_controller.rb', line 15
def show
@order = Order.find_by_number!(params[:id])
end
|
#update ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'app/controllers/spree/orders_controller.rb', line 19
def update
if @order.contents.update_cart(order_params)
respond_with(@order) do |format|
format.html do
if params.has_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
|