Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have a question just like in the title - Why codeigniter shopping cart class doesn't allow any special character in the name? When I'm adding some item with normal name containing only standard characters it works like charm. However if I add something like, say, "word / word" or something like that it won't add anything to the shopping cart. Can someone provide me with some hints on that one please?

like image 559
Pavel Avatar asked Sep 27 '10 07:09

Pavel


1 Answers

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());
like image 58
ipalaus Avatar answered Sep 29 '22 18:09

ipalaus