Welcome Guest, Not a member yet? Register   Sign In
Problem with CodeIgniter Cart class
#1

[eluser]cysquan[/eluser]
Hello everyone, I'm having a little problem with the provided Cart class from CI

when I try to add a product that has name contains special character, the cart doesn't seem to work.

Code:
$data = array(  
                              'id'      => $id,  
                              'qty'     => '1',  
                              'price'   => $row->product_price_decimal,  
                              'name'    => "intel duo core"  
                      );
                 $this->cart->insert($data);

The code above is working with the name not contain any special character, however if I change the name to something similar to this (e.g 'name' => 'intel duo core 1/2') then the product is not added to cart.

How can I fix this?

Thanks in advance!
#2

[eluser]WanWizard[/eluser]
You will have to modify the product name rules: $this->cart->product_name_rules (a regex that is used to validate the name).

The default value is
Code:
$product_name_rules    = '\.\:\-_ a-z0-9'; // alpha-numeric, dashes, underscores, colons or periods
#3

[eluser]cysquan[/eluser]
Thanks a ton Big Grin
#4

[eluser]MikeeJay[/eluser]
And if you also would like to allow:

åäö ÅÄÖ é É

How should the regex look like?
#5

[eluser]WanWizard[/eluser]
Without having tried it: maybe this might be of some help: http://www.regular-expressions.info/unicode.html#prop. PHP uses the PRCE engine, which should support this.
#6

[eluser]Fabiano Shark[/eluser]
This worked for me:
Code:
$this->product_name_rules = '\d\D';


Isto resolve problemas de acentuação no carrinho de compras (cart) do codeigniter. Wink

Crédito: http://ellislab.com/forums/viewreply/811712/




Theme © iAndrew 2016 - Forum software by © MyBB