Automattic\WooCommerce\Internal\Admin\Reports

ProductSearchQuery::get_id_condition │ public static │ WC 11.2.0

Returns the condition restricting a report to a set of products.

A search resolves to a subquery, the categories and products filters to an ID list. The subquery already covers those filters, since it is built restricted to the same IDs.

Not a data store method: both products data stores need it and one extends the other, so it would become part of what extensions inherit.

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

Хуков нет.

Возвращает

string. SQL condition, or an empty string when the report is not restricted.

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

$result = ProductSearchQuery::get_id_condition( $column, $search_subquery, $included_products ): string;
$column(строка) (обязательный)
Product ID column to compare, qualified with its table name.
$search_subquery(строка) (обязательный)
Statement the search argument resolves to, from get_ids_subquery(). Empty when the report carries no search.
$included_products(массив) (обязательный)
Product IDs the categories and products filters resolve to.

Список изменений

С версии 11.2.0 Введена.

Код ProductSearchQuery::get_id_condition() WC 11.2.2

public static function get_id_condition( string $column, string $search_subquery, array $included_products ): string {
	if ( '' !== $search_subquery ) {
		return "{$column} IN ( {$search_subquery} )";
	}

	$id_list = implode( ',', $included_products );

	return $id_list ? "{$column} IN ( {$id_list} )" : '';
}