Yo te pongo el codigo por si acaso
en index.php
Código PHP:
Ver original<form name="form" action="carrito.php" method="get"/>
<input id="datepicker" class="s" type="text" name="date" required />
<input type="hidden" id="id" name="id" value="<?php echo $datos[0["albergue_id"]?>" />
<input type="hidden" id="action" name="action" value="add" />
<input type="hidden" name="url" value="<?php echo $url;?>" />
<input type="submit" value="enviar" />
En carrito.php
Código PHP:
Ver originalrequire_once '../application/Bootstrap.php';
require_once ROOT . 'site/albergues.php';
require_once ROOT . 'site/carro.php';
$config = new Carro();
$obj = new Propiedades();
$config->procesaCarro();
if(isset($_SESSION["carro"])): $totalCoste = 0;
$Total = 0;
foreach($_SESSION["carro"] as $key=>$valor):
$fi = $obj->getRoomsId($key);
foreach($fi as $fila):
$id = $fila["albergue_id"];
$room = $fila["albergue_nombre"];
$precio = $fila["albergue_precio"];
endforeach;
$coste = $precio * $valor;
$totalCoste = $totalCoste + $coste;
$Total = $Total + $valor;
//AQUI EL CODIGO HTML
//CIERRO TODAS LOS CICLOS
?>
Y en site/carro.php
Código PHP:
Ver originalpublic function procesaCarro(){
foreach ($_GET as $key => $input_arr) {
$_GET[$key] = addslashes($this->limpiarCadena($input_arr)); }
}
$id = $_GET['id'];
$id = (int) $id;
}else{
$id = 1;
}
if(isset($_GET["url"])) { $url = $_GET["url"];
}
$_SESSION["carro"] = Array();
if(isset($_GET['action'])) $action = $_GET['action'];
else
$action = '';
switch ($action) {
case 'add':
if(isset($_SESSION['carro'][$id])){
$_SESSION['carro'][$id]++;
}else
$_SESSION['carro'][$id] = 1;
break;
case 'remove':
if(isset($_SESSION['carro'][$id])) {
$_SESSION['carro'][$id]--;
if($_SESSION['carro'][$id] == 0)
unset($_SESSION['carro'][$id]); }
break;
case 'removeProd':
if(isset($_SESSION['carro'][$id])) {
unset($_SESSION['carro'][$id]); }
break;
case 'empty':
unset($_SESSION['carro'][$id]);
break;
}
}