我是代码点火器的新手。在这里,我正在使用购物车进行产品结帐。当我将产品添加到购物车时,它适用于前三种产品,在添加任何产品后视为第四种产品。如果任何产品在三个产品之后添加到购物车,它将替换现有的第四个产品。但购物车上只显示前三个产品,第四个不显示,而且我不能在购物车上添加超过四个产品,我正在使用 jquery ajax 进行购物车更新
jquery ajax 代码
$('.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['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;
我不知道产品购物车为什么在插入三个产品后不更新。任何人都给我这个问题的指导。提前感谢