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



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

def edit
  country_id = Address.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



8
9
10
11
# File 'app/controllers/spree/admin/orders/customer_details_controller.rb', line 8

def show
  edit
  render action: :edit
end

#updateObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/controllers/spree/admin/orders/customer_details_controller.rb', line 22

def update
  if @order.update_attributes(order_params)
    @order.associate_user!(@user, @order.email.blank?) unless guest_checkout?
    @order.next unless @order.complete?
    @order.refresh_shipment_rates(Spree::ShippingMethod::DISPLAY_ON_FRONT_AND_BACK_END)

    if @order.errors.empty?
      flash[:success] = Spree.t('customer_details_updated')
      redirect_to edit_admin_order_url(@order)
    else
      render action: :edit
    end
  else
    render action: :edit
  end
end