Automattic\WooCommerce\Blocks\BlockTypes

ProductQuery::filter_query_to_only_include_ids()privateWC 1.0

Apply the query only to a subset of products

Method of the class: ProductQuery{}

No Hooks.

Return

Array.

Usage

// private - for code of main (parent) class only
$result = $this->filter_query_to_only_include_ids( $query, $ids );
$query(array) (required)
The query.
$ids(array) (required)
Array of selected product ids.

ProductQuery::filter_query_to_only_include_ids() code WC 9.6.0

private function filter_query_to_only_include_ids( $query, $ids ) {
	if ( ! empty( $ids ) ) {
		$query['post__in'] = empty( $query['post__in'] ) ?
			$ids : array_intersect( $ids, $query['post__in'] );
	}

	return $query;
}