Update: 2026-06-26 04:38:26

This commit is contained in:
Hamza-Ayed
2026-06-26 04:38:26 +03:00
parent 116f08d367
commit 3413ca8b07

View File

@@ -45,15 +45,19 @@ $hour = (int)$currentTime->format('H');
switch ($country) { switch ($country) {
case 'Syria': case 'Syria':
$minFare = 150.0; $minFare = 150.0;
$promoMaxDiscount = 30.0;
break; break;
case 'Egypt': case 'Egypt':
$minFare = 20.0; $minFare = 20.0;
$promoMaxDiscount = 25.0;
break; break;
case 'Jordan': case 'Jordan':
$minFare = 1.0; $minFare = 1.0;
$promoMaxDiscount = 0.30;
break; break;
default: default:
$minFare = 0.0; $minFare = 0.0;
$promoMaxDiscount = 0.0;
break; break;
} }
@@ -450,10 +454,23 @@ foreach ($categories as $key => $carType) {
$price_for_driver = $result['price_for_driver']; $price_for_driver = $result['price_for_driver'];
// Apply discount // Apply discount
$discountAmount = 0;
if ($discount > 0 && $discount <= 100) { if ($discount > 0 && $discount <= 100) {
$finalPrice = max(0, $withCommission - ($withCommission * ($discount / 100))); $discountAmount = $withCommission * ($discount / 100);
} else { } 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 // Add negative balance