...
WC_Admin_Report... ... ...
include_once( WP_PLUGIN_DIR . '/woocommerce/includes/admin/reports/class-wc-admin-report.php');
$reports = new WC_Admin_Report();
$args = array(
'data' => array(
'_order_total' => array(
'type' => 'meta',
'function' => 'SUM',
'name' => 'total_cash'
),
'ID' => array(
'type' => 'post_data',
'function' => 'COUNT',
'name' => 'total_orders'
),
'post_status' => array(
'type' => 'post_data',
'function' => '',
'name' => 'status'
),
),
'where' => array(
array(
'key' => 'post_date',
'value' => date( 'Y-m-d', strtotime( '02/01/2016' ) ),
'operator' => '>'
),
array(
'key' => 'post_date',
'value' => date( 'Y-m-d', strtotime( '02/31/2016' ) ),
'operator' => '<'
),
),
'where_meta' => array(
array(
'meta_key' => 'who',
'meta_value' => 'manik',
'operator' => '='
)
),
'order_status' => array( 'cancelled', 'completed', 'shipped' ),
'group_by' => 'posts.post_status',
'query_type' => 'get_results',
);
$data = $reports->get_order_report_data($args);
print_r($data);
-
Array
(
[0] => stdClass Object
(
[total_cash] => 35
[total_orders] => 2
[status] => wc-cancelled
)
[1] => stdClass Object
(
[total_cash] => 315
[total_orders] => 21
[status] => wc-completed
)
[2] => stdClass Object
(
[total_cash] => 211
[total_orders] => 11
[status] => wc-shipped
)
)
$data
$currency = (function_exists('get_woocommerce_currency_symbol'))?get_woocommerce_currency_symbol():'';
foreach($data as $item) {
echo sprintf('<p>%s : Total Orders %s -> Total Cash -> %s%s </p>', $item->status, $item->total_orders, $item->total_cash, $currency);
}
$data. " ".
:
wc-cancel: Total Orders 2 → → 35 $
wc-completed: 21 → → 315 $
wc-: 11 → → 211 $