diff --git a/changelog/fix-6952-fix-phonenumberinput b/changelog/fix-6952-fix-phonenumberinput new file mode 100644 index 00000000000..697a2ddf421 --- /dev/null +++ b/changelog/fix-6952-fix-phonenumberinput @@ -0,0 +1,4 @@ +Significance: patch +Type: fix + +Fix phone number input widget on checkout page diff --git a/client/settings/phone-input/index.tsx b/client/settings/phone-input/index.tsx index 69f9138d6a6..75c1442d713 100644 --- a/client/settings/phone-input/index.tsx +++ b/client/settings/phone-input/index.tsx @@ -75,16 +75,18 @@ const PhoneNumberInput = ( { onlyCountries: [], }; - const accountCountry = wcpaySettings?.accountStatus?.country ?? ''; - - // Special case for Japan: Only Japanese phone numbers are accepted by Stripe - if ( accountCountry === 'JP' ) { - phoneCountries = { - initialCountry: 'JP', - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - onlyCountries: [ 'JP' ], - }; + //if in admin panel + if ( 'undefined' !== typeof wcpaySettings ) { + const accountCountry = wcpaySettings?.accountStatus?.country ?? ''; + // Special case for Japan: Only Japanese phone numbers are accepted by Stripe + if ( accountCountry === 'JP' ) { + phoneCountries = { + initialCountry: 'JP', + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + onlyCountries: [ 'JP' ], + }; + } } if ( currentRef ) {