Commit 4b76d7899ce for woocommerce

commit 4b76d7899ce5c7dc2f44f42de8e07b0d04c003c6
Author: Albert Juhé Lluveras <contact@albertjuhe.com>
Date:   Fri Dec 4 19:02:58 2026 +0100

    Add to Cart + Options: add aria-disabled to Add to Cart button when it looks disabled (#71804)

    * Add to Cart + Options: add aria-disabled to Add to Cart button when it looks disabled

    * Add changelog file

    * Update tests

    * Add test that makes sure aria-disabled is aligned with disabled class

diff --git a/plugins/woocommerce/changelog/fix-71747-add-to-cart-with-options-aria-disbled-button b/plugins/woocommerce/changelog/fix-71747-add-to-cart-with-options-aria-disbled-button
new file mode 100644
index 00000000000..21855834fa6
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-71747-add-to-cart-with-options-aria-disbled-button
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Add to Cart + Options: add aria-disabled to Add to Cart button when it looks disabled
diff --git a/plugins/woocommerce/src/Blocks/BlockTypes/ProductButton.php b/plugins/woocommerce/src/Blocks/BlockTypes/ProductButton.php
index de4edc6ee77..b215bbb8f1a 100644
--- a/plugins/woocommerce/src/Blocks/BlockTypes/ProductButton.php
+++ b/plugins/woocommerce/src/Blocks/BlockTypes/ProductButton.php
@@ -269,6 +269,7 @@ class ProductButton extends AbstractBlock {

 		$button_directives = $is_descendant_of_add_to_cart_form ?
 			'data-wp-class--disabled="woocommerce/add-to-cart-with-options::!state.isFormValid"
+			data-wp-bind--aria-disabled="woocommerce/add-to-cart-with-options::!state.isFormValid"
 			data-wp-bind--hidden="woocommerce/add-to-cart-with-options::!state.allowsAddingToCart"
 			data-wp-on--click="actions.handlePressedState"' :
 			'data-wp-on--click="actions.addCartItem"';
diff --git a/plugins/woocommerce/tests/e2e/tests/blocks/add-to-cart-with-options/add-to-cart-with-options.block_theme.spec.ts b/plugins/woocommerce/tests/e2e/tests/blocks/add-to-cart-with-options/add-to-cart-with-options.block_theme.spec.ts
index 04edcb6b2df..4a3771f69d2 100644
--- a/plugins/woocommerce/tests/e2e/tests/blocks/add-to-cart-with-options/add-to-cart-with-options.block_theme.spec.ts
+++ b/plugins/woocommerce/tests/e2e/tests/blocks/add-to-cart-with-options/add-to-cart-with-options.block_theme.spec.ts
@@ -284,7 +284,9 @@ test.describe( 'Add to Cart + Options Block', () => {
 		} );

 		await test.step( 'displays an error when attributes are not selected', async () => {
-			await addToCartButton.click();
+			// Playwright skips clicking an aria-disabled control unless forced.
+			// eslint-disable-next-line playwright/no-force-option
+			await addToCartButton.click( { force: true } );

 			const notice = addToCartBlock.getByRole( 'alert' );
 			await expect( notice ).toHaveText(
@@ -305,7 +307,8 @@ test.describe( 'Add to Cart + Options Block', () => {
 			await notice.evaluate( ( element ) =>
 				element.setAttribute( 'data-test-first-submit', '' )
 			);
-			await addToCartButton.click();
+			// eslint-disable-next-line playwright/no-force-option
+			await addToCartButton.click( { force: true } );
 			await expect(
 				addToCartBlock.locator(
 					'[role="alert"]:not([data-test-first-submit])'
@@ -369,6 +372,10 @@ test.describe( 'Add to Cart + Options Block', () => {
 			await expect( page.getByText( '100 in stock' ) ).toBeVisible();
 			await expect( page.getByText( 'SKU: woo-hoodie' ) ).toBeVisible();
 			await expect( addToCartButton ).toHaveClass( /\bdisabled\b/ );
+			await expect( addToCartButton ).toHaveAttribute(
+				'aria-disabled',
+				'true'
+			);
 			await expect(
 				additionalInfoPanel.getByText( '1.5 lbs' )
 			).toBeVisible();
@@ -388,6 +395,10 @@ test.describe( 'Add to Cart + Options Block', () => {
 			// Instead, we check directly for the "disabled" class, which grays
 			// out the button.
 			await expect( addToCartButton ).not.toHaveClass( /\bdisabled\b/ );
+			await expect( addToCartButton ).not.toHaveAttribute(
+				'aria-disabled',
+				'true'
+			);

 			await addToCartButton.click();

@@ -609,7 +620,8 @@ test.describe( 'Add to Cart + Options Block', () => {
 			// There is the chance the button might be clicked before the iAPI
 			// stores have been loaded.
 			await expect( async () => {
-				await addToCartButton.click();
+				// eslint-disable-next-line playwright/no-force-option
+				await addToCartButton.click( { force: true } );
 				await expect( addToCartBlock.getByRole( 'alert' ) ).toHaveText(
 					'Please select some products to add to the cart.'
 				);
@@ -1402,7 +1414,8 @@ test.describe( 'Add to Cart + Options Block', () => {

 		await firstBlock
 			.getByRole( 'button', { name: 'Add to cart', exact: true } )
-			.click();
+			// eslint-disable-next-line playwright/no-force-option
+			.click( { force: true } );
 		await expect( firstBlock.getByRole( 'alert' ) ).toHaveText(
 			'Please select product attributes before adding to cart.'
 		);