From 69e4670a175f87eee1fb95e54fa1c459456b36f1 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Mon, 28 Jun 2021 17:12:13 +0100 Subject: [PATCH] Tidy up building default address objects --- .../spree/admin/orders/customer_details_controller.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/controllers/spree/admin/orders/customer_details_controller.rb b/app/controllers/spree/admin/orders/customer_details_controller.rb index 5b4806c815..271b6b1b16 100644 --- a/app/controllers/spree/admin/orders/customer_details_controller.rb +++ b/app/controllers/spree/admin/orders/customer_details_controller.rb @@ -14,9 +14,7 @@ module Spree 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? + build_addresses end def update @@ -44,6 +42,12 @@ module Spree private + def build_addresses + 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 refresh_shipment_rates @order.shipments.map(&:refresh_rates) end