Welcome Guest, Not a member yet? Register   Sign In
Help - Shopping cart fails to add item.
#1

[eluser]Frank Rocco[/eluser]
Hello,

The item fails when the description has a / in it.
example: B/S INSIGNIA

$row->Item_description = "B/S INSIGNIA"
$data = array(
'id' => $row->Item,
'qty' => $qty,
'price' => $row->List_price,
'name' => $row->Item_description
);

$this->cart->insert($data);

if I remove the /, it saves ok.
$row->Item_description = "BS INSIGNIA"
Thanks

CI 1.7.2
#2

[eluser]christophe2[/eluser]
Hello,

I have the same problem. I didn't find a way to add the slash to the $product_name_rules variable of the cart class even though I anti-slashed it. I had to remove the entire product name validation.

Christophe
#3

[eluser]aggiaggiaggiaggi[/eluser]
same here, there are a number of other chars which prevent products to go in the cart, like ' and !

heres a simple solution.

just add your products with the following code:

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

This allows all printable characters in the product name.

@codeigniter coders: i think this should be made default, just allowing _ . : is not enough
#4

[eluser]christophe2[/eluser]
It works nicely. Thanks for sharing your solution.
Christophe
#5

[eluser]Frank Rocco[/eluser]
Thanks for the help.

Regards,

Frank
#6

[eluser]Chalda Pnuzig[/eluser]
Thanks!

[quote author="aggiaggiaggiaggi" date="1266331057"]
@codeigniter coders: i think this should be made default, just allowing _ . : is not enough[/quote]
#7

[eluser]Brayan[/eluser]
Hey ..

Sorry for revive the topic.. but this code

Code:
$this->cart->product_name_rules = '[:print:]';

only work for names with slashes

I need to add products that have latin characters.. like áÓãoâê .. etc.

anyone knows how to do that?

thanks
#8

[eluser]aggiaggiaggiaggi[/eluser]
well, not tested, but in theory, you should always be able to use '.*' which allows *every* character. (or maybe [.], one of the two should work)
#9

[eluser]Brayan[/eluser]
[quote author="aggiaggiaggiaggi" date="1269276570"]well, not tested, but in theory, you should always be able to use '.*' which allows *every* character. (or maybe [.], one of the two should work)[/quote]

thank you.. but this doesn't work.
I commented these lines (validation in the cart library):

Code:
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;
        }

so now I can add any products, this is a good way for me, 'cause the name of products are already in database.. so NVM Big Grin

cheers.
#10

[eluser]skunkbad[/eluser]
I've never seen [:print:] used before. Is this a CI thing, or PHP? Got more info?




Theme © iAndrew 2016 - Forum software by © MyBB