Ver Mensaje Individual
  #4 (permalink)  
Antiguo 20/11/2008, 10:37
Avatar de juaniquillo
juaniquillo
Colaborador
 
Fecha de Ingreso: noviembre-2005
Ubicación: San Juan, Puerto Rico
Mensajes: 5.745
Antigüedad: 18 años, 5 meses
Puntos: 281
Respuesta: Problema con clase

bueno, además de hacer lo de las register_global tuve que hacer lo siguiente:

Tuve que explícitamente convertir la variable en array si no lo es, así que terminé cambiando la función:

Código PHP:
Ver original
  1. function AddToBasket($id, $qty = 1) {
  2.  
  3.         if (isset($_SESSION['cart'][$id])) {
  4.             $_SESSION['cart'][$id] = $_SESSION['cart'][$id] + $qty;
  5.         } else {
  6.             $_SESSION['cart'][$id] = $qty;
  7.         }
  8.         $this->SetCookie();
  9.         return true;
  10.     }

Por:

Código PHP:
Ver original
  1. function AddToBasket($id, $qty = 1) {
  2.  
  3.         if (isset($_SESSION['cart'][$id])) {
  4.             if (!is_array($_SESSION['cart'][$id])) $_SESSION['cart'][$id] = array();
  5.             $_SESSION['cart'][$id] = $_SESSION['cart'][$id] + $qty;
  6.         } else {
  7.             if (!is_array($_SESSION['cart'][$id])) $_SESSION['cart'][$id] = array();
  8.             $_SESSION['cart'][$id] = $qty;
  9.         }
  10.         $this->SetCookie();
  11.         return true;
  12.     }

Espero que a alguien le sirva. Saludos.
__________________
Por fin.. tengo algo parecido a un blog
Y por lo visto ya estoy escribiendo...