0

I faced an issue that I cannot add item to cart if it contain cyrillic name. In Cart.php I added to variable symbols а-я:

var $product_name_rules = 'абвгдеёжзийклмнопрстуфхцчшщъыьэюя\.\:\-_ a-z0-9';

But it not resolved issue. When I changed an item name to latin it is added to cart.

doitlikejustin
  • 6,293
  • 2
  • 40
  • 68
user2027175
  • 83
  • 3
  • 10
  • it seems that it works : $product_name_rules = '\p{Cyrillic}\.\:\-_ a-z0-9'; preg_match("/^[". $product_name_rules."]+$/iu", $items['name']); – user2027175 Sep 16 '13 at 08:12
  • it return аЙбббб? ,but must йяюэъ ??? – user2027175 Sep 16 '13 at 08:21
  • for last comment it return correct string, but I don't set encoding for browser so that's why I get string in another encoding. However I still get error in Cart. – user2027175 Sep 16 '13 at 08:55

1 Answers1

1

You should add unicode flag to pregmatch in _insert function:

if ( ! preg_match("/^[".$this->product_id_rules."]+$/iu", $items['id']))

and

if ( ! preg_match("/^[".$this->product_name_rules."]+$/iu", $items['name']))

There is good article about this issue: http://wwarlock.blogspot.ru/2010/03/codeigniter.html

CodingFeles
  • 374
  • 5
  • 18