Commit 87158f40ace for woocommerce

commit 87158f40ace6ece5036a9f76b254a6031ad50cc0
Author: iris-woocommerce[bot] <282076412+iris-woocommerce[bot]@users.noreply.github.com>
Date:   Mon Nov 30 15:51:49 2026 +0000

    Stock notifications: Remove the broken unsubscribe link from block back-in-stock emails (#71601)

diff --git a/plugins/woocommerce/changelog/fix-stock-notification-block-email-unsubscribe b/plugins/woocommerce/changelog/fix-stock-notification-block-email-unsubscribe
new file mode 100644
index 00000000000..764a16e6822
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-stock-notification-block-email-unsubscribe
@@ -0,0 +1,4 @@
+Significance: patch
+Type: dev
+Comment: Fix the guest footer in the block back-in-stock email; the bug never shipped in a release.
+
diff --git a/plugins/woocommerce/templates/emails/block/general-block-content-for-stock-notification-emails.php b/plugins/woocommerce/templates/emails/block/general-block-content-for-stock-notification-emails.php
index d306dca8eed..f21e355bcdb 100644
--- a/plugins/woocommerce/templates/emails/block/general-block-content-for-stock-notification-emails.php
+++ b/plugins/woocommerce/templates/emails/block/general-block-content-for-stock-notification-emails.php
@@ -85,6 +85,13 @@ if ( isset( $verification_link ) ) {
 		$account_link_tag = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $account_link ), esc_html_x( 'click here', 'account management cta for stock notifications for existing customers', 'woocommerce' ) );
 		// translators: %s: "click here" link to the customer's account.
 		echo wp_kses_post( sprintf( __( 'To manage your notifications, %s to log in to your account.', 'woocommerce' ), $account_link_tag ) );
+	} elseif ( 'customer_stock_notification' === $email->id ) {
+		// The back-in-stock email ends the sign-up, so guests get no unsubscribe link.
+		if ( $account_link ) {
+			esc_html_e( 'Create an account or log in with this email address to manage your notifications.', 'woocommerce' );
+			echo ' ';
+			printf( '<a href="%1$s">%2$s</a>', esc_url( $account_link ), esc_html__( 'Manage notifications', 'woocommerce' ) );
+		}
 	} else {
 		$unsubscribe_link_tag = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $unsubscribe_link ), esc_html_x( 'click here', 'unsubscribe cta for stock notifications for guests', 'woocommerce' ) );
 		// translators: %s: "click here" unsubscribe link.
diff --git a/plugins/woocommerce/tests/php/src/Internal/StockNotifications/Emails/StockNotificationBlockEmailsTests.php b/plugins/woocommerce/tests/php/src/Internal/StockNotifications/Emails/StockNotificationBlockEmailsTests.php
index 647f9de3760..43447e1a0eb 100644
--- a/plugins/woocommerce/tests/php/src/Internal/StockNotifications/Emails/StockNotificationBlockEmailsTests.php
+++ b/plugins/woocommerce/tests/php/src/Internal/StockNotifications/Emails/StockNotificationBlockEmailsTests.php
@@ -119,6 +119,36 @@ class StockNotificationBlockEmailsTests extends \WC_Unit_Test_Case {
 		$this->assertStringNotContainsString( 'email_link_action=unsubscribe', $content );
 	}

+	/**
+	 * @testdox A guest gets no unsubscribe link in the back-in-stock email, and a link to manage notifications only when registration is on.
+	 * @testWith ["yes", true]
+	 *           ["no", false]
+	 *
+	 * @param string $registration  Value of the My Account registration option.
+	 * @param bool   $expect_manage Whether the email should link to manage notifications.
+	 */
+	public function test_guest_back_in_stock_email_has_no_unsubscribe_link( string $registration, bool $expect_manage ): void {
+		$this->skip_if_unsupported_environment();
+
+		update_option( 'woocommerce_enable_myaccount_registration', $registration );
+		update_option( MyAccountEndpoint::ENDPOINT_OPTION, 'stock-notifications' );
+		new MyAccountEndpoint();
+		WC()->query->init_query_vars();
+
+		$email = new CustomerStockNotificationEmail();
+		$email->prepare_email( $this->create_notification() );
+
+		$content = $email->get_content();
+
+		$this->assertStringNotContainsString( 'To stop receiving these messages,', $content );
+		$this->assertStringNotContainsString( 'email_link_action=unsubscribe', $content );
+		if ( $expect_manage ) {
+			$this->assertStringContainsString( 'Manage notifications', $content );
+		} else {
+			$this->assertStringNotContainsString( 'Manage notifications', $content );
+		}
+	}
+
 	/**
 	 * Create a pending guest notification for a saved product named Blue Mug.
 	 *
@@ -157,7 +187,7 @@ class StockNotificationBlockEmailsTests extends \WC_Unit_Test_Case {
 			'back in stock'      => array(
 				CustomerStockNotificationEmail::class,
 				'It\'s back in stock!',
-				array( 'Shop Now', 'email_link_action=unsubscribe', 'To stop receiving these messages,' ),
+				array( 'Shop Now' ),
 			),
 			'confirm sign-up'    => array(
 				CustomerStockNotificationVerifyEmail::class,