WordPress at a glance
function is not described

Automattic\WooCommerce\Admin\API\Reports\Variations\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. Nothing.

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 5.3.0

<?php
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_segmenting_table = $wpdb->prefix . 'wc_order_product_lookup';

	// Can't get all the numbers from one query, so split it into one query for product-level numbers and one for order-level numbers (which first need to have orders uniqued).
	// Product-level numbers.
	$segments_products = $wpdb->get_results(
		"SELECT
					$segmenting_groupby AS $segmenting_dimension_name
					{$segmenting_selections['product_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;
}