From 2ad0c9e955e07b32ed6f85104acf3e31649b2abd Mon Sep 17 00:00:00 2001 From: jouls Date: Fri, 26 Apr 2024 17:36:12 +0800 Subject: [PATCH] changed logic of summation of daily revenue --- admin/index.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/admin/index.php b/admin/index.php index 8e8582b..9944da9 100644 --- a/admin/index.php +++ b/admin/index.php @@ -756,13 +756,14 @@ $allSignups = array_merge($all_customers, $all_vendors); $orderCount = 0; // Initialize order count $dailyRevenue = 0; - foreach ($all_orders as $x => $val) { + foreach (array_reverse($all_orders) as $x => $val) { $paymentStatus = strtolower($val['payment']['status']); - + $returnStatus = strtolower($val['return_order']['status']); + $orderStatus = strtolower($val['status']); $formattedOrderDate = date('m-d-Y', strtotime($val['order_date'])); if ($formattedOrderDate == $currentDate) { $orderCount++; - if($paymentStatus == "paid"){ + if($paymentStatus == "paid" && (!$returnStatus || $orderStatus != "returned" )){ $dailyRevenue += $val['total_amount']; } // Increment order count for each order on the current date }