• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cart Class - Products with brackets included in the name dont get added

#1
[eluser]alan-tucker[/eluser]
I have noticed that product that have brackets included in them dont get added to the basket.

Any ideas?

Code:
array(
'id'      => 'sku_567ZYX',
'qty'     => 1,
'price'   => 9.95,
'name'    => 'Coffee Mug (Small)',
'options' => ''
),

#2
[eluser]brianw1975[/eluser]
Take a look at your logs and see if you find "An invalid name was submitted as the product name: '.$items['name'].' The name can only contain alpha-numeric characters, dashes, underscores, colons, and spaces'"

I took a look at the code and found the following info in the _insert function

Code:
// Validate the product name. It can only be alpha-numeric, dashes, underscores, colons or periods.
        // Note: These can be user-specified by setting the $this->product_name_rules variable.
        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;

appears that the cart class documentation needs a bit of work...

#3
[eluser]alan-tucker[/eluser]
Yea I updated the following:

From

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


To

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

#4
[eluser]brianw1975[/eluser]
a lot of people may have to make the same update if they have already existing tables of items that don't have separate tables of options -- in your instance Small would be an option and used in the options section of the array - but I assume that the item_name is already existing and that there are multiple item ids for a shirt like shirt (small), shirt (medium), shirt (large)

#5
[eluser]mikegniewosz[/eluser]
Thanks for this. I spent too much time trying to figure out why my items weren't being added to the cart. What are the security risks of adding other characters?

#6
[eluser]darkhouse[/eluser]
I'm going through this same issue. I've got products with French characters, and I really don't want to have to add every possible character to the list. I'm wondering what the purpose of this is in the first place, it's just a name. I'm thinking I might just remove the whole thing that checks the item names altogether. I know it would solve my immediate problem, but I'm not sure what issues I could run into in the future. Any thoughts?


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.