From 0385aad3017da0d6de48645aadd62d945fc12e62 Mon Sep 17 00:00:00 2001 From: Himad M Date: Wed, 23 Jul 2025 16:32:22 -0400 Subject: [PATCH] Add optional chaining to address properties --- modules/ppcp-blocks/resources/js/Helper/Address.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/ppcp-blocks/resources/js/Helper/Address.js b/modules/ppcp-blocks/resources/js/Helper/Address.js index 6e6338f3c..a4a6fa99d 100644 --- a/modules/ppcp-blocks/resources/js/Helper/Address.js +++ b/modules/ppcp-blocks/resources/js/Helper/Address.js @@ -27,7 +27,7 @@ export const paypalAddressToWc = ( address ) => { admin_area_2: 'city', postal_code: 'postcode', }; - if ( address.city ) { + if ( address?.city ) { // address not from API, such as onShippingChange map = { country_code: 'country', @@ -38,7 +38,7 @@ export const paypalAddressToWc = ( address ) => { } const result = {}; Object.entries( map ).forEach( ( [ paypalKey, wcKey ] ) => { - if ( address[ paypalKey ] ) { + if ( address?.[ paypalKey ] ) { result[ wcKey ] = address[ paypalKey ]; } } );