在codeigniter为同一项添加两个价格

时间:2013-08-09 06:46:21

标签: php codeigniter session cart

我想在codeigniter中为同一项添加两个价格。但是在codeigniter购物车功能只有一个价格可用。我需要单独插入INR价格和美元价格。我怎样才能做到这一点 ?我坚持过去8个小时,请清除我任何一个

购物车添加商品的正常代码

$proid=$this->input->post('pid');
                $this->db->where('pid',$pid);
                $data=$this->db->get('product')->result();
                foreach ($data as $pro)
                {
                    $proname=$pro->pro_name;
                    $salb1=$pro->s1price;
                    $salb2=$pro->s2price;
                    $salb3=$pro->s3price;
                    $salb4=$pro->s4price;
                    $proimg=$pro->image_name;
                    $nwt=$pro->case_netweight;
                    $gwt=$pro->case_grossweight;
                    $cbm=$pro->cbm;
                }

                switch ($this->session->userdata('buser_slab'))
                {
                    case 1:
                        $price = $salb1;
                    break;
                    case 2:
                        $price = $salb2;
                    break;
                    case 3:
                        $price = $salb3;
                    break;
                    case 4:
                        $price = $salb4;
                    break;
                }

                $propriceinr =round($price + round(($price * $this->session->userdata('margin'))/100,2));   


                $dat = array(
               'id'      => $pid,
               'qty'     => 1,
               'price'   => $propriceinr,
               'name'    => $proname,
               'options' => array('cbm' => $cbm, 'nwt' => $nwt,'gwt'=>$gwt,'image' => $proimg ,'price'=>$price)
            );              
                $this->cart->insert($dat); 

0 个答案:

没有答案