i am new to code-igniter. here i am using shopping cart for product checkout. when i am add product to cart it's working for first three products, after adding any product consider as fourth product. if any product add to cart after three products it will replace the existing fourth product. but only first three product display on cart, and the fourth one not display and also i cant add more than four products on cart, i am using jquery ajax for cart update
jquery ajax code
$('.addcart').click(function(){
var proid=$(this).attr('id');
$.post('<?php echo base_url()?>productajax',{typ:'addtocart',proid:proid},function(data){
})
return false;
})
product add to cart code
$proid=$this->input->post('proid');
$this->db->where('pro_id',$proid);
$data=$this->db->get('product')->result();
foreach ($data as $pro)
{
$proname=$pro->pro_name;
$price=$pro->s1price;
$proimg=$pro->image_name;
$nwt=$pro->case_netweight;
$gwt=$pro->case_grossweight;
$cbm=$pro->cbm;
}
$propriceinr =round($price + round(($price * $this->session->userdata('user_margin'))/100,2));
$dat = array(
'id' => $proid,
'qty' => 1,
'price' => $propriceinr,
'name' => $proname,
'options' => array('cbm' => $cbm, 'nwt' => $nwt,'gwt'=>$gwt,'image' => $proimg ,'price'=>$price,)
);
$this->cart->insert($dat);
config.php
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_expire_on_close'] = FALSE;
$config['sess_encrypt_cookie'] = FALSE;
$config['sess_use_database'] = FALSE;
$config['sess_table_name'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update'] = 300;
$config['csrf_protection'] = FALSE;
$config['csrf_token_name'] = 'csrf_test_name';
$config['csrf_cookie_name'] = 'csrf_cookie_name';
$config['csrf_expire'] = 7200;
i don't know the product cart why not update after insert three product. give me a guidance for this issue anyone. thanks advance