CodeIgniter Forums
Shopping Cart library 5 item limit, weird problem - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Shopping Cart library 5 item limit, weird problem (/showthread.php?tid=37454)



Shopping Cart library 5 item limit, weird problem - El Forum - 01-10-2011

[eluser]cityzen[/eluser]
Hey Everyone -

I'm using the CI cart library and it seems to work fine but after I had 5 items it just craps out. Even if I remove an item it won't let me add another. I have to remove all of the items or destroy the cart to get it working again. I can't, for the life of me, figure out what is going on. I have tried loading up an array with multiple items and that doesn't work either. Any ideas of where to even start sorting this out would be appreciated.

Thanks in advance!

Mike


Shopping Cart library 5 item limit, weird problem - El Forum - 01-10-2011

[eluser]Cristian Gilè[/eluser]
Hi cityzen, provide us your code.

Cristian Gilè


Shopping Cart library 5 item limit, weird problem - El Forum - 01-10-2011

[eluser]cityzen[/eluser]
Thanks for the fast reply...

*I just did some crossbrowser testing before I replied and it seems to work fine on Safari and Firefox so the issue seems to be Chrome, unfortunately*

I've been doing more testing and thought I confirmed that my items were limited to 5 but somehow got six into the cart somehow (cannot replicate this). This code is used to add a sample of a product to a cart. The fetch method is grabbing the info.

Code:
function add_sample()
    {
    
        $sample = $this->Product_model->fetch('variation', $this->uri->segment(3));
        
        $sample_price = ($sample[0]->sample_price > 0) ? $sample[0]->sample_price : $this->sample_price;
        
        $data = array(
            'id'    => 'SMPL-' . $sample[0]->id,
            'qty'    => 1,
            'price'    => $sample_price,
            'name'    => 'Product Sample'
        );
        
        $this->cart->insert($data);
        
        header('Location: /cart/');
    
    }

While testing I set up a page where I was adding items to the cart and echoing out the $this->session->userdata('cart_contents'); and it seems like after the 5th product, all new products just replace the last one.


Shopping Cart library 5 item limit, weird problem - El Forum - 01-10-2011

[eluser]cideveloper[/eluser]
Are you using a database to store session data or cookie? cookie has a size limitation. This is a common problem people have.


Shopping Cart library 5 item limit, weird problem - El Forum - 01-10-2011

[eluser]cityzen[/eluser]
Just switched over to database, seems much more reliable. Thanks for the feedback.