Esempio n. 1
0
 if (isset($_GET['accion']) and strcmp($_GET['accion'], "logout") == 0) {
     eliminarSesion();
 } else {
     if (isset($_GET['accion']) and strcmp($_GET['accion'], "addProducto") == 0) {
         $carrito = new carrito();
         $producto = array("id" => $_POST['id'], "cantidad" => $_POST['cantidad'], "precio" => $_POST['precio'], "nombre" => $_POST['nombre']);
         $carrito->add($producto);
         header('Location: cesta.php');
     } else {
         if (isset($_GET['accion']) and strcmp($_GET['accion'], "modificarCesta") == 0) {
             $carrito = new carrito();
             if (isset($_POST['Eliminar'])) {
                 $carrito->remove_producto($_POST['id']);
             } else {
                 if (isset($_POST['Modificar'])) {
                     $carrito->modificar_cantidad($_POST['id'], $_POST['cantidad']);
                 }
             }
             header('Location: cesta.php');
         } else {
             if (isset($_GET['accion']) and strcmp($_GET['accion'], "confirmar") == 0) {
                 header('Location: checkout.php');
             } else {
                 if (isset($_GET['accion']) and strcmp($_GET['accion'], "checkout") == 0) {
                     $carrito = new carrito();
                     if (isset($_POST['direccion']) && trim($_POST['direccion']) != "") {
                         try {
                             $Beans->realizarPedido($carrito->get_content(), $_POST['direccion']);
                             header('Location: index.php');
                         } catch (Exception $e) {
                             header("Location: checkout.php?error=" . $e->getMessage());