Automattic\WooCommerce\Blocks\BlockTypes

ProductQuery::filter_query_to_only_include_ids()privateWC 1.0

Apply the query only to a subset of products

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

Хуков нет.

Возвращает

Массив.

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

// private - только в коде основоного (родительского) класса
$result = $this->filter_query_to_only_include_ids( $query, $ids );
$query(массив) (обязательный)
The query.
$ids(массив) (обязательный)
Array of selected product ids.

Код ProductQuery::filter_query_to_only_include_ids() WC 9.8.1

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;
}