diff --git a/api/order.php b/api/order.php index 1811e8e..e1833bf 100644 --- a/api/order.php +++ b/api/order.php @@ -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()]); -} \ No newline at end of file +}