Why codeigniter shopping cart class doesn't allow any special character in the name? Why codeigniter shopping cart class doesn't allow any special character in the name? codeigniter codeigniter

Why codeigniter shopping cart class doesn't allow any special character in the name?


If you look on Cart.php you will see on line 31 var $product_name_rules = '\.\:\-_ a-z0-9';.

A nice way to change this variable is putting a MY_Cart.php on your application\libraries\MY_Cart.php with this code:

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');class MY_Cart extends CI_Cart {    var $product_name_rules = '[:print:]';}

Or you can also modify it when you add the product, using:

$this->cart->product_name_rules = '[:print:]';$this->cart->insert(array());


I just found this question from google while facing the same problem, but the answer ipalaus provided didn't fix my problem, because it still does not allow greek characters. After some more digging I found this :

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');class MY_Cart extends CI_Cart {    var $product_name_rules = '\d\D';}

which basically allows everything. Enjoy!


You can also optionally just modify the regular expression to allow quotes like so:

$this->cart->product_name_rules = "\.\:\-_\"\' a-z0-9";