Set billing addr from shipping addr when no payer addr

This commit is contained in:
Narek Zakarian 2024-05-15 22:06:23 +04:00
parent c43af44a2f
commit eaf7985145
No known key found for this signature in database
GPG key ID: 07AFD7E7A9C164A7

View file

@ -139,7 +139,17 @@ export const paypalOrderToWcAddresses = (order) => {
billingAddress = paypalPayerToWc(order.payer);
// no billing address, such as if billing address retrieval is not allowed in the merchant account
if (!billingAddress.address_line_1) {
billingAddress = {...shippingAddress, ...paypalPayerToWc(order.payer)};
// use only non empty values from payer address, otherwise it will override shipping address
let payerAddress = Object.fromEntries(
Object.entries(billingAddress).filter(
([key, value]) => value !== '' && key !== 'country'
)
);
billingAddress = {
...shippingAddress,
...payerAddress
};
}
}