From 69b3679a7e585abc8a5068df3bd2457714149939 Mon Sep 17 00:00:00 2001 From: Seghir Nadir Date: Wed, 5 May 2021 12:59:30 +0100 Subject: [PATCH] Don't clear email and phone fields when using separate billing address. (#4162) * preseve-billing-data * pluck empty email and phone * add issue number --- assets/js/base/context/hooks/use-checkout-address.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/assets/js/base/context/hooks/use-checkout-address.js b/assets/js/base/context/hooks/use-checkout-address.js index 5f58b412a17..0ac8b09e573 100644 --- a/assets/js/base/context/hooks/use-checkout-address.js +++ b/assets/js/base/context/hooks/use-checkout-address.js @@ -87,10 +87,16 @@ export const useCheckoutAddress = () => { previousBillingData.current = billingData; setBillingData( shippingAddress ); } else { + const { + // We need to pluck out email and phone from previous billing data because they can be empty, causing the current email and phone to get emptied. See issue #4155 + /* eslint-disable no-unused-vars */ + email, + phone, + /* eslint-enable no-unused-vars */ + ...billingAddress + } = previousBillingData.current; setBillingData( { - ...previousBillingData.current, - email: undefined, - phone: undefined, + ...billingAddress, } ); } currentShippingAsBilling.current = shippingAsBilling;