Add compat for status count as well.

This commit is contained in:
Vedanshu Jain 2023-05-15 15:14:43 +05:30
parent 00530cce42
commit b2f7599647
2 changed files with 2 additions and 2 deletions

View File

@ -384,9 +384,8 @@ class WC_Tracker {
*/
private static function get_order_counts() {
$order_count = array();
$order_count_data = wp_count_posts( 'shop_order' );
foreach ( wc_get_order_statuses() as $status_slug => $status_name ) {
$order_count[ $status_slug ] = $order_count_data->{ $status_slug };
$order_count[ $status_slug ] = wc_orders_count( $status_slug );
}
return $order_count;
}

View File

@ -92,6 +92,7 @@ class WC_Tracker_Test extends \WC_Unit_Test_Case {
$order_data = WC_Tracker::get_tracking_data()['orders'];
print_r( $order_data );
foreach ( $status_entries as $status_entry ) {
$this->assertEquals( $order_count / count( $status_entries ), $order_data[ $status_entry ] );
}