Track purchases regardless of status but return revenue status correctly

When we apply this commit every purchase will be tracked. When the shop manager updates an order
the status will be updated. For the statistics it will only return values for purchases with
the 'completed' status

[MAILPOET-5485]
This commit is contained in:
David Remer
2023-08-24 10:21:54 +03:00
committed by Aschepikov
parent bba7786e7e
commit 7ac2065b1a
4 changed files with 38 additions and 2 deletions

View File

@@ -263,6 +263,8 @@ class NewsletterStatisticsRepository extends Repository {
return null;
}
$revenueStatus = $this->wcHelper->getPurchaseStates();
$currency = $this->wcHelper->getWoocommerceCurrency();
$query = $this->entityManager
->createQueryBuilder()
@@ -270,8 +272,10 @@ class NewsletterStatisticsRepository extends Repository {
->from(StatisticsWooCommercePurchaseEntity::class, 'stats')
->where('stats.newsletter IN (:newsletters)')
->andWhere('stats.orderCurrency = :currency')
->andWhere('stats.status IN (:revenue_status)')
->setParameter('newsletters', $newsletters)
->setParameter('currency', $currency)
->setParameter('revenue_status', $revenueStatus)
->groupBy('stats.newsletter');
if ($from && $to) {