Include puchases count in newsletters stats
[PREMIUM-115]
This commit is contained in:
@@ -605,6 +605,7 @@ class Newsletter extends Model {
|
|||||||
) {
|
) {
|
||||||
$currency = $woocommerce_helper->getWoocommerceCurrency();
|
$currency = $woocommerce_helper->getWoocommerceCurrency();
|
||||||
$row = StatisticsWooCommercePurchases::selectExpr('SUM(order_price_total) AS total')
|
$row = StatisticsWooCommercePurchases::selectExpr('SUM(order_price_total) AS total')
|
||||||
|
->selectExpr('count(*)', 'count')
|
||||||
->where([
|
->where([
|
||||||
'newsletter_id' => $this->id,
|
'newsletter_id' => $this->id,
|
||||||
'order_currency' => $currency,
|
'order_currency' => $currency,
|
||||||
@@ -612,9 +613,11 @@ class Newsletter extends Model {
|
|||||||
->findOne();
|
->findOne();
|
||||||
|
|
||||||
$revenue = !empty($row->total) ? (float)$row->total : 0.0;
|
$revenue = !empty($row->total) ? (float)$row->total : 0.0;
|
||||||
|
$count = !empty($row->count) ? (int)$row->count : 0;
|
||||||
$result['revenue'] = [
|
$result['revenue'] = [
|
||||||
'currency' => $currency,
|
'currency' => $currency,
|
||||||
'value' => $revenue,
|
'value' => $revenue,
|
||||||
|
'count' => $count,
|
||||||
'formatted' => $woocommerce_helper->getRawPrice($revenue, ['currency' => $currency]),
|
'formatted' => $woocommerce_helper->getRawPrice($revenue, ['currency' => $currency]),
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user