I have a PHP array, set up using
$this->cart = array();
Which is all ind and dandy except the array will not, no matter what i do, take new values, but only replaces the existing values with the new ones.
I've tried array_merge, array_push and others and the same thing happens but this is the code that should work.
$this->cart[]=$input;
The first time that is used, it say there's one item in the array "Array ( [0] => 1 " The second time it's used it will show this, replacing the first value "Array ( [0] => 2 ) "
Adding values are triggered by a form with pulling the ID and putting it into the array as the value
echo '<input type="hidden" name="addeditem" value="2">';
But no matter what code, it will not append the array, only replace it, any ideas. I have tried adding a key and value, as well as creating a second array and merging it in and nothing works.
The function to add to cart is this
function addToCart($input){
$this->cart[]=$input;
$this->setCartCount();
}
Solved: See comments.