'error', 'message' => 'La quantità deve essere almeno 1.' ]); exit; } // Check if the item exists in the cart if (isset($_SESSION['cart'][$idschedule])) { // Update the quantity for the specified item $_SESSION['cart'][$idschedule]['quantity'] = $quantity; echo json_encode([ 'status' => 'success', 'message' => 'Quantità aggiornata con successo.' ]); } else { echo json_encode([ 'status' => 'error', 'message' => 'Articolo non trovato nel carrello.' ]); } } else { echo json_encode([ 'status' => 'error', 'message' => 'Dati non validi.' ]); }