Sha256: 52eb9dd66566a27c9b826fe28524a206e4be3e548e128f000bcdb7e8f6a5c550

Contents?: true

Size: 1.48 KB

Versions: 6

Compression:

Stored size: 1.48 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
          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?
        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[:user_id].present?
                @order.user_id = params[:user_id]
                @order.user true
              end
              @order.save
              @order.create_shipment!
              flash[:success] = 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

6 entries across 6 versions & 2 rubygems

Version Path
spree_core-1.3.2 app/controllers/spree/admin/orders/customer_details_controller.rb
spree_core-1.3.1 app/controllers/spree/admin/orders/customer_details_controller.rb
spree_core-1.3.0 app/controllers/spree/admin/orders/customer_details_controller.rb
spree_core-1.3.0.rc2 app/controllers/spree/admin/orders/customer_details_controller.rb
dup_spree_core-1.3.0.rc1 app/controllers/spree/admin/orders/customer_details_controller.rb
spree_core-1.3.0.rc1 app/controllers/spree/admin/orders/customer_details_controller.rb