cmsphp 发表于 2011-6-10 07:48:38

关于购物车数组里name 为什么不能是中文? 在线等。

本帖最后由 cmsphp 于 2011-6-10 07:49 编辑

关于购物车数组里name 为什么不能是中文? 在线等。
$data = array(
                     'id'      => 'sku_123ABC',
                     'qty'   => 1,
                     'price'   => 39.95,
                     'name'    => 'T-Shir',
                     'options' => array('Size' => 'L', 'Color' => 'Red')
            );
                        //print_r($data);
                        //exit;
               $this->cart->insert($data);

要是把 'name'    => 'T-Shir',改成'name'    => '中国',

$data = array(
                     'id'      => 'sku_123ABC',
                     'qty'   => 1,
                     'price'   => 39.95,
                     'name'    => '中国',
                     'options' => array('Size' => 'L', 'Color' => 'Red')
            );
                        //print_r($data);
                        //exit;
               $this->cart->insert($data);
这样就不行了

jeongee 发表于 2011-6-10 09:17:58

老外写的,老外不用中文,老外没考虑到国际化。
所以老外在购物车类中用了正则来只允许名称含有数字字母以及下划线等,
所以你要使用,你得去扩展购物车类或者直接更改。
翻看源代码将是你最好的老师。

geomen 发表于 2011-6-10 10:00:29

http://codeigniter.org.cn/forums/forum.php?mod=viewthread&tid=8393&highlight=%E8%B4%AD%E7%89%A9%E8%BD%A6
遇到问题可以先搜索一下~
这CI站内搜索还是蛮强大的:D

cmsphp 发表于 2011-6-11 20:22:33

本帖最后由 cmsphp 于 2011-6-11 20:22 编辑

建立一个MY_Cart.php
application/libraries下

<?phpif ( ! defined('BASEPATH')) exit('No direct script access allowed');

class MY_Cart extends CI_Cart {
    function __construct() {
      parent::CI_Cart();
      $this->product_name_rules = '\d\D';
    }
}
页: [1]
查看完整版本: 关于购物车数组里name 为什么不能是中文? 在线等。