|
Server : Apache/2.4.62 System : FreeBSD fbsdweb2.web.rcn.net 14.1-RELEASE FreeBSD 14.1-RELEASE releng/14.1-n267679-10e31f0946d8 GENERIC amd64 User : www ( 80) PHP Version : 8.3.8 Disable Function : NONE Directory : /domains/logicswapweb/fnc/ |
Upload File : |
<?
//Carrito de compras
class Carrito extends Componente{
var $items; /* array de accesorios */
var $index; /* indice para el array items*/
var $total; /* total de carro */
function Carrito() {
$this->DBManager('MySQL');
$this->connect();
$this->items = array();
$this->index = 0;
$this->total = 0;
}
function agregar($id_pro, $cantidad) {
//a�adir $cantidad de accesorios de tipo id_acces al carro
$this->items[$this->index]['id_pro'] = $id_pro;
$this->items[$this->index]['cantidad'] = $cantidad;
$this->index++;
return true;
}
function del_productos()
{
$this->items = '';
$this->index = 0;
}
function agregarProductos($prods, $cant, $quitar)
{
$p = count($prods);
$c = count($cant);
if($quitar)
$q = count($quitar);
else
$q=0;
if($p != $c)
return false;
for($i = 0; $i < $p; $i++)
{
$quit = false;
if($q > 0)
{
for($j = 0; $j < $q; $j++)
{
if($quitar[$j] == $prods[$i])
{
$quit = true;
}
}
}
if($quit == false)
{
$this->agregar($prods[$i], $cant[$i]);
}
}
}
}
?>