heping45 发表于 2011-6-22 19:57:47

$this->load->library('cart3');
$data = array(
       'id'      => $product['id'],
        'qty'   => $num,
        'price'   => $product['price'],
        'name'    => $product['name'],
       'options' => array( 'weight' => $product['weight'],'is_group' =>$is_group )
);
$this->cart3->insert($data);

VIEW里面
<?php foreach($this->cart3->contents() as $items): ?>
   <?php echo $items['qty']; ?>
<?php endforeach; ?>

是不是用的时候错了


heping45 发表于 2011-6-22 20:07:45

                $this->load->library('cart3');
          $data = array(
                           'id'      => $product['id'],
                           'qty'   => 2,
                           'price'   => $product['price'],
                           'name'    => $product['name'],
                           'options' => array( 'weight' => $product['weight'],'is_group' =>1 )
                        );

          $this->cart3->insert($data);
echo round($this->cart3->total(),2);

以上调运后,结果显示为0

heping45 发表于 2011-6-22 20:24:30

在线等待,确实挺郁闷的。

heping45 发表于 2011-6-22 20:35:06

好像CI成了负担,怎么会有这样的感觉!?碰到问题还不要解决!还请版主帮忙在看看,谢谢!

heping45 发表于 2011-6-22 20:57:52

找到问题了,是这个位置被赋false。没法insert。把这个判断条件去掉就OK了,奇怪了!?
                // --------------------------------------------------------------------
       
                // Validate the product name. It can only be alpha-numeric, dashes, underscores, colons or periods.
                // Note: These can be user-specified by setting the $this->product_name_rules variable.
//                if ( ! preg_match("/^[".$this->product_name_rules."]+$/i", $items['name']))
//                {

//                        log_message('error', 'An invalid name was submitted as the product name: '.$items['name'].' The name can only contain alpha-numeric characters, dashes, underscores, colons, and spaces');
//                        return FALSE;
//                }

jeongee 发表于 2011-6-22 20:59:26

本帖最后由 jeongee 于 2011-6-22 21:00 编辑

heping45 发表于 2011-6-22 20:57 static/image/common/back.gif
找到问题了,是这个位置被赋false。没法insert。把这个判断条件去掉就OK了,奇怪了!?
                // ------------- ...
呵呵,name还有中文了?我之前精简了这个购物车类,呵呵

heping45 发表于 2011-6-22 21:14:24

在哪儿?提供下,我看看!我直接把他给删了。哈哈问题是暂时决绝了!

jeongee 发表于 2011-6-22 22:16:37

heping45 发表于 2011-6-22 21:14 static/image/common/back.gif
在哪儿?提供下,我看看!我直接把他给删了。哈哈问题是暂时决绝了!

呵呵,如果你想要,明天上班时间问我要吧,在公司的电脑上呢

baiyuxiong 发表于 2011-6-23 14:48:50

多个购物车很好搞啊
购物车里面不是有个option的选项吗?在option里面定义一个属性,比如:cart_no就可以了。

小CI 发表于 2013-5-16 10:46:54

:Q 这个 session key值改哪个呢
页: 1 [2]
查看完整版本: 如何建立多个购物车啊?