Class: Spree::Admin::Orders::CustomerDetailsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/spree/admin/orders/customer_details_controller.rb

Instance Method Summary collapse

Instance Method Details

#editObject



15
16
17
18
19
20
21
22
23
# File 'app/controllers/spree/admin/orders/customer_details_controller.rb', line 15

def edit
  country_id = default_country_id

  @order.build_bill_address(country_id: country_id) if @order.bill_address.nil?
  @order.build_ship_address(country_id: country_id) if @order.ship_address.nil?

  @order.bill_address.country_id = country_id if @order.bill_address.country.nil?
  @order.ship_address.country_id = country_id if @order.ship_address.country.nil?
end

#showObject



11
12
13
# File 'app/controllers/spree/admin/orders/customer_details_controller.rb', line 11

def show
  edit
end

#updateObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/controllers/spree/admin/orders/customer_details_controller.rb', line 25

def update
  if @order.contents.update_cart(order_params)

    if should_associate_user?
      requested_user = Spree.user_class.find(params[:user_id])
      @order.associate_user!(requested_user, @order.email.blank?)
    end

    unless @order.completed?
      @order.next
      @order.refresh_shipment_rates
    end

    flash[:success] = t('spree.customer_details_updated')
    redirect_to edit_admin_order_url(@order)
  else
    render action: :edit
  end
end