From 51bca7ce2fbf53158137c8f8592a165215280e68 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Wed, 27 Nov 2019 21:47:10 +0000 Subject: [PATCH] Add customer_details_controller from spree_backend so that we can now merge it with the OFN's decorator --- .../orders/customer_details_controller.rb | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 app/controllers/spree/admin/orders/customer_details_controller.rb diff --git a/app/controllers/spree/admin/orders/customer_details_controller.rb b/app/controllers/spree/admin/orders/customer_details_controller.rb new file mode 100644 index 0000000000..151e3e4d5a --- /dev/null +++ b/app/controllers/spree/admin/orders/customer_details_controller.rb @@ -0,0 +1,43 @@ +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]) + if params[:guest_checkout] == "false" + @order.associate_user!(Spree.user_class.find_by_email(@order.email)) + end + while @order.next; end + + @order.shipments.map &:refresh_rates + flash[:success] = Spree.t('customer_details_updated') + redirect_to admin_order_customer_path(@order) + 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