Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Character issue on Cart Class #78

Closed
bitbucket-import opened this issue Aug 19, 2011 · 3 comments
Closed

Character issue on Cart Class #78

bitbucket-import opened this issue Aug 19, 2011 · 3 comments
Labels

Comments

@bitbucket-import
Copy link

Hello,

I was itching my head when I was trying out the cart class. Because some products was added nicely, but some wouldn't at all. Without any error.

After some head scratching I found out that this line is the problem for us that lives in scandinavia, and possibly many other countries.

var $product_name_rules = '\.\:\-_ a-z0-9'; // alpha-numeric, dashes, underscores, colons or periods

located in system/libraries/Cart.php

The reason is we use ÆØÅ in our product names and therefor it will fail.

So I suggest to add a config item that we can add local characters on and the CI_Cart can fetch those from there. Instead of "hacking the core". That's one option.

This is the working code for me.

var $product_name_rules = '\.\:\-_ a-zæøåÆØÅ0-9'; // alpha-numeric, dashes, underscores, colons or periods

Best regards
Anthoni Giskegjerde ( @antonigiske )

@michail1982
Copy link

Addon..
Cart not use unicode switch by testing product name
Thats case a need to use
var $product_name_rules = '.:-_ a-z0-9_-а-яА-Я';
instate of
var $product_name_rules = '.:-_ a-z0-9_-а-я';
woold be helpful to add unicode switch
if ( ! preg_match("/^[".$this->product_name_rules."]+$/ui", $items['name']))
and ability to set product_name_rules via config

@narfbg
Copy link
Contributor

narfbg commented Jul 18, 2013

Unicode support has already been added and the product_name_rules property is public, so you can easily alter the rule for non-latin characters. Furthermore, the rule has been changed to allow "word characters" instead of just 'a-z'.

@narfbg narfbg closed this as completed Jul 18, 2013
@ibadgore
Copy link

How about
/*
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;
}
*/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants