Add order counts by status

This commit is contained in:
Menaka S 2020-12-23 06:47:39 +05:30
parent 0aee0a0848
commit 1a6835019a
1 changed files with 11 additions and 0 deletions

View File

@ -390,6 +390,8 @@ class WC_Tracker {
$status = $order->get_status();
if ( 'shop_order' == $type ) {
// Find the first and last order dates for completed and processing statuses
if ( "completed" == $status and $date_created < $first ) {
$first = $date_created;
}
@ -402,6 +404,15 @@ class WC_Tracker {
if ( "processing" == $status and $date_created > $processing_last ) {
$processing_last = $date_created;
}
// Get order counts by status
$status = "wc-" . $status;
if ( ! isset( $order_data[ $status ] ) ) {
$order_data[ $status ] = 1;
} else {
$order_data[ $status ] += 1;
}
}
}
$order_data['first'] = gmdate( 'Y-m-d H:i:s', $first );