Commit a185f925d9a for woocommerce
commit a185f925d9a7cd814dea39e09188eaed2e1ed6de
Author: Chris Lilitsas <1105590+xristos3490@users.noreply.github.com>
Date: Fri Sep 18 12:57:04 2026 +0300
Fix Back in Stock sign-up form staying visible for in-stock variations (#68811)
* fix: hide back in stock form with hidden attribute, not a CSS class
* chore: keep BIS form template at 11.2.0 for backporting
diff --git a/plugins/woocommerce/changelog/wooplug-7615-bis-form-hidden-attribute b/plugins/woocommerce/changelog/wooplug-7615-bis-form-hidden-attribute
new file mode 100644
index 00000000000..3aa059fcee8
--- /dev/null
+++ b/plugins/woocommerce/changelog/wooplug-7615-bis-form-hidden-attribute
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Back in Stock: hide the sign-up form with the hidden attribute so it stays hidden for in-stock variations on themes that replace the WooCommerce stylesheet.
diff --git a/plugins/woocommerce/client/legacy/js/frontend/back-in-stock-form.js b/plugins/woocommerce/client/legacy/js/frontend/back-in-stock-form.js
index d2da8215d72..1dc76746ada 100644
--- a/plugins/woocommerce/client/legacy/js/frontend/back-in-stock-form.js
+++ b/plugins/woocommerce/client/legacy/js/frontend/back-in-stock-form.js
@@ -54,16 +54,16 @@
BISFormManager.prototype.onShowVariation = function( event, variation ) {
var form = event.data.bisForm;
if ( variation.is_in_stock && variation.is_purchasable ) {
- form.$formContainer.addClass( 'hidden' );
+ form.$formContainer.prop( 'hidden', true );
return;
}
if ( ! variation.variation_is_active || ! variation.variation_is_visible ) {
- form.$formContainer.addClass( 'hidden' );
+ form.$formContainer.prop( 'hidden', true );
return;
}
- form.$formContainer.removeClass( 'hidden' );
+ form.$formContainer.prop( 'hidden', false );
};
/**
@@ -74,7 +74,7 @@
BISFormManager.prototype.onAnnounceReset = function( event ) {
var form = event.data.bisForm;
form.$formProductInput.val( form.product_id ).trigger( 'change' );
- form.$formContainer.addClass( 'hidden' );
+ form.$formContainer.prop( 'hidden', true );
};
/**
diff --git a/plugins/woocommerce/templates/single-product/back-in-stock-form.php b/plugins/woocommerce/templates/single-product/back-in-stock-form.php
index c53f934ce9e..9b9e15fbc62 100644
--- a/plugins/woocommerce/templates/single-product/back-in-stock-form.php
+++ b/plugins/woocommerce/templates/single-product/back-in-stock-form.php
@@ -23,7 +23,7 @@ if ( ! defined( 'ABSPATH' ) ) {
}
?>
-<div class="wc_bis_form<?php echo $is_visible ? '' : ' hidden'; ?>" data-bis-product-id="<?php echo absint( $product_id ); ?>">
+<div class="wc_bis_form" data-bis-product-id="<?php echo absint( $product_id ); ?>" <?php echo $is_visible ? '' : 'hidden'; ?>>
<h3 id="wc_bis_form_heading_<?php echo absint( $product_id ); ?>">
<?php echo wp_kses_post( __( 'Want to be notified when this product is back in stock?', 'woocommerce' ) ); ?>
diff --git a/plugins/woocommerce/tests/e2e/tests/back-in-stock-notifications/variations.spec.ts b/plugins/woocommerce/tests/e2e/tests/back-in-stock-notifications/variations.spec.ts
index f3171ff0e92..302947efbf9 100644
--- a/plugins/woocommerce/tests/e2e/tests/back-in-stock-notifications/variations.spec.ts
+++ b/plugins/woocommerce/tests/e2e/tests/back-in-stock-notifications/variations.spec.ts
@@ -65,12 +65,7 @@ test.describe(
// Before a variation is picked the form is rendered but
// hidden, and still points at the parent product.
- //
- // Asserted on the `hidden` class rather than on visibility:
- // that class is the contract `back-in-stock-form.js` drives,
- // while whether it actually hides the form depends on the
- // theme's stylesheet.
- await expect( form ).toContainClass( 'hidden' );
+ await expect( form ).toBeHidden();
await expect( targetProduct ).toHaveValue(
String( variableProduct.id )
);
@@ -81,7 +76,7 @@ test.describe(
variableProduct.outOfStockVariation
);
- await expect( form ).not.toContainClass( 'hidden' );
+ await expect( form ).toBeVisible();
await expect(
form.getByRole( 'button', { name: /Notify me/i } )
).toBeVisible();
@@ -98,7 +93,7 @@ test.describe(
variableProduct.inStockVariation!
);
- await expect( form ).toContainClass( 'hidden' );
+ await expect( form ).toBeHidden();
} );
test( 'signing up for an out-of-stock variation confirms the variation by name', async ( {
diff --git a/plugins/woocommerce/tests/e2e/utils/back-in-stock-notifications.ts b/plugins/woocommerce/tests/e2e/utils/back-in-stock-notifications.ts
index ed51b89c658..852730c175f 100644
--- a/plugins/woocommerce/tests/e2e/utils/back-in-stock-notifications.ts
+++ b/plugins/woocommerce/tests/e2e/utils/back-in-stock-notifications.ts
@@ -422,10 +422,9 @@ export async function restockProduct(
* Locator for the PDP sign-up form wrapper.
*
* The wrapper is rendered whenever the product allows signups, and core's
- * `back-in-stock-form.js` toggles its `hidden` class from the `show_variation`
- * event — the class the variation specs assert on. A product whose parent opts
- * out of signups renders no wrapper at all, so that case is asserted on
- * presence instead.
+ * `back-in-stock-form.js` toggles its `hidden` attribute from the
+ * `show_variation` event. A product whose parent opts out of signups renders no
+ * wrapper at all, so that case is asserted on presence instead.
*
* @param {Page} page Playwright page on the product detail.
*/