Commit aa23b52613 for woocommerce

commit aa23b52613a13860aafcba55be3a5dfb5bfec13d
Author: Jan Lysý <lysyjan@users.noreply.github.com>
Date:   Tue Feb 10 11:41:58 2026 +0100

    Remove heading from Product Collection block in email editor (#63180)

    * Remove heading block from Product Collection in email editor

    * Add changelog for removing heading from product/collection in email editor

diff --git a/plugins/woocommerce/changelog/stomail-7792-inserting-handpicked-products-block-inserts-recommended b/plugins/woocommerce/changelog/stomail-7792-inserting-handpicked-products-block-inserts-recommended
new file mode 100644
index 0000000000..555dc5f0fd
--- /dev/null
+++ b/plugins/woocommerce/changelog/stomail-7792-inserting-handpicked-products-block-inserts-recommended
@@ -0,0 +1,4 @@
+Significance: patch
+Type: update
+
+Remove heading block from Product Collection when used in the email editor.
diff --git a/plugins/woocommerce/client/blocks/assets/js/blocks/product-collection/edit/inspector-controls/index.tsx b/plugins/woocommerce/client/blocks/assets/js/blocks/product-collection/edit/inspector-controls/index.tsx
index ec8625823f..1d8376539a 100644
--- a/plugins/woocommerce/client/blocks/assets/js/blocks/product-collection/edit/inspector-controls/index.tsx
+++ b/plugins/woocommerce/client/blocks/assets/js/blocks/product-collection/edit/inspector-controls/index.tsx
@@ -34,6 +34,7 @@ import {
 import useCarouselLayoutAdjustments from './use-carousel-layout-adjustments';
 import useEmailPaginationAdjustments from './use-email-pagination-adjustments';
 import useEmailColumnAdjustments from './use-email-column-adjustments';
+import useEmailHeadingAdjustments from './use-email-heading-adjustments';
 import DefaultQueryOrderByControl from './order-by-control/default-query-order-by-control';
 import CustomQueryOrderByControl from './order-by-control/custom-query-order-by-control';
 import OnSaleControl from './on-sale-control';
@@ -89,6 +90,7 @@ const ProductCollectionInspectorControls = (
 	useCarouselLayoutAdjustments( clientId, attributes );
 	useEmailPaginationAdjustments( clientId, attributes );
 	useEmailColumnAdjustments( attributes, setAttributes );
+	useEmailHeadingAdjustments( clientId );

 	const showCustomQueryControls = inherit === false;
 	const showInheritQueryControl =
diff --git a/plugins/woocommerce/client/blocks/assets/js/blocks/product-collection/edit/inspector-controls/use-email-heading-adjustments.ts b/plugins/woocommerce/client/blocks/assets/js/blocks/product-collection/edit/inspector-controls/use-email-heading-adjustments.ts
new file mode 100644
index 0000000000..b0f2531bce
--- /dev/null
+++ b/plugins/woocommerce/client/blocks/assets/js/blocks/product-collection/edit/inspector-controls/use-email-heading-adjustments.ts
@@ -0,0 +1,64 @@
+/**
+ * External dependencies
+ */
+import { useIsEmailEditor } from '@woocommerce/email-editor';
+import { useEffect } from '@wordpress/element';
+import { useSelect, useDispatch } from '@wordpress/data';
+import { store as blockEditorStore } from '@wordpress/block-editor';
+
+interface Block {
+	clientId: string;
+	name: string;
+	innerBlocks: Block[];
+}
+
+/**
+ * Custom hook to remove heading blocks when in the email editor.
+ * Headings are included in collection inner block templates but are
+ * not needed in the email context.
+ *
+ * @param {string} clientId - The client ID of the product collection block.
+ */
+const useEmailHeadingAdjustments = ( clientId: string ) => {
+	const actions = useDispatch( blockEditorStore );
+	const isEmail = useIsEmailEditor();
+
+	const { productCollectionBlock } = useSelect(
+		( select ) => ( {
+			productCollectionBlock:
+				// @ts-expect-error getBlock is not typed.
+				select( blockEditorStore ).getBlock( clientId ) as Block | null,
+		} ),
+		[ clientId ]
+	);
+
+	useEffect( () => {
+		if ( ! clientId || ! productCollectionBlock || ! isEmail ) {
+			return;
+		}
+
+		if (
+			! productCollectionBlock.innerBlocks ||
+			! Array.isArray( productCollectionBlock.innerBlocks )
+		) {
+			return;
+		}
+
+		const headingBlocks = productCollectionBlock.innerBlocks.filter(
+			( block: Block ) => block && block.name === 'core/heading'
+		);
+
+		headingBlocks.forEach( ( headingBlock: Block ) => {
+			if ( headingBlock && headingBlock.clientId ) {
+				try {
+					actions.removeBlock( headingBlock.clientId );
+				} catch ( error ) {
+					// Silently handle cases where block might already be removed
+					// or in an inconsistent state during block editor operations
+				}
+			}
+		} );
+	}, [ clientId, actions, productCollectionBlock, isEmail ] );
+};
+
+export default useEmailHeadingAdjustments;