Sha256: 88efe5b6489b957b733108734ba91f9c13ecc8b4351a13440a3c806a4f979d23
Contents?: true
Size: 1.94 KB
Versions: 1
Compression:
Stored size: 1.94 KB
Contents
module Spree module Admin module Orders class CustomerDetailsController < Spree::Admin::BaseController before_action :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? @order.bill_address.country_id = country_id if @order.bill_address.country.nil? @order.ship_address.country_id = country_id if @order.ship_address.country.nil? end def update if @order.contents.update_cart(order_params) if should_associate_user? requested_user = Spree.user_class.find(params[:user_id]) @order.associate_user!(Spree.user_class.find(params[:user_id]), @order.email.blank?) end unless @order.completed? @order.next @order.refresh_shipment_rates end flash[:success] = Spree.t('customer_details_updated') redirect_to edit_admin_order_url(@order) else render :action => :edit end end private def order_params params.require(:order).permit( :email, :use_billing, :bill_address_attributes => permitted_address_attributes, :ship_address_attributes => permitted_address_attributes ) end def load_order @order = Order.includes(:adjustments).find_by_number!(params[:order_id]) end def model_class Spree::Order end def should_associate_user? params[:guest_checkout] == "false" && params[:user_id] && params[:user_id].to_i != @order.user_id end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
solidus_backend-1.0.0.pre | app/controllers/spree/admin/orders/customer_details_controller.rb |