mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Add customer_details_controller from spree_backend so that we can now merge it with the OFN's decorator
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user