WordPress at Your Fingertips
function is not described

Automattic\WooCommerce\Admin\API\Reports\Coupons\Stats

Segmenter::get_product_related_totals_segments() protected WC 1.0

Calculate segments for totals where the segmenting property is bound to product (e.g. category, product_id, variation_id).

{} It's a method of the class: Segmenter{}

No Hooks.

Return

Array.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_product_related_totals_segments( $segmenting_selections, $segmenting_from, $segmenting_where, $segmenting_groupby, $segmenting_dimension_name, $table_name, $totals_query, $unique_orders_table );
$segmenting_selections(array) (required)
SELECT part of segmenting SQL query--one for 'product_level' and one for 'order_level'.
$segmenting_from(string) (required)
FROM part of segmenting SQL query.
$segmenting_where(string) (required)
WHERE part of segmenting SQL query.
$segmenting_groupby(string) (required)
GROUP BY part of segmenting SQL query.
$segmenting_dimension_name(string) (required)
Name of the segmenting dimension.
$table_name(string) (required)
Name of SQL table which is the stats table for orders.
$totals_query(array) (required)
Array of SQL clauses for totals query.
$unique_orders_table(string) (required)
Name of temporary SQL table that holds unique orders.

Code of Segmenter::get_product_related_totals_segments() WC 6.1.1

protected function get_product_related_totals_segments( $segmenting_selections, $segmenting_from, $segmenting_where, $segmenting_groupby, $segmenting_dimension_name, $table_name, $totals_query, $unique_orders_table ) {
	global $wpdb;

	// Product-level numbers and order-level numbers can be fetched by the same query.
	$segments_products = $wpdb->get_results(
		"SELECT
					$segmenting_groupby AS $segmenting_dimension_name
					{$segmenting_selections['product_level']}
					{$segmenting_selections['order_level']}
				FROM
					$table_name
					$segmenting_from
					{$totals_query['from_clause']}
				WHERE
					1=1
					{$totals_query['where_time_clause']}
					{$totals_query['where_clause']}
					$segmenting_where
				GROUP BY
					$segmenting_groupby",
		ARRAY_A
	); // WPCS: cache ok, DB call ok, unprepared SQL ok.

	$totals_segments = $this->merge_segment_totals_results( $segmenting_dimension_name, $segments_products, array() );
	return $totals_segments;
}