<?php
// test-cart.php
require_once __DIR__ . '/includes/config.php';
require_once __DIR__ . '/includes/functions.php';

header('Content-Type: application/json');

// Test if session is working
session_start();

// Add a test item to cart if empty
if (empty($_SESSION['cart'])) {
    $_SESSION['cart'] = [
        'test-1' => [
            'product_id' => 1,
            'name' => 'Test Product',
            'price' => 100,
            'quantity' => 1,
            'image' => 'default.jpg',
            'attributes' => []
        ]
    ];
}

echo json_encode([
    'session' => $_SESSION['cart'],
    'count' => getCartCount(),
    'total' => getCartTotal()
]);
?>