Ok so I looked at my code and by having a var_dump() just before the AddItems() method call, I got this:
array(1) { [0]=> string(12) "01/marketing" }
bypassing the function I get this:
object(shoppingCart)#1 (1) { ["items: protected"]=> array(0) { } }
So clearly my problem is my get_shopping_cart() function and I will bet the $_SESSION is the culprit.
Based on my get_shopping_cart() function:
PHP Code:
function get_shopping_cart()
{
// $_SESSION is a means for working with cookies
// shopping carts hold temporary data with cookies
if(!isset($_SESSION['cart']))
{
// creates new shoppingCart() object from classes/shoppingCart.php
return new shoppingCart();
}
else
{
// unserialize essentially "unzips" an object from memory for use
return unserialize($_SESSION['cart']);
}
}
this would mean my $_SESSION is being prematurely set, thus skipping the instructions to create a new object and go to unserialize the session.
I have a set_shopping_cart() function which is found at the bottom of the page calling all these functions:
PHP Code:
function set_shopping_cart($cart)
{
$_SESSION['cart'] = serialize($cart);
}
This is the only place I know of that would set a session. I commented it out to see what I would get and no change was made.