Automattic\WooCommerce\Blocks\BlockTypes

ProductQuery::update_query()publicWC 1.0

Update the query for the product query block.

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

Хуков нет.

Возвращает

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

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

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

Код ProductQuery::update_query() WC 9.1.2

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

	$this->parsed_block = $parsed_block;

	if ( self::is_woocommerce_variation( $parsed_block ) ) {
		// Indicate to interactivity powered components that this block is on the page
		// and needs refresh to update data.
		$this->asset_data_registry->add(
			'needsRefreshForInteractivityAPI',
			true
		);
		// Set this so that our product filters can detect if it's a PHP template.
		$this->asset_data_registry->add( 'hasFilterableProducts', true );
		$this->asset_data_registry->add( 'isRenderingPhpTemplate', true );
		add_filter(
			'query_loop_block_query_vars',
			array( $this, 'build_query' ),
			10,
			1
		);
	}

	return $pre_render;
}