updating loyality

This commit is contained in:
Flatlogic Bot 2026-02-25 19:06:52 +00:00
parent 0c98d8d160
commit a1d6822c0a

View File

@ -75,6 +75,7 @@ try {
$loyaltySettings = $settingsStmt->fetch(PDO::FETCH_ASSOC);
$loyalty_enabled = $loyaltySettings ? (bool)$loyaltySettings['is_enabled'] : true;
$points_threshold = $loyaltySettings ? intval($loyaltySettings['points_for_free_meal']) : 70;
$points_per_product = $loyaltySettings ? intval($loyaltySettings['points_per_order']) : 10;
$current_points = 0;
$points_deducted = 0;
@ -206,9 +207,9 @@ try {
// Recalculate Subtotal and Earned Points
foreach ($processed_items as $pi) {
$calculated_total += $pi['unit_price'] * $pi['quantity'];
// Award points for PAID loyalty items (10 points each)
// Award points for PAID loyalty items
if ($pi['is_loyalty'] && $pi['unit_price'] > 0) {
$points_awarded += $pi['quantity'] * 10;
$points_awarded += $pi['quantity'] * $points_per_product;
}
}
@ -373,4 +374,4 @@ You've earned *{points_earned} points* with this order.
if ($pdo->inTransaction()) $pdo->rollBack();
error_log("Order Error: " . $e->getMessage());
echo json_encode(['success' => false, 'error' => $e->getMessage()]);
}
}