Automattic\WooCommerce\Admin\API\Reports\Orders\Stats
DataStore::get_unique_product_count
Get unique products based on user time query
Method of the class: DataStore{}
No Hooks.
Returns
integer. Unique product count.
Usage
$DataStore = new DataStore(); $DataStore->get_unique_product_count( $from_clause, $where_time_clause, $where_clause );
- $from_clause(string) (required)
- From clause with date query.
- $where_time_clause(string) (required)
- Where clause with date query.
- $where_clause(string) (required)
- Where clause with date query.
DataStore::get_unique_product_count() DataStore::get unique product count code WC 11.3.0
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.
}