Skip to content

Commit

Permalink
Remove the condition that enables optimization when sending all count…
Browse files Browse the repository at this point in the history
…ry codes
  • Loading branch information
asumaran committed Oct 28, 2024
1 parent 606ec49 commit 62c6c56
Showing 1 changed file with 5 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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(
Expand Down

0 comments on commit 62c6c56

Please sign in to comment.