From 3413ca8b073720102991ae5a38e1c1b908ed20e9 Mon Sep 17 00:00:00 2001 From: Hamza-Ayed Date: Fri, 26 Jun 2026 04:38:26 +0300 Subject: [PATCH] Update: 2026-06-26 04:38:26 --- backend/ride/pricing/get.php | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/backend/ride/pricing/get.php b/backend/ride/pricing/get.php index 17a9bf8d..7637c565 100644 --- a/backend/ride/pricing/get.php +++ b/backend/ride/pricing/get.php @@ -45,15 +45,19 @@ $hour = (int)$currentTime->format('H'); switch ($country) { case 'Syria': $minFare = 150.0; + $promoMaxDiscount = 30.0; break; case 'Egypt': $minFare = 20.0; + $promoMaxDiscount = 25.0; break; case 'Jordan': $minFare = 1.0; + $promoMaxDiscount = 0.30; break; default: $minFare = 0.0; + $promoMaxDiscount = 0.0; break; } @@ -450,10 +454,23 @@ foreach ($categories as $key => $carType) { $price_for_driver = $result['price_for_driver']; // Apply discount + $discountAmount = 0; if ($discount > 0 && $discount <= 100) { - $finalPrice = max(0, $withCommission - ($withCommission * ($discount / 100))); + $discountAmount = $withCommission * ($discount / 100); } else { - $finalPrice = max(0, $withCommission - $discount); + $discountAmount = $discount; + } + + // Cap discount by country-specific max + if ($promoMaxDiscount > 0 && $discountAmount > $promoMaxDiscount) { + $discountAmount = $promoMaxDiscount; + } + + $finalPrice = max(0, $withCommission - $discountAmount); + + // Ensure final price doesn't go below minimum fare + if ($finalPrice < $minFare) { + $finalPrice = $minFare; } // Add negative balance