Automattic\WooCommerce\Blocks\BlockTypes

RelatedProducts::update_query()publicWC 1.0

Update the query for the product query block.

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

Хуков нет.

Возвращает

null. Ничего (null).

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

$RelatedProducts = new RelatedProducts();
$RelatedProducts->update_query( $pre_render, $parsed_block );
$pre_render(строка|null) (обязательный)
The pre-rendered content.
По умолчанию: null
$parsed_block(массив) (обязательный)
The block being rendered.

Код RelatedProducts::update_query() WC 9.0.2

public function update_query( $pre_render, $parsed_block ) {
	if ( 'core/query' !== $parsed_block['blockName'] ) {
		return $pre_render;
	}

	$this->parsed_block = $parsed_block;

	if ( ProductQuery::is_woocommerce_variation( $parsed_block ) && 'woocommerce/related-products' === $parsed_block['attrs']['namespace'] ) {
		// Set this so that our product filters can detect if it's a PHP template.
		add_filter(
			'query_loop_block_query_vars',
			array( $this, 'build_query' ),
			10,
			1
		);
	}

	return $pre_render;
}