surreal5335
12-08-2010, 08:41 PM
I am building shopping cart class for my website and currently my addItems() function is undefined. Here is the code the function:
class shoppingCart
{
protected $items = array();
// adds $product_id to $items array()
public function AddItems($product_id)
{
if(array_key_exists($product_id, $this->items))
{
$this->items[$product_id] = $this->items[$products_id] + 1;
}
else
{
$this->items[$product_id] = 1;
}
}
}
Here is the code that is calling it:
// get_shopping_cart() is found in functions.php
// get_shopping_cart() creates a new shoppingCart() object
$shopping_cart = get_shopping_cart();
if(product_exists($product_id, $layout))
{
$shopping_cart->AddItems($product_id);
//echo 'product exits';
}
Here is the link to the page displaying the error I am getting:
http://paperlesswasp.com/millionaire/add_to_cart.php?id=01/marketing
Thanks a lot for the help
class shoppingCart
{
protected $items = array();
// adds $product_id to $items array()
public function AddItems($product_id)
{
if(array_key_exists($product_id, $this->items))
{
$this->items[$product_id] = $this->items[$products_id] + 1;
}
else
{
$this->items[$product_id] = 1;
}
}
}
Here is the code that is calling it:
// get_shopping_cart() is found in functions.php
// get_shopping_cart() creates a new shoppingCart() object
$shopping_cart = get_shopping_cart();
if(product_exists($product_id, $layout))
{
$shopping_cart->AddItems($product_id);
//echo 'product exits';
}
Here is the link to the page displaying the error I am getting:
http://paperlesswasp.com/millionaire/add_to_cart.php?id=01/marketing
Thanks a lot for the help