prepare("INSERT INTO checkout_attempts (user_id, name, phone, address, notes, subtotal, shipping, tip, total) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"); $userId = $_SESSION['user_id'] ?? null; $stmt->bind_param("issssddds", $userId, $name, $phone, $address, $notes, $subtotal, $shipping, $tip, $total); $stmt->execute(); $attemptId = $stmt->insert_id; // 2. Save items $itemStmt = $conn->prepare("INSERT INTO checkout_items (attempt_id, product_id, quantity, price) VALUES (?, ?, ?, ?)"); foreach ($cart as $item) { $itemStmt->bind_param("iiid", $attemptId, $item['id'], $item['quantity'], $item['price']); $itemStmt->execute(); } // TODO: Initiate Kopokopo STK push here using $phone and $total echo "Checkout logged. Proceeding to payment...";