The ship address is filled from bill address for some attributes

firstname, lastname and phone are the same between those two address. Fill it automatically.
This commit is contained in:
Jean-Baptiste Bellet
2021-08-23 15:42:29 +02:00
parent 1ecfeca88c
commit 9fd126ca0f

View File

@@ -52,6 +52,7 @@ class SplitCheckoutController < ::BaseController
def handle_shipping_method_selection
load_shipping_method
filter_ship_address_params
populate_ship_address_common_params
populate_ship_address_params
@shipping_method_id = params[:shipping_method_id]
@ship_address_same_as_billing = params[:order]["Checkout.ship_address_same_as_billing"]
@@ -68,6 +69,12 @@ class SplitCheckoutController < ::BaseController
params[:order].delete(:ship_address_attributes)
end
def populate_ship_address_common_params
params[:order][:ship_address_attributes][:firstname] = params[:order][:bill_address_attributes][:firstname]
params[:order][:ship_address_attributes][:lastname] = params[:order][:bill_address_attributes][:lastname]
params[:order][:ship_address_attributes][:phone] = params[:order][:bill_address_attributes][:phone]
end
def populate_ship_address_params
return unless params[:order]["Checkout.ship_address_same_as_billing"] == "1"