Automattic\WooCommerce\Admin\API\Reports\Orders\Stats

DataStore::get_unique_product_count()publicWC 1.0

Get unique products based on user time query

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

Хуков нет.

Возвращает

Int. Unique product count.

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

$DataStore = new DataStore();
$DataStore->get_unique_product_count( $from_clause, $where_time_clause, $where_clause );
$from_clause(строка) (обязательный)
From clause with date query.
$where_time_clause(строка) (обязательный)
Where clause with date query.
$where_clause(строка) (обязательный)
Where clause with date query.

Код DataStore::get_unique_product_count() WC 9.4.2

public function get_unique_product_count( $from_clause, $where_time_clause, $where_clause ) {
	global $wpdb;

	$table_name = self::get_db_table_name();
	return $wpdb->get_var(
		"SELECT
				COUNT( DISTINCT {$wpdb->prefix}wc_order_product_lookup.product_id )
			FROM
				{$wpdb->prefix}wc_order_product_lookup JOIN {$table_name} ON {$wpdb->prefix}wc_order_product_lookup.order_id = {$table_name}.order_id
				{$from_clause}
			WHERE
				1=1
				{$where_time_clause}
				{$where_clause}"
	); // phpcs:ignore cache ok, DB call ok, unprepared SQL ok.
}