diff --git a/index.php b/index.php index 7aafa23..3641ccf 100644 --- a/index.php +++ b/index.php @@ -1805,7 +1805,7 @@ if (isset($_GET['action']) || isset($_POST['action'])) { if ($discount) { echo json_encode(['success' => true, 'discount' => $discount]); } else { - echo json_encode(['success' => false, 'error' => 'Invalid or expired discount code']); + echo json_encode(['success' => false, 'error' => ($lang === 'ar' ? 'رمز الخصم غير صالح أو منتهي الصلاحية' : 'Invalid or expired discount code')]); } exit; } @@ -1977,7 +1977,7 @@ if (isset($_GET['action']) || isset($_POST['action'])) { if ($action === 'hold_pos_cart') { header('Content-Type: application/json'); - $name = $_POST['cart_name'] ?? 'Untitled Cart'; + $name = $_POST['cart_name'] ?? ($lang === 'ar' ? 'طلب غير مسمى' : 'Untitled Cart'); $items = $_POST['items'] ?? '[]'; $customer_id = !empty($_POST['customer_id']) ? (int)$_POST['customer_id'] : null; $stmt = db()->prepare("INSERT INTO pos_held_carts (cart_name, items_json, customer_id) VALUES (?, ?, ?)"); @@ -2013,9 +2013,17 @@ if (isset($_GET['action']) || isset($_POST['action'])) { $total_amount = (float)($_POST['total_amount'] ?? 0); $tax_amount = (float)($_POST['tax_amount'] ?? 0); $discount_code_id = !empty($_POST['discount_code_id']) ? (int)$_POST['discount_code_id'] : null; - $discount_amount = (float)($_POST['discount_amount'] ?? 0); - $loyalty_redeemed = (float)($_POST['loyalty_redeemed'] ?? 0); - $net_amount = $total_amount - $discount_amount - $loyalty_redeemed; + $discount_amount = max(0, (float)($_POST['discount_amount'] ?? 0)); + $manualDiscountEnabled = getSettingValue('manual_discount_enabled', '0') === '1'; + if (!$manualDiscountEnabled && $discount_code_id === null) { + $discount_amount = 0.0; + } + if ($discount_amount > $total_amount) { + $discount_amount = max(0, $total_amount); + } + $loyalty_redeemed = max(0, (float)($_POST['loyalty_redeemed'] ?? 0)); + $loyalty_redeemed = min($loyalty_redeemed, max(0, $total_amount - $discount_amount)); + $net_amount = max(0, $total_amount - $discount_amount - $loyalty_redeemed); $transaction_no = 'POS-' . time() . rand(10, 99); $session_id = $_SESSION['register_session_id'] ?? null; @@ -7691,15 +7699,15 @@ runtime_debug_mark('page:rendering', ['page' => (string)$page]);
- +
- +
@@ -7727,7 +7735,7 @@ runtime_debug_mark('page:rendering', ['page' => (string)$page]); OMR
- left + @@ -7736,21 +7744,21 @@ runtime_debug_mark('page:rendering', ['page' => (string)$page]);
-
Cart
+
- + - + - - - + + +
- +
- +
-
Spend more to unlock Silver
+
-
- + +
+
- - + + +
+
+
+ +
+ +
+ +
@@ -7797,31 +7815,44 @@ runtime_debug_mark('page:rendering', ['page' => (string)$page]);
-

Cart is empty

+

- Subtotal (Excl. VAT) + 0.000
- VAT + 0.000
- Total + 0.000
-