<?php
// views/pages/raspadita/api/venta_cart_list.php
declare(strict_types=1);

session_start();
date_default_timezone_set('America/Guayaquil');
header('Content-Type: application/json; charset=utf-8');
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
header('Pragma: no-cache');
header('Expires: 0');

if (!isset($_SESSION['idusuario'])) { http_response_code(401); echo json_encode(['success'=>false,'message'=>'Sesión no iniciada']); exit; }

$_SESSION['rasp_cart'] = $_SESSION['rasp_cart'] ?? [];
$PRECIO_FIJO = 0.50;

$items = array_values($_SESSION['rasp_cart']);
$total = round(count($items) * $PRECIO_FIJO, 2);

echo json_encode(['success'=>true,'data'=>$items,'total'=>$total,'precio'=>$PRECIO_FIJO], JSON_UNESCAPED_UNICODE);
