Welcome Guest, Not a member yet? Register   Sign In
Shopping Cart library 5 item limit, weird problem
#1

[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
#2

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

Cristian Gilè
#3

[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.
#4

[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.
#5

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




Theme © iAndrew 2016 - Forum software by © MyBB