Merge pull request #3551 from woocommerce/PCP-5027-checkout-error

Fix undefined properties error in checkout block (5027)
This commit is contained in:
Niklas Gutberlet 2025-08-04 11:44:39 +02:00 committed by GitHub
commit 8a48732966
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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 ];
}
} );