Automattic\WooCommerce\Blocks\BlockTypes\ProductCollection

Renderer::handle_rendering │ public │ WC 1.0

Handle the rendering of the block.

Метод класса: Renderer{}

Хуков нет.

Возвращает

string.

Использование

$Renderer = new Renderer();
$Renderer->handle_rendering( $block_content, $block );
$block_content(строка) (обязательный)
The block content about to be rendered.
$block(массив) (обязательный)
The block being rendered.

Код Renderer::handle_rendering() WC 11.3.0

public function handle_rendering( $block_content, $block ) {
	$query                  = $block['attrs']['query'] ?? array();
	$product_reference_type = $query['productReferenceType'] ?? null;
	$is_cart_reference      = empty( $query['productReference'] ) && ( self::REFERENCE_TYPE_CART === $product_reference_type || $this->has_cart_reference_context );

	if ( $this->should_prevent_render() ) {
		// For cart-referencing collections (e.g., cross-sells in the
		// Mini-Cart overlay), render an empty placeholder with a
		// router-region so the Interactivity Router can refresh it when
		// the cart changes.
		if ( $is_cart_reference ) {
			$this->reset_render_state();
			return $this->render_empty_placeholder();
		}

		$this->reset_render_state();
		return '';
	}

	$block_content = $this->enhance_product_collection_with_interactivity( $block_content, $block );

	// Reset the render state for the next render.
	$this->reset_render_state();

	return $block_content;
}