duanfenhui5511 2013-06-20 09:21
浏览 43
已采纳

codeigniter插入数据的购物车问题

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

  • 写回答

2条回答 默认 最新

  • doukui4786 2013-06-20 12:09
    关注

    Please set

    $config['sess_use_database'] = FALSE;

    to $config['sess_use_database'] = TRUE; in your config.php.

    Right now your products details are being saved in cookie which has the maximum limit of 4kb.
    By enabling $config['sess_use_database'] = TRUE;.

    This feature lets you insert your information in database table i.e:

    $config['sess_table_name'] = 'ci_sessions';.

    Hope that will work for you

    If you dont have ci_sessions table here is the query for that:

     CREATE TABLE `ci_sessions` (
     `session_id` varchar(40) NOT NULL DEFAULT '0',
     `ip_address` varchar(16) NOT NULL DEFAULT '0',
     `user_agent` varchar(50) NOT NULL,
     `last_activity` int(10) unsigned NOT NULL DEFAULT '0',
    `user_data` text NOT NULL,
    PRIMARY KEY (`session_id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 三相直流充电模块对数字电源芯片在物理上它必须具备哪些功能和性能?
  • ¥30 数字电源对DSP芯片的具体要求
  • ¥20 antv g6 折线边如何变为钝角
  • ¥30 如何在Matlab或Python中 设置饼图的高度
  • ¥15 nginx中的CORS策略应该如何配置
  • ¥30 信号与系统实验:采样定理分析
  • ¥100 我想找人帮我写Python 的股票分析代码,有意请加mathtao
  • ¥20 Vite 打包的 Vue3 组件库,图标无法显示
  • ¥15 php 同步电商平台多个店铺增量订单和订单状态
  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别