WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Платформа для конвертации и монетизации трафика
функция не описана

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

Segmenter::get_product_related_intervals_segments() protected WC 1.0

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

{} Это метод класса: Segmenter{}

Хуков нет.

Возвращает

Массив.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->get_product_related_intervals_segments( $segmenting_selections, $segmenting_from, $segmenting_where, $segmenting_groupby, $segmenting_dimension_name, $table_name, $intervals_query, $unique_orders_table );
$segmenting_selections(массив) (обязательный)
SELECT part of segmenting SQL query--one for 'product_level' and one for 'order_level'.
$segmenting_from(строка) (обязательный)
FROM part of segmenting SQL query.
$segmenting_where(строка) (обязательный)
WHERE part of segmenting SQL query.
$segmenting_groupby(строка) (обязательный)
GROUP BY part of segmenting SQL query.
$segmenting_dimension_name(строка) (обязательный)
Name of the segmenting dimension.
$table_name(строка) (обязательный)
Name of SQL table which is the stats table for orders.
$intervals_query(массив) (обязательный)
Array of SQL clauses for intervals query.
$unique_orders_table(строка) (обязательный)
Name of temporary SQL table that holds unique orders.

Код Segmenter::get_product_related_intervals_segments() WC 4.7.1

<?php
protected function get_product_related_intervals_segments( $segmenting_selections, $segmenting_from, $segmenting_where, $segmenting_groupby, $segmenting_dimension_name, $table_name, $intervals_query, $unique_orders_table ) {
	global $wpdb;

	// LIMIT offset, rowcount needs to be updated to LIMIT offset, rowcount * max number of segments.
	$limit_parts      = explode( ',', $intervals_query['limit'] );
	$orig_rowcount    = intval( $limit_parts[1] );
	$segmenting_limit = $limit_parts[0] . ',' . $orig_rowcount * count( $this->get_all_segments() );

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

	$intervals_segments = $this->merge_segment_intervals_results( $segmenting_dimension_name, $segments_products, array() );
	return $intervals_segments;
}