Don't clear email and phone fields when using separate billing address. (https://github.com/woocommerce/woocommerce-blocks/pull/4162)
* preseve-billing-data * pluck empty email and phone * add issue number
This commit is contained in:
parent
b9db5d4c51
commit
037dc09f62
|
@ -87,10 +87,16 @@ export const useCheckoutAddress = () => {
|
||||||
previousBillingData.current = billingData;
|
previousBillingData.current = billingData;
|
||||||
setBillingData( shippingAddress );
|
setBillingData( shippingAddress );
|
||||||
} else {
|
} 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( {
|
setBillingData( {
|
||||||
...previousBillingData.current,
|
...billingAddress,
|
||||||
email: undefined,
|
|
||||||
phone: undefined,
|
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
currentShippingAsBilling.current = shippingAsBilling;
|
currentShippingAsBilling.current = shippingAsBilling;
|
||||||
|
|
Loading…
Reference in New Issue