Handle missing shipping address for express block (virtual products)

This commit is contained in:
Alex P 2023-03-23 09:02:17 +02:00
parent 2a0fa49800
commit 02bec2b611
No known key found for this signature in database
GPG key ID: 54487A734A204D71

View file

@ -71,7 +71,12 @@ export const paypalPayerToWc = (payer) => {
* @returns {Object}
*/
export const paypalOrderToWcShippingAddress = (order) => {
const res = paypalShippingToWc(order.purchase_units[0].shipping);
const shipping = order.purchase_units[0].shipping;
if (!shipping) {
return {};
}
const res = paypalShippingToWc(shipping);
// use the name from billing if the same, to avoid possible mistakes when splitting full_name
const billingAddress = paypalPayerToWc(order.payer);