mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-30 05:00:51 +08:00
Add optional chaining to address properties
This commit is contained in:
parent
a8dfe57165
commit
0385aad301
1 changed files with 2 additions and 2 deletions
|
@ -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 ];
|
||||
}
|
||||
} );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue