Sha256: be72e815a663a8d2e6d0c27e376359304f7005a97f1007c4f61b77c745417c98

Contents?: true

Size: 1.43 KB

Versions: 2

Compression:

Stored size: 1.43 KB

Contents

module Spree
  module Admin
    module Orders
      class CustomerDetailsController < Spree::Admin::BaseController
        before_filter :load_order

        def show
          edit
          render :action => :edit
        end

        def edit
          @order.bill_address = Address.default if @order.bill_address.nil?
          @order.ship_address = Address.default if @order.ship_address.nil?
        end

        def update
          if @order.update_attributes(params[:order])
            shipping_method = @order.available_shipping_methods(:front_end).first
            if shipping_method
              @order.shipping_method = shipping_method

              if params[:guest_checkout] == 'false' && params[:user_id].present?
                @order.user_id = params[:user_id]
                @order.user true
              end
              @order.save
              @order.create_shipment!
              flash[:notice] = t('customer_details_updated')
              redirect_to edit_admin_order_shipment_path(@order, @order.shipment)
            else
              flash[:error] = t('errors.messages.no_shipping_methods_available')
              redirect_to admin_order_customer_path(@order)
            end
          else
            render :action => :edit
          end

        end

        private

        def load_order
          @order = Order.find_by_number(params[:order_id], :include => :adjustments)
        end

      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spree_core-1.0.7 app/controllers/spree/admin/orders/customer_details_controller.rb
spree_core-1.0.6 app/controllers/spree/admin/orders/customer_details_controller.rb