Buenas de nuevo,
Me he mirado el codigo para ver si podria yo mismo implementarlo..pero no se como lo podria hacer..aqui os dejo el codigo:
Código PHP:
if(!$_GET['v'] == "n"){
conectardb($host,$usuariodb,$contrasenadb,$basedatos);
if(!empty($producto)){
$sql="SELECT producto FROM productos WHERE producto='$producto'";
}elseif(!empty($proyecto)){
$sql="SELECT proyecto FROM proyectos_dvd WHERE numdvd='$proyecto'";
}
$query= mysql_query($sql);
$resultado= mysql_fetch_array($query);
}
$item=$resultado[0];
$cantidad=$_POST['cantidad'];
$itemsEnCesta=$_SESSION['itemsEnCesta'];
if($_POST['actucan']){
if(!empty($_POST['cantidadnueva']) && $_POST['cantidadnueva'] > 0){
$pro=$_GET['i'];
$cantidadnu=$_POST['cantidadnueva'];
$itemsEnCesta[$pro]=$cantidadnu;
}elseif($_POST['cantidadnueva'] == 0 || empty($_POST['cantidadnueva'])){
$pro=$_GET['i'];
unset($itemsEnCesta[$pro]);
}
}
if ($item){
if (!isset($itemsEnCesta)){
$itemsEnCesta[$item]=$cantidad;
}else{
foreach($itemsEnCesta as $k => $v){
if ($item==$k){
$itemsEnCesta[$k]+=$cantidad;
$encontrado=1;
}
}
if (!$encontrado){ $itemsEnCesta[$item]=$cantidad;}
}
}
$_SESSION['itemsEnCesta']=$itemsEnCesta;
if (isset($itemsEnCesta)){
$cantidades= array();
$unidades= array();
echo "<table style='margin: 0px;padding: 0px;'>";
foreach($itemsEnCesta as $k => $v){
$sqlp="SELECT pre FROM precios WHERE pro='$k'";
$queryp= mysql_query($sqlp);
$resultadop= mysql_fetch_array($queryp);
echo "<tr><td><font style='font-weight: bold;color: #e98d2b;font-family: Verdana;font-size:0.8em;'>Producto: </font><font style='color: #000000;font-weight: bold;font-family: Verdana;font-size:0.8em;'>".$k."</font></td>
<td style='padding-left: 42px;'><font style='font-weight: bold;color: #e98d2b;font-family: Verdana;font-size:0.8em;'> Unidades </font><form method='post' action='ac.php?v=n&i=$k'><input type='text' name='cantidadc' size='1' value='".$v."' readonly='readonly' /><input type='text' name='cantidadnueva' size='1' style='margin-left: 5px;' value='0'/><input type='submit' name='actucan' value='Cambiar Cantidad' style='margin-left: 5px;background-color: #e74a49;' /></form></td>
<td style='padding-left: 42px;'><font style='font-weight: bold;color: #e98d2b;font-family: Verdana;font-size:0.8em;'>Precio Und.</font><font style='color: #000000;font-weight: bold;font-family: Verdana;font-size:0.8em;'> $resultadop[0] €</font></td>
<td style='padding-left: 42px;'><font style='font-weight: bold;color: #e98d2b;font-family: Verdana;font-size:0.8em;'>Total: </font><font style='color: #000000;font-weight: bold;font-family: Verdana;font-size:0.8em;'>".$totalp=($resultadop[0]*$v)." €</font></td></tr>";
array_push($cantidades,$totalp);
array_push($unidades,$v);
}
if(count($cantidades) > 0 && count($unidades) > 0){
echo "<tr><td colspan='2' style='padding-left: 0px;'><font style='font-weight: bold;color: #e98d2b;font-family: Verdana;font-size:0.8em;'>Unidades totales de la compra: </font><font style='color: #000000;font-weight: bold;font-family: Verdana;font-size:0.8em;'>".array_sum($unidades)." Und.</font>"."</td>";
echo "<td colspan='2' align='right'><font style='font-weight: bold;color: #e98d2b;font-family: Verdana;font-size:0.8em;'>Precio total de la compra: </font><font style='color: #000000;font-weight: bold;font-family: Verdana;font-size:0.8em;'>".array_sum($cantidades)." €</font>"."</td></tr>";
echo "<tr><td colspan='4' align='right'><form action='ppc.php' method='post'><input type='submit' name='envio' value='Pasar por caja' style='margin-top: 10px;background-color: #e74a49;' /></form></td></tr>";
}else{
echo "<p>El carrito esta vacio.No has añadido ningun producto al carrito.</p>";
}
}
echo "</table>";
if($_GET['vo'] == "s"){
$categoria= $_GET['cat'];
$pagina=$_GET['_pagi_pg'];
if(isset($producto)){
echo "<a href='ti.php?cat=$categoria'>Seguir comprando</a>";
echo "<br/><a href='ti.php'>Ir a categorias</a>";
}elseif(isset($proyecto)){
echo "<a href='pd.php'>Seguir comprando</a>";
}
}
}
Tan solo una observacion, $producto y $proyecto las recogo por metodo GET..
Un Saludo!!