Automattic\WooCommerce\Blocks

QueryFilters::main_query_filter()publicWC 1.0

Filter the posts clauses of the main query to suport global filters.

Method of the class: QueryFilters{}

No Hooks.

Return

Array.

Usage

$QueryFilters = new QueryFilters();
$QueryFilters->main_query_filter( $args, $wp_query );
$args(array) (required)
Query args.
$wp_query(\WP_Query) (required)
WP_Query object.

QueryFilters::main_query_filter() code WC 9.0.1

public function main_query_filter( $args, $wp_query ) {
	if (
		! $wp_query->is_main_query() ||
		'product_query' !== $wp_query->get( 'wc_query' )
	) {
		return $args;
	}

	if ( $wp_query->get( 'filter_stock_status' ) ) {
		$args = $this->stock_filter_clauses( $args, $wp_query );
	}

	return $args;
}