Welcome Guest, Not a member yet? Register   Sign In
can't add more than 5 different items to the cart :/
#1

[eluser]dazamate[/eluser]
Hi there ,

I am working on this site at the moment www.bodmaster.com, and I can't add more than 5 different type of items to the cart. I am still fairly new to CI and I am not sure how to go about debugging this one.

here is the code which adds items to the cart class.

Code:
class cart extends CI_controller

{
  function index()
   {
     //load the model 'products_model'
    $this->load->model('Products_model');
    
    //call the get all function form the model to
    //get all product information
    $data['products'] = $this->Products_model->Get_all();
    
    //pass all product informaton to the shop view
    $this->load->view('shop_view', $data);
   }
  
  function add()
   {
     //load product model to get data from db
    $this->load->model('Products_model');
    
    //call the get function and pass the product id
    //to extract all product data from the db
    $product = $this->Products_model->Get($this->input->post('id'));
    
    //create the array for the insert method
    $insert = array(
      'id'=> $this->input->post('id'),
      'name'=> $product->name,
      'qty'=> $this->input->post('qty'),
      'price'=> $product->price,
      'img'=>$product->img,
      'brand'=>$product->brand
    
    );
}

As you will see you can add and remove items from the cart until you get to 5 and then it just won't add anymore.

Does anyone have any suggestions on where to look to isolate this problem.

Let me know if you want to see any more deeper code.

Thank you , much appreciated.
#2

[eluser]fatangel26[/eluser]
Is there mistake "Bad ReQuest" ?. If true, you do ci_session database.
#3

[eluser]skunkbad[/eluser]
Are you using cookie based sessions or database based sessions? If database, try adjusting the datatype of the userdata. If cookie, are you encrypting the session? If so, you may need to change the encryption type to something that doesn't take up so much space. I use blowfish.
#4

[eluser]dazamate[/eluser]
Hey guys, I am just using the cookie session. I also noticed when I fill up the cart with 5 items some other session data starts to play up. I will adjusting the encryption.

Is there a size limit to your cookie is there?, Is there a way to increase it. Also is there a way NOT to use cookies and just use database sessions instead? I read that if enable database sessions that it still uses cookies but just keeps comparing it with the database table for a match. If there is no match the session is destroyed. Is that correct?
#5

[eluser]kanjimaster[/eluser]
Yes, cookie size is limited and e-commerce is one of the applications that will typically blow those limits very quickly.

I strongly recommend that you read the user guide section on the session class, Towards the bottom you'll find that you can set a config flag to the use the database rather than cookies, but there's a lot more in there that's worth reading and noting.




Theme © iAndrew 2016 - Forum software by © MyBB