Fix order_count inconsistency between stats and reports (#49283)

* Fix order_count consistency between stats and reports

* Add changefile(s) from automation for the following project(s): woocommerce

---------

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
Miguel Pérez Pellicer 2024-07-10 17:19:33 +04:00 committed by GitHub
parent 4311640de2
commit 39b8b23fc8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Fix Order Count inconsistency between stats and reports

View File

@ -82,7 +82,7 @@ class DataStore extends ReportsDataStore implements DataStoreInterface {
'total_tax' => 'SUM(total_tax) as total_tax',
'order_tax' => 'SUM(order_tax) as order_tax',
'shipping_tax' => 'SUM(shipping_tax) as shipping_tax',
'orders_count' => "COUNT({$table_name}.order_id) as orders_count",
'orders_count' => "COUNT( DISTINCT ( CASE WHEN parent_id = 0 THEN {$table_name}.order_id END ) ) as orders_count",
);
}