Commit 83b641cdc4 for woocommerce
commit 83b641cdc44af3259680acc6788c1acf933628ac
Author: Devanshi Joshi <86941664+devanshijoshi9@users.noreply.github.com>
Date: Wed Dec 31 19:51:03 2025 +0530
Hide the WooCommerce Accordion blocks from the inserter in WP 6.9 and later (#62626)
* Fix: Add conditional checks to prevent the WooCommerce Accordion block from appearing in the block inserter on WordPress 6.9 and later
* Fix: Add since annotation in new functions and add WP version check in accordion inner blocks as well
* Fix: Use Js based approach to hide accordion in inserter when WP version is 6.9 or more
* Fix: Hide only the accordion group block and keep the inner blocks as they are
* Resolved: Failed unit tests
* Fix: Remove unnecessary isWpVersion import on inner accordion blocks
diff --git a/plugins/woocommerce/changelog/fix-62119 b/plugins/woocommerce/changelog/fix-62119
new file mode 100644
index 0000000000..d59db23a74
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-62119
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Add conditional checks to prevent the WooCommerce Accordion block from appearing in the block inserter on WordPress 6.9 and later.
\ No newline at end of file
diff --git a/plugins/woocommerce/client/blocks/assets/js/blocks/accordion/accordion-group/index.js b/plugins/woocommerce/client/blocks/assets/js/blocks/accordion/accordion-group/index.js
index 4a3ae54f46..78312c898c 100644
--- a/plugins/woocommerce/client/blocks/assets/js/blocks/accordion/accordion-group/index.js
+++ b/plugins/woocommerce/client/blocks/assets/js/blocks/accordion/accordion-group/index.js
@@ -3,6 +3,7 @@
*/
import { SVG, Path } from '@wordpress/components';
import { registerBlockType } from '@wordpress/blocks';
+import { isWpVersion } from '@woocommerce/settings';
/**
* Internal dependencies
@@ -46,6 +47,11 @@ export const settings = {
example: {},
edit,
save,
+ supports: {
+ // We only want to show the block in the inserter in WP 6.8 or lower,
+ // because WP 6.9 comes with its own accordion block.
+ inserter: isWpVersion( '6.9', '<' ),
+ },
};
registerBlockType( metadata, settings );
diff --git a/plugins/woocommerce/client/blocks/assets/js/blocks/product-details/test/block.tsx b/plugins/woocommerce/client/blocks/assets/js/blocks/product-details/test/block.tsx
index 541ff1fa5a..b1c27c78b6 100644
--- a/plugins/woocommerce/client/blocks/assets/js/blocks/product-details/test/block.tsx
+++ b/plugins/woocommerce/client/blocks/assets/js/blocks/product-details/test/block.tsx
@@ -54,6 +54,11 @@ jest.mock( '@wordpress/data', () => ( {
useSelect: jest.fn(),
} ) );
+jest.mock( '@woocommerce/settings', () => ( {
+ ...jest.requireActual( '@woocommerce/settings' ),
+ isWpVersion: jest.fn().mockReturnValue( false ),
+} ) );
+
describe( 'Product Details block', () => {
describe( 'Single Product block', () => {
const server = setupServer(