Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit 3be65be

Browse files
authored
Don't clear email and phone fields when using separate billing address. (#4162)
* preseve-billing-data * pluck empty email and phone * add issue number
1 parent 36e316c commit 3be65be

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

assets/js/base/context/hooks/use-checkout-address.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,16 @@ export const useCheckoutAddress = () => {
8787
previousBillingData.current = billingData;
8888
setBillingData( shippingAddress );
8989
} else {
90+
const {
91+
// 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
92+
/* eslint-disable no-unused-vars */
93+
email,
94+
phone,
95+
/* eslint-enable no-unused-vars */
96+
...billingAddress
97+
} = previousBillingData.current;
9098
setBillingData( {
91-
...previousBillingData.current,
92-
email: undefined,
93-
phone: undefined,
99+
...billingAddress,
94100
} );
95101
}
96102
currentShippingAsBilling.current = shippingAsBilling;

0 commit comments

Comments
 (0)