Commit c96d81c14e1 for woocommerce

commit c96d81c14e1b30e5409aa417f1e554815cf85eef
Author: Cem Ünalan <raicem@users.noreply.github.com>
Date:   Tue Mar 17 11:14:21 2026 +0300

    Add new message variant to expired subscription notice. (#63636)

    * Add new message variant to has_active_usable_product_subscription

    * In-App Marketplace: update button copy

    * Fix Yoda condition in PluginsHelper

    * Fix PHPCS alignment in PluginsHelper notices

    * Fix notice array indentation in PluginsHelper

    ---------

    Co-authored-by: Herman <KokkieH@users.noreply.github.com>

diff --git a/plugins/woocommerce/src/Admin/PluginsHelper.php b/plugins/woocommerce/src/Admin/PluginsHelper.php
index 117e564ffe4..5b389ba640b 100644
--- a/plugins/woocommerce/src/Admin/PluginsHelper.php
+++ b/plugins/woocommerce/src/Admin/PluginsHelper.php
@@ -818,7 +818,18 @@ class PluginsHelper {
 			)
 		);

-		$message_key      = $has_multiple_subs_for_product ? 'multiple_manage' : 'single_manage';
+		$message_key = $has_multiple_subs_for_product ? 'multiple_manage' : 'single_manage';
+
+		/**
+		 * Even if there are multiple subscriptions for this product, if the store is covered by an active subscription,
+		 * show the 'site covered' message instead of the 'manage' message.
+		 */
+		if ( 'expired' === $type && $has_multiple_subs_for_product ) {
+			if ( self::has_active_usable_product_subscription( $product_id, $all_subs ) ) {
+				$message_key = 'multiple_manage_site_covered';
+			}
+		}
+
 		$renew_string     = __( 'Renew', 'woocommerce' );
 		$subscribe_string = __( 'Subscribe', 'woocommerce' );
 		if ( isset( $subscription['product_regular_price'] ) ) {
@@ -866,6 +877,39 @@ class PluginsHelper {
 		);
 	}

+	/**
+	 * Check whether the current store has an active usable subscription for a product.
+	 *
+	 * @param int   $product_id Product id.
+	 * @param array $subscriptions Subscription list data.
+	 * @return bool
+	 */
+	private static function has_active_usable_product_subscription( int $product_id, array $subscriptions ): bool {
+		$auth    = \WC_Helper_Options::get( 'auth' );
+		$site_id = isset( $auth['site_id'] ) ? absint( $auth['site_id'] ) : 0;
+
+		if ( 0 === $site_id ) {
+			return false;
+		}
+
+		foreach ( $subscriptions as $subscription ) {
+			if ( absint( $subscription['product_id'] ?? 0 ) !== $product_id ) {
+				continue;
+			}
+
+			$connections = isset( $subscription['connections'] ) && is_array( $subscription['connections'] ) ? $subscription['connections'] : array();
+			if ( ! in_array( $site_id, $connections, true ) ) {
+				continue;
+			}
+
+			if ( empty( $subscription['expired'] ) || ! empty( $subscription['lifetime'] ) ) {
+				return true;
+			}
+		}
+
+		return false;
+	}
+
 	/**
 	 * Get formatted notice information for expiring subscription.
 	 *
@@ -990,15 +1034,18 @@ class PluginsHelper {
 			$total_expired_subscriptions,
 			array(
 				/* translators: 1) product name 3) URL to My Subscriptions page 4) Renew product price string */
-				'single_manage'           => __( 'Your subscription for <strong>%1$s</strong> expired. <a href="%3$s">%4$s</a> to continue receiving updates and streamlined support.', 'woocommerce' ),
+				'single_manage'                => __( 'Your subscription for <strong>%1$s</strong> expired. <a href="%3$s">%4$s</a> to continue receiving updates and streamlined support.', 'woocommerce' ),
 				/* translators: 1) product name 3) URL to My Subscriptions page 4) Renew product price string */
-				'multiple_manage'         => __( 'One of your subscriptions for <strong>%1$s</strong> has expired. <a href="%3$s">%4$s</a> to continue receiving updates and streamlined support.', 'woocommerce' ),
+				'multiple_manage'              => __( 'One of your subscriptions for <strong>%1$s</strong> has expired. <a href="%3$s">%4$s</a> to continue receiving updates and streamlined support.', 'woocommerce' ),
+				/* translators: 1) product name 3) URL to My Subscriptions page */
+				'multiple_manage_site_covered' => __( 'One of your subscriptions for <strong>%1$s</strong> has expired. This store is still covered by another active subscription.', 'woocommerce' ),
 				/* translators: 1) total expired subscriptions 2) URL to My Subscriptions page */
-				'different_subscriptions' => __( 'You have <strong>%1$s Woo extension subscriptions</strong> that expired. <a href="%2$s">Renew</a> to continue receiving updates and streamlined support.', 'woocommerce' ),
+				'different_subscriptions'      => __( 'You have <strong>%1$s Woo extension subscriptions</strong> that expired. <a href="%2$s">Renew</a> to continue receiving updates and streamlined support.', 'woocommerce' ),
 			),
 			'expired',
 		);

+		$button_text = __( 'Renew', 'woocommerce' );
 		$button_link = add_query_arg(
 			array(
 				'add-to-cart'  => $notice_data['product_id'],
@@ -1008,7 +1055,18 @@ class PluginsHelper {
 			self::WOO_CART_PAGE_URL
 		);

-		if ( in_array( $notice_data['type'], array( 'single_manage', 'multiple_manage' ), true ) ) {
+		if ( 'multiple_manage_site_covered' === $notice_data['type'] ) {
+			$button_text = __( 'Review subscriptions', 'woocommerce' );
+			$button_link = add_query_arg(
+				array(
+					'product_id'   => $notice_data['product_id'],
+					'type'         => 'expired',
+					'utm_source'   => 'pu',
+					'utm_campaign' => $allowed_link ? 'pu_settings_screen_review_subscriptions' : 'pu_in_apps_screen_review_subscriptions',
+				),
+				self::WOO_SUBSCRIPTION_PAGE_URL
+			);
+		} elseif ( in_array( $notice_data['type'], array( 'single_manage', 'multiple_manage' ), true ) ) {
 			$button_link = add_query_arg(
 				array(
 					'add-to-cart' => $notice_data['product_id'],
@@ -1019,7 +1077,7 @@ class PluginsHelper {

 		return array(
 			'description' => $allowed_link ? $notice_data['parsed_message'] : preg_replace( '#<a.*?>(.*?)</a>#i', '\1', $notice_data['parsed_message'] ),
-			'button_text' => __( 'Renew', 'woocommerce' ),
+			'button_text' => $button_text,
 			'button_link' => $button_link,
 		);
 	}