I have this code that cause the error Call to a member function addItem() on a non-object at AddToCart : $this->cart_object->addItem, what is wrong?
Yii::import('application.extensions.faucart.faucart');
class Cart extends CFormModel {
private $cart_name = "MYFAUCART";
private $cart_object = null;
function __consruct() {
session_start();
$this->inSession();
parent::__consruct();
}
//gia arxikopiisi tis cartas
function inSession() {
if (isset($_SESSION[$cart_name]))
$this->cart_object = unserialize($_SESSION[$this->cart_name]);
else
$this->cart_object = new faucart();
}
//vazi sto session tis allages
function toSession() {
if (isset($_SESSION[$this->cart_name]))
unset($_SESSION[$this->cart_name]);
$_SESSION[$cart_name] = serialize($this->cart_object);
}
public function AddToCart($name,$comment,$price) {
$this->cart_object->addItem(new faucartelement($name,$comment,$price));
$this->toSession();
}...