Class: Spree::Admin::Orders::ContactInformationController

Inherits:
BaseController
  • Object
show all
Includes:
Spree::Admin::OrderConcern
Defined in:
app/controllers/spree/admin/orders/contact_information_controller.rb

Instance Method Summary collapse

Methods included from BreadcrumbConcern

#add_breadcrumb_icon_instance_var

Instance Method Details

#editObject



9
# File 'app/controllers/spree/admin/orders/contact_information_controller.rb', line 9

def edit; end

#updateObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/controllers/spree/admin/orders/contact_information_controller.rb', line 11

def update
  if Spree::Orders::UpdateContactInformation.call(order: @order, order_params: order_params).success?
    unless @order.completed?
      max_state = if @order.ship_address.present?
                    @order.ensure_updated_shipments
                    'payment'
                  else
                    'address'
                  end

      result = Spree.checkout_advance_service.call(order: @order, state: max_state)

      unless result.success?
        flash[:error] = result.error.value.full_messages.to_sentence
        @order.ensure_updated_shipments
        return redirect_to spree.edit_admin_order_path(@order)
      end
    end

    flash[:success] = Spree.t(:successfully_updated, resource: Spree.t(:contact_information))
    redirect_to spree.edit_admin_order_path(@order)
  else
    render :edit
  end
end