From 138b7824ba6ff33c9f561cbf70bfcb41567c08a2 Mon Sep 17 00:00:00 2001 From: Andy Brett Date: Thu, 19 Aug 2021 10:18:11 -0700 Subject: [PATCH] remove ship address if shipping method does not require it --- app/controllers/split_checkout_controller.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/controllers/split_checkout_controller.rb b/app/controllers/split_checkout_controller.rb index 1eb3938227..f929199929 100644 --- a/app/controllers/split_checkout_controller.rb +++ b/app/controllers/split_checkout_controller.rb @@ -30,6 +30,8 @@ class SplitCheckoutController < ::BaseController end def update + load_shipping_method + filter_ship_address_params populate_ship_address_params if confirm_order || update_order @@ -44,6 +46,16 @@ class SplitCheckoutController < ::BaseController private + def load_shipping_method + @shipping_method = Spree::ShippingMethod.find(params[:shipping_method_id]) + end + + def filter_ship_address_params + return if @shipping_method.require_ship_address + + params[:order].delete(:ship_address_attributes) + end + def populate_ship_address_params return unless params[:order]["Checkout.ship_address_same_as_billing"] == "1"