Automattic\WooCommerce\Blocks\BlockTypes
ProductQuery::update_query
Update the query for the product query block.
Method of the class: ProductQuery{}
No Hooks.
Returns
null. Nothing (null).
Usage
$ProductQuery = new ProductQuery(); $ProductQuery->update_query( $pre_render, $parsed_block );
- $pre_render(string|null) (required)
- The pre-rendered content.
Default: null - $parsed_block(array) (required)
- The block being rendered.
ProductQuery::update_query() ProductQuery::update query code WC 10.4.3
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.
wp_interactivity_config(
'woocommerce',
[
'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,
2
);
}
return $pre_render;
}