<?php
require_once 'config.php';
// Check if customer is logged in
if (!isset($_SESSION['opd_patient'])) {
    // Store cart page as redirect URL
    $_SESSION['redirect_after_login'] = 'cart.php';
    header('Location: opd/index.php');
    exit;
}

$patient_id = $_SESSION['opd_patient'];
$patient = $conn->query("SELECT * FROM opd_patients WHERE id=$patient_id")->fetch_assoc();
header('Content-Type: application/json');
echo json_encode(['count' => getCartCount(session_id())]);