Automattic\WooCommerce\Blocks\Templates

ArchiveProductTemplatesCompatibility::update_render_block_data()publicWC 1.0

Update the render block data to inject our custom attribute needed to determine which blocks belong to an inherited Products block.

Method of the class: ArchiveProductTemplatesCompatibility{}

No Hooks.

Return

Array.

Usage

$ArchiveProductTemplatesCompatibility = new ArchiveProductTemplatesCompatibility();
$ArchiveProductTemplatesCompatibility->update_render_block_data( $parsed_block, $source_block, $parent_block );
$parsed_block(array) (required)
The block being rendered.
$source_block(array) (required)
An un-modified copy of $parsed_block, as it appeared in the source content.
$parent_block(WP_Block|null) (required)
If this is a nested block, a reference to the parent block.

ArchiveProductTemplatesCompatibility::update_render_block_data() code WC 9.0.1

public function update_render_block_data( $parsed_block, $source_block, $parent_block ) {

	if ( ! $this->is_archive_template() ) {
		return $parsed_block;
	}

	/**
	 * Custom data can be injected to top level block only, as Gutenberg
	 * will use this data to render the blocks and its nested blocks.
	 */
	if ( $parent_block ) {
		return $parsed_block;
	}

	$this->inner_blocks_walker( $parsed_block );

	return $parsed_block;
}