Automattic\WooCommerce\Blocks\BlockTypes

RelatedProducts::is_related_products_blockprivateWC 1.0

Determines whether the block is a related products block.

Method of the class: RelatedProducts{}

No Hooks.

Returns

true|false. Whether the block is a related products block.

Usage

// private - for code of main (parent) class only
$result = $this->is_related_products_block( $parsed_block, $rendered_block );
$parsed_block(array) (required)
The parsed block.
$rendered_block(array)
The rendered block.
Default: null

RelatedProducts::is_related_products_block() code WC 10.6.2

private function is_related_products_block( $parsed_block, $rendered_block = null ) {
	$is_product_collection_block = $rendered_block->context['query']['isProductCollectionBlock'] ?? false;
	if ( ! $is_product_collection_block && 'woocommerce/related-products' === ( $parsed_block['attrs']['namespace'] ?? null ) && ProductQuery::is_woocommerce_variation( $parsed_block ) ) {
		return true;
	}

	return false;
}