Automattic\WooCommerce\Blocks\BlockTypes
ProductQuery::filter_query_to_only_include_ids
Apply the query only to a subset of products
Method of the class: ProductQuery{}
No Hooks.
Returns
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() ProductQuery::filter query to only include ids code WC 10.3.6
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;
}