From 62c6c56dd703b66c6ae36720465fee9b22276b5c Mon Sep 17 00:00:00 2001 From: Alfredo Sumaran Date: Mon, 28 Oct 2024 17:00:08 -0500 Subject: [PATCH] Remove the condition that enables optimization when sending all country codes --- ...ayments-express-checkout-button-handler.php | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/includes/express-checkout/class-wc-payments-express-checkout-button-handler.php b/includes/express-checkout/class-wc-payments-express-checkout-button-handler.php index f43a0b131f6..d024c3ba611 100644 --- a/includes/express-checkout/class-wc-payments-express-checkout-button-handler.php +++ b/includes/express-checkout/class-wc-payments-express-checkout-button-handler.php @@ -240,11 +240,12 @@ public function scripts() { 'pay_for_order' => wp_create_nonce( 'pay_for_order' ), ], 'checkout' => [ - 'currency_code' => strtolower( get_woocommerce_currency() ), - 'country_code' => substr( get_option( 'woocommerce_default_country' ), 0, 2 ), - 'needs_shipping' => WC()->cart->needs_shipping(), + 'currency_code' => strtolower( get_woocommerce_currency() ), + 'country_code' => substr( get_option( 'woocommerce_default_country' ), 0, 2 ), + 'needs_shipping' => WC()->cart->needs_shipping(), // Defaults to 'required' to match how core initializes this option. - 'needs_payer_phone' => 'required' === get_option( 'woocommerce_checkout_phone_field', 'required' ), + 'needs_payer_phone' => 'required' === get_option( 'woocommerce_checkout_phone_field', 'required' ), + 'allowed_shipping_countries' => array_keys( WC()->countries->get_shipping_countries() ?? [] ), ], 'button' => $this->get_button_settings(), 'login_confirmation' => $this->get_login_confirmation_settings(), @@ -257,15 +258,6 @@ public function scripts() { 'is_checkout_page' => $this->express_checkout_helper->is_checkout(), ]; - // No need to send a list of countries if the store: - // 1. ships to all countries. Regardless of whom it sells to. - $ship_to_all = get_option( 'woocommerce_ship_to_countries' ) === 'all'; - // 2. ships to all countries it sells to and store sells to all countries. - $ship_to_all_and_selling_to_all = get_option( 'woocommerce_allowed_countries' ) === 'all' && empty( get_option( 'woocommerce_ship_to_countries' ) ); - if ( ! $ship_to_all && ! $ship_to_all_and_selling_to_all ) { - $payment_request_params['checkout']['allowed_shipping_countries'] = array_keys( WC()->countries->get_shipping_countries() ?? [] ); - } - WC_Payments::register_script_with_dependencies( 'WCPAY_EXPRESS_CHECKOUT_ECE', 'dist/express-checkout', [ 'jquery', 'stripe' ] ); WC_Payments_Utils::enqueue_style(