Commit 7e715396fc4 for woocommerce

commit 7e715396fc4cf1f22197d09ff78cd9ac6e687b02
Author: Vladimir Reznichenko <kalessil@gmail.com>
Date:   Thu Apr 30 08:09:50 2026 +0200

    [dev] Reduce variability in payment gateway is_available implementations. (#64386)

    Consistently use 'yes' === $gateway->enabled in bundled payment gateway is_available implementations to exit early when the gateway is disabled.

diff --git a/plugins/woocommerce/changelog/performance-available-gateways-population b/plugins/woocommerce/changelog/performance-available-gateways-population
new file mode 100644
index 00000000000..f584f29d4fb
--- /dev/null
+++ b/plugins/woocommerce/changelog/performance-available-gateways-population
@@ -0,0 +1,4 @@
+Significance: minor
+Type: dev
+
+Reduce variability in payment gateway is_available implementations.
diff --git a/plugins/woocommerce/includes/abstracts/abstract-wc-payment-gateway.php b/plugins/woocommerce/includes/abstracts/abstract-wc-payment-gateway.php
index d1d23508ec0..5ed2e4394e2 100644
--- a/plugins/woocommerce/includes/abstracts/abstract-wc-payment-gateway.php
+++ b/plugins/woocommerce/includes/abstracts/abstract-wc-payment-gateway.php
@@ -344,14 +344,13 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
 	 * @return bool
 	 */
 	public function is_available() {
-		if ( 'yes' !== $this->enabled ) {
-			return false;
-		}
-
-		$is_available = true;
+		$is_available = 'yes' === $this->enabled;

-		if ( WC()->cart && 0 < $this->get_order_total() && 0 < $this->max_amount && $this->max_amount < $this->get_order_total() ) {
-			$is_available = false;
+		if ( $is_available && WC()->cart ) {
+			$order_total = $this->get_order_total();
+			if ( 0 < $order_total && 0 < $this->max_amount && $order_total > $this->max_amount ) {
+				$is_available = false;
+			}
 		}

 		return $is_available;
diff --git a/plugins/woocommerce/includes/class-wc-payment-gateways.php b/plugins/woocommerce/includes/class-wc-payment-gateways.php
index dede9b12a45..be1925ca5bb 100644
--- a/plugins/woocommerce/includes/class-wc-payment-gateways.php
+++ b/plugins/woocommerce/includes/class-wc-payment-gateways.php
@@ -25,7 +25,7 @@ class WC_Payment_Gateways {
 	/**
 	 * Payment gateway classes.
 	 *
-	 * @var array
+	 * @var WC_Payment_Gateway[]
 	 */
 	public $payment_gateways = array();

@@ -319,7 +319,7 @@ class WC_Payment_Gateways {
 	 * may try to rely on the existence of a WC session - a valid thing to do,
 	 * and cause fatal errors when the session is not available.
 	 *
-	 * @return array The available payment gateways.
+	 * @return WC_Payment_Gateway[] The available payment gateways.
 	 */
 	public function get_available_payment_gateways() {
 		$_available_gateways = array();
diff --git a/plugins/woocommerce/includes/gateways/paypal/class-wc-gateway-paypal.php b/plugins/woocommerce/includes/gateways/paypal/class-wc-gateway-paypal.php
index a31d8e5952f..ef31e0b581e 100644
--- a/plugins/woocommerce/includes/gateways/paypal/class-wc-gateway-paypal.php
+++ b/plugins/woocommerce/includes/gateways/paypal/class-wc-gateway-paypal.php
@@ -339,6 +339,10 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
 	 * @return bool
 	 */
 	public function is_available() {
+		if ( 'yes' !== $this->enabled ) {
+			return false;
+		}
+
 		// For Orders v2, require a valid email address to be set up in the gateway settings.
 		if ( $this->should_use_orders_v2() && $this->needs_setup() ) {
 			return false;