Welcome Guest, Not a member yet? Register   Sign In
Cart Library Reject any "bad" Character
#1

[eluser]edidiway[/eluser]
Hi. I have been frustated for an hour maybe because this bug.

I am building online shop website now, and you know, when I was testing it, I used 2 products for example..

The first product name was "Product 1" and the second was "Product #2"

and what happen if I add to cart?
"Product 1" will be inserted to the cart while in the other hand "product #2" will be never inserted to the cart..

can someone fix this problem? I have searched at google and no answer. There is 1 thread I have found, but no solution anyway.
this is the thread "http://ellislab.com/forums/viewthread/136051/#672421"

if there is no solution, I affraid that my client can not use "bad" character in inserting the product name
#2

[eluser]oppenheimer[/eluser]
As the post you referenced suggest, you can modify the cart class to your needs. It is system/library/cart.php. Modify line 31 (at least in my version) to add a pound sign.

Code:
var $product_name_rules    = '\.\:\-_ a-z0-9#';
#3

[eluser]edidiway[/eluser]
Hi oppenheimer, thanks.. this solution is very good Big Grin
#4

[eluser]davidbehler[/eluser]
Never modify a file in /system. It will be overwritten the next time you update CI. Instead you should extend the library in /application/libraries/cart.php. See the "Extending Native Libraries" section in the Guide if you don't know what I'm talking about.
#5

[eluser]WanWizard[/eluser]
Alternatively, just do
Code:
$this->load->library('cart');
$this->cart->product_name_rules = '\.\:\-_ a-z0-9';

But walmeisters suggestion is the preferred way.
#6

[eluser]edidiway[/eluser]
both waldmeister and wanwizard solutions are excellent I think. but in this case I will use from wanwizard, it is quite simple. But in certain case, waldmeister solution was a good one.
Very thanks to all for the solutions Smile




Theme © iAndrew 2016 - Forum software by © MyBB