From 3ee36839578b286dc90f2947f4785f645a60124d Mon Sep 17 00:00:00 2001 From: Guilherme Pressutto Date: Tue, 10 Dec 2024 09:52:05 -0300 Subject: [PATCH] Fixed UPE country detection in Checkout for non-logged in users --- changelog/fix-upe-country-selection | 4 ++++ client/checkout/utils/upe.js | 3 +-- 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 changelog/fix-upe-country-selection diff --git a/changelog/fix-upe-country-selection b/changelog/fix-upe-country-selection new file mode 100644 index 00000000000..478ffa1cfcd --- /dev/null +++ b/changelog/fix-upe-country-selection @@ -0,0 +1,4 @@ +Significance: patch +Type: fix + +Fixed UPE country detection in Checkout for non-logged in users diff --git a/client/checkout/utils/upe.js b/client/checkout/utils/upe.js index 500314b9f5b..af8e0427c04 100644 --- a/client/checkout/utils/upe.js +++ b/client/checkout/utils/upe.js @@ -375,10 +375,9 @@ export const togglePaymentMethodForCountry = ( upeElement ) => { billingInput = document.querySelector( '#billing_country' ); } - /* global wcpayCustomerData */ // in the case of "pay for order", there is no "billing country" input, so we need to rely on backend data. const billingCountry = - billingInput?.value || wcpayCustomerData?.billing_country || ''; + billingInput?.value || window?.wcpayCustomerData?.billing_country || ''; const upeContainer = upeElement?.closest( '.wc_payment_method' ); if ( supportedCountries.includes( billingCountry ) ) {