Commit 247dad2606d for woocommerce

commit 247dad2606df228f2d4b14c7a015059f3029b0e5
Author: Chris Lilitsas <1105590+xristos3490@users.noreply.github.com>
Date:   Wed Sep 16 15:56:23 2026 +0300

    Fix: Use wc_get_account_endpoint_url to keep endpoint-url filter on stock notification login link (#68473)

    * fix: keep endpoint-url filter on stock notifications login link

    * test: assert the stock notifications login link href, not just its landing

diff --git a/plugins/woocommerce/changelog/fix-stock-notifications-login-link b/plugins/woocommerce/changelog/fix-stock-notifications-login-link
new file mode 100644
index 00000000000..dd4f7a8c0e2
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-stock-notifications-login-link
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Fix the "log in" link in the stock notifications account-required notice pointing to /my-account/my-account/ instead of the My Account page.
diff --git a/plugins/woocommerce/src/Internal/StockNotifications/Frontend/ProductPageIntegration.php b/plugins/woocommerce/src/Internal/StockNotifications/Frontend/ProductPageIntegration.php
index b769b61da48..4ff262da232 100644
--- a/plugins/woocommerce/src/Internal/StockNotifications/Frontend/ProductPageIntegration.php
+++ b/plugins/woocommerce/src/Internal/StockNotifications/Frontend/ProductPageIntegration.php
@@ -178,7 +178,7 @@ class ProductPageIntegration {
 		}

 		$text = __( 'Please {login_link} to sign up for stock notifications.', 'woocommerce' );
-		$text = str_replace( '{login_link}', '<a href="' . esc_url( wc_get_account_endpoint_url( 'my-account' ) ) . '">' . _x( 'log in', 'back in stock form', 'woocommerce' ) . '</a>', $text );
+		$text = str_replace( '{login_link}', '<a href="' . esc_url( wc_get_account_endpoint_url( 'dashboard' ) ) . '">' . _x( 'log in', 'back in stock form', 'woocommerce' ) . '</a>', $text );
 		wc_print_notice( $text, 'notice' );
 	}

diff --git a/plugins/woocommerce/tests/e2e/tests/back-in-stock-notifications/signing-up.spec.ts b/plugins/woocommerce/tests/e2e/tests/back-in-stock-notifications/signing-up.spec.ts
index 06b8ca5737d..e8ae7b5751a 100644
--- a/plugins/woocommerce/tests/e2e/tests/back-in-stock-notifications/signing-up.spec.ts
+++ b/plugins/woocommerce/tests/e2e/tests/back-in-stock-notifications/signing-up.spec.ts
@@ -20,6 +20,13 @@ import {
 import { clearFilters, setFilterValue } from '../../utils/filters';
 import { setOption } from '../../utils/options';

+/**
+ * Drop a trailing slash so URL paths compare regardless of permalink trailing.
+ *
+ * @param path URL path to normalize.
+ */
+const trimSlash = ( path: string ) => path.replace( /\/$/, '' );
+
 test.describe(
 	'Back in Stock Notifications — signing up',
 	{ tag: [ tags.SKIP_ON_EXTERNAL_ENV ] },
@@ -341,22 +348,29 @@ test.describe(
 			test( 'logging in from the prompt lets the customer sign up', async ( {
 				page,
 				product,
+				baseURL,
 			} ) => {
 				await page.goto( product.permalink );

-				await page.getByRole( 'link', { name: 'log in' } ).click();
+				const accountPath = trimSlash(
+					new URL( 'my-account/', baseURL ).pathname
+				);
+				const loginLink = page.getByRole( 'link', { name: 'log in' } );
+
+				// The link has to point at the account page itself. A nested
+				// endpoint such as /my-account/my-account/ still lands there
+				// via WordPress' 404 URL guessing, so only the href tells a
+				// working link apart from a broken one.
+				const href = await loginLink.getAttribute( 'href' );
+				expect( trimSlash( new URL( href!, baseURL ).pathname ) ).toBe(
+					accountPath
+				);

-				// The prompt's link points at a non-existent endpoint, so
-				// WordPress guesses the 404 back to the account page. Assert
-				// the landing, or a lost guess would only show up as a
-				// timeout on the login form below.
-				await expect( page ).toHaveURL( ( url ) => {
-					const path = url.pathname.endsWith( '/' )
-						? url.pathname.slice( 0, -1 )
-						: url.pathname;
+				await loginLink.click();

-					return path.endsWith( '/my-account' );
-				} );
+				await expect( page ).toHaveURL(
+					( url ) => trimSlash( url.pathname ) === accountPath
+				);

 				await page.locator( '#username' ).fill( customer.username );
 				await page.locator( '#password' ).fill( customer.password );