I'm trying out CodeIgniter's Shopping Cart Library for the first time. I've got all my sessions setup, and when I go to add an item to cart, it appears in $this->cart->contents(); So far so good. The add looks like this:
$data = array( 'id' => 1,
'qty' => 1,
'price' => 20,
'name' => "Item1");
$rowid = $this->cart->insert($data);
But when I try to add that same item again, it doesn't increase the quantity of that item in the cart. I imagined that performing that same insert would add one more, increasing the quantity of that row to 2, but it doesn't.
If I add a different product, it appears alongside the first. But again, attempts to add another of that product fail to increase the count.
I am certainly missing something. Perhaps you know what it is.
Many thanks!
I believe that just adding two of the item won't sum them together to get a new quantity.
You can actually update the cart with the new quantity [qty] value. See the "Updating the Cart" section of this page: http://codeigniter.com/user_guide/libraries/cart.html
Note: You will probably need to do the following:
$this->cart->product_options($rowid);
or by looping through all the items and finding the correct one with $this->cart->contents();
$rowid
with the new quantity valueHope that helps!