Ayúdame a corregir mi código, lo que quiero es que los productos que seleccione desde el apartado de productos aparezcan, pero al momento de agregar mis productos al carrito estos no aparecen & no se suma la cantidad total a pagar. Te paso el código <?php session_start(); if (isset($_GET['action'])) { if ($_GET['action'] == 'vaciar') { unset($_SESSION['carrito']); } elseif ($_GET['action'] == 'eliminar' && isset($_GET['codigoProd'])) { $codigoProd = $_GET['codigoProd']; if (isset($_SESSION['carrito'][$codigoProd])) { unset($_SESSION['carrito'][$codigoProd]); } } } ?> <!DOCTYPE html> <html lang="es"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Mi carrito de compras</title> <style> h1 { font-family: 'Cambria', cursive; font-style: italic; color: #333; text-align: center; } .carrito { border: 2px solid #f699cd; border-radius: 10px; padding: 20px; max-width: 800px; margin: 20px auto; background-color: #ffe4f0; box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1); } table { width: 100%; border-collapse: collapse; } th, td { padding: 10px; text-align: left; border-bottom: 1px solid #ddd; } th { background-color: #f699cd; color: white; } td a { color: #f699cd; text-decoration: none; } td a:hover { text-decoration: underline; } a.btn-vaciar { display: inline-block; padding: 10px 20px; background-color: #f699cd; color: white; text-decoration: none; border-radius: 5px; margin-top: 20px; } a.btn-vaciar:hover { background-color: #e0669c; } .seguir-comprando { text-align: center; margin-top: 20px; } </style> </head> <body> <h1>Carrito de Compras</h1> <div class="carrito"> <?php if (isset($_SESSION['carrito']) && count($_SESSION['carrito']) > 0): ?> <table> <thead> <tr> <th>Producto</th> <th>Precio</th> <th>Cantidad</th> <th>Total</th> <th>Acciones</th> </tr> </thead> <tbody> <?php $totalCarrito = 0; foreach ($_SESSION['carrito'] as $key => $producto): ?> <tr> <td><?php echo $producto['nombreProd']; ?></td> <td><?php echo number_format($producto['precioProd'], 2); ?></td> <td><?php echo $producto['cantidad']; ?></td> <td><?php echo number_format($producto['precioProd'] * $producto['cantidad'], 2); ?></td> <td> <a href="carrito.php?action=eliminar&codigoProd=<?php echo $key; ?>">Eliminar</a> </td> </tr> <?php $totalCarrito += $producto['precioProd'] * $producto['cantidad']; endforeach; ?> </tbody> </table> <h2>Total: $<?php echo number_format($totalCarrito, 2); ?></h2> <a href="carrito.php?action=vaciar" class="btn-vaciar">Vaciar Carrito</a> <?php else: ?> <p>El carrito está vacío</p> <?php endif; ?> <div class="seguir-comprando"> <a href="index.php">Seguir comprando</a> </div> </div> </body> </html>
php session_start(); if (isset($_GET['action'])) { $action = $_GET['action']; } else { $action = ''; } if (isset($_GET['id'])) { $id = $_GET['id']; } else { $id = ''; } if (isset($_GET['name'])) { $name = $_GET['name']; } else { $name =