I’m testing adding items to the shopping cart like this:
$item = $this->model->getSingleItem();
for($i = 0; $i < 11; $i++) {
$this->cart->insert(array(
'id' => $item->id++,
'qty' => 1,
'price' => 1,
'name' => $item->title
));
}
However, the above loop only adds 10 items to the shopping cart. Even if I modify the loop above to run 20 times, I still get only 10 items in the cart. Is this a known bug, or am I doing something wrong?
Doing echo count($this->cart->contents()); always shows a count of 10 or less. Never more.
I’m using CI 2.1.2. If someone can confirm they don’t face this issue in a previous version, perhaps I can use the cart class from an older version of CI.
Ok, figured it out. The reason I was unable to store more than 10 items is because I was hitting the limit on cookie size (CI sessions are stored as cookies). I changed my config to use databases for sessions, and this issue went away.