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); $loyaltySettings = $settingsStmt->fetch(PDO::FETCH_ASSOC);
$loyalty_enabled = $loyaltySettings ? (bool)$loyaltySettings['is_enabled'] : true; $loyalty_enabled = $loyaltySettings ? (bool)$loyaltySettings['is_enabled'] : true;
$points_threshold = $loyaltySettings ? intval($loyaltySettings['points_for_free_meal']) : 70; $points_threshold = $loyaltySettings ? intval($loyaltySettings['points_for_free_meal']) : 70;
$points_per_product = $loyaltySettings ? intval($loyaltySettings['points_per_order']) : 10;
$current_points = 0; $current_points = 0;
$points_deducted = 0; $points_deducted = 0;
@ -206,9 +207,9 @@ try {
// Recalculate Subtotal and Earned Points // Recalculate Subtotal and Earned Points
foreach ($processed_items as $pi) { foreach ($processed_items as $pi) {
$calculated_total += $pi['unit_price'] * $pi['quantity']; $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) { if ($pi['is_loyalty'] && $pi['unit_price'] > 0) {
$points_awarded += $pi['quantity'] * 10; $points_awarded += $pi['quantity'] * $points_per_product;
} }
} }