diff --git a/app/controllers/split_checkout_controller.rb b/app/controllers/split_checkout_controller.rb index 997ef5e5bf..752cec3010 100644 --- a/app/controllers/split_checkout_controller.rb +++ b/app/controllers/split_checkout_controller.rb @@ -59,12 +59,17 @@ class SplitCheckoutController < ::BaseController def order_error_messages # Remove ship_address.* errors if no shipping method is not selected - remove_ship_address_errors if @order.errors[:shipping_method].present? + remove_ship_address_errors if no_ship_address_needed? + # Reorder errors to make sure the most important ones are shown first # and finally, return the error messages to sentence reorder_errors.map(&:full_message).to_sentence end + def no_ship_address_needed? + @order.errors[:shipping_method].present? || params[:ship_address_same_as_billing] == "1" + end + def remove_ship_address_errors @order.errors.delete("ship_address.firstname") @order.errors.delete("ship_address.address1")