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

WC_Admin_Dashboard::get_top_seller() WC 1.0

Get top seller from DB.

Это метод класса: WC_Admin_Dashboard

Хуки из метода
Возвращает

Объект.

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

$WC_Admin_Dashboard = new WC_Admin_Dashboard();
$var = $WC_Admin_Dashboard->get_top_seller();

Код WC Admin Dashboard::get top seller: woocommerce/includes/admin/class-wc-admin-dashboard.php WC 3.6.3

<?php
private function get_top_seller() {
	global $wpdb;

	$query            = array();
	$query['fields']  = "SELECT SUM( order_item_meta.meta_value ) as qty, order_item_meta_2.meta_value as product_id
	FROM {$wpdb->posts} as posts";
	$query['join']    = "INNER JOIN {$wpdb->prefix}woocommerce_order_items AS order_items ON posts.ID = order_id ";
	$query['join']   .= "INNER JOIN {$wpdb->prefix}woocommerce_order_itemmeta AS order_item_meta ON order_items.order_item_id = order_item_meta.order_item_id ";
	$query['join']   .= "INNER JOIN {$wpdb->prefix}woocommerce_order_itemmeta AS order_item_meta_2 ON order_items.order_item_id = order_item_meta_2.order_item_id ";
	$query['where']   = "WHERE posts.post_type IN ( '" . implode( "','", wc_get_order_types( 'order-count' ) ) . "' ) ";
	$query['where']  .= "AND posts.post_status IN ( 'wc-" . implode( "','wc-", apply_filters( 'woocommerce_reports_order_statuses', array( 'completed', 'processing', 'on-hold' ) ) ) . "' ) ";
	$query['where']  .= "AND order_item_meta.meta_key = '_qty' ";
	$query['where']  .= "AND order_item_meta_2.meta_key = '_product_id' ";
	$query['where']  .= "AND posts.post_date >= '" . date( 'Y-m-01', current_time( 'timestamp' ) ) . "' ";
	$query['where']  .= "AND posts.post_date <= '" . date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ) . "' ";
	$query['groupby'] = 'GROUP BY product_id';
	$query['orderby'] = 'ORDER BY qty DESC';
	$query['limits']  = 'LIMIT 1';

	return $wpdb->get_row( implode( ' ', apply_filters( 'woocommerce_dashboard_status_widget_top_seller_query', $query ) ) ); //phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
}