false, 'error' => 'Unauthorized']); exit; } $input = json_decode(file_get_contents('php://input'), true); $id = $input['id'] ?? null; if (!$id) { echo json_encode(['success' => false, 'error' => 'Missing order ID']); exit; } try { $pdo = db(); $stmt = $pdo->prepare("DELETE FROM orders WHERE id = ?"); $stmt->execute([$id]); if ($stmt->rowCount() > 0) { echo json_encode(['success' => true]); } else { echo json_encode(['success' => false, 'error' => 'Order not found or already deleted']); } } catch (Exception $e) { echo json_encode(['success' => false, 'error' => $e->getMessage()]); }