WC_REST_Report_Customers_Totals_Controller::get_reports() protected WC 3.5.0
Get reports list.
{} Это метод класса: WC_REST_Report_Customers_Totals_Controller{}
Хуков нет.
Возвращает
Массив
. Ничего.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->get_reports();
Список изменений
С версии 3.5.0 | Введена. |
Код WC_REST_Report_Customers_Totals_Controller::get_reports() WC REST Report Customers Totals Controller::get reports WC 5.2.2
protected function get_reports() {
$users_count = count_users();
$total_customers = 0;
foreach ( $users_count['avail_roles'] as $role => $total ) {
if ( in_array( $role, array( 'administrator', 'shop_manager' ), true ) ) {
continue;
}
$total_customers += (int) $total;
}
$customers_query = new WP_User_Query(
array(
'role__not_in' => array( 'administrator', 'shop_manager' ),
'number' => 0,
'fields' => 'ID',
'count_total' => true,
'meta_query' => array( // WPCS: slow query ok.
array(
'key' => 'paying_customer',
'value' => 1,
'compare' => '=',
),
),
)
);
$total_paying = (int) $customers_query->get_total();
$data = array(
array(
'slug' => 'paying',
'name' => __( 'Paying customer', 'woocommerce' ),
'total' => $total_paying,
),
array(
'slug' => 'non_paying',
'name' => __( 'Non-paying customer', 'woocommerce' ),
'total' => $total_customers - $total_paying,
),
);
return $data;
}