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

Automattic\WooCommerce\Admin\API

Leaderboards::get_products_leaderboard() public WC 1.0

Get the data for the products leaderboard.

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

Хуков нет.

Возвращает

Null. Ничего.

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

$Leaderboards = new Leaderboards();
$Leaderboards->get_products_leaderboard( $per_page, $after, $before, $persisted_query );
$per_page(число) (обязательный)
Number of rows.
$after(строка) (обязательный)
Items after date.
$before(строка) (обязательный)
Items before date.
$persisted_query(строка) (обязательный)
URL query string.

Код Leaderboards::get_products_leaderboard() WC 4.7.1

<?php
public function get_products_leaderboard( $per_page, $after, $before, $persisted_query ) {
	$products_data_store = new ProductsDataStore();
	$products_data       = $per_page > 0 ? $products_data_store->get_data(
		array(
			'orderby'       => 'items_sold',
			'order'         => 'desc',
			'after'         => $after,
			'before'        => $before,
			'per_page'      => $per_page,
			'extended_info' => true,
		)
	)->data : array();

	$rows = array();
	foreach ( $products_data as $product ) {
		$url_query    = wp_parse_args(
			array(
				'filter'   => 'single_product',
				'products' => $product['product_id'],
			),
			$persisted_query
		);
		$product_url  = wc_admin_url( '/analytics/products', $url_query );
		$product_name = isset( $product['extended_info'] ) && isset( $product['extended_info']['name'] ) ? $product['extended_info']['name'] : '';
		$rows[]       = array(
			array(
				'display' => "<a href='{$product_url}'>{$product_name}</a>",
				'value'   => $product_name,
			),
			array(
				'display' => wc_admin_number_format( $product['items_sold'] ),
				'value'   => $product['items_sold'],
			),
			array(
				'display' => wc_price( $product['net_revenue'] ),
				'value'   => $product['net_revenue'],
			),
		);
	}

	return array(
		'id'      => 'products',
		'label'   => __( 'Top Products - Items Sold', 'woocommerce' ),
		'headers' => array(
			array(
				'label' => __( 'Product', 'woocommerce' ),
			),
			array(
				'label' => __( 'Items Sold', 'woocommerce' ),
			),
			array(
				'label' => __( 'Net Sales', 'woocommerce' ),
			),
		),
		'rows'    => $rows,
	);
}