Jump to content

[Solved] Storing numbers as “firstname” or “lastname” for customers


Recommended Posts

I am pretty sure this is super simple…
We only sell to stores and we keep track of our customers by customer code (combination of letters and numbers)
I am importing our customer list into PS (using CSV) and using "Name field" for customer code (something like XYZ01)
I get error massage in process of importing because I am using the numerical character in name field.
Is there a simple way around that?
I was thinking of changing the “ps_customer” structure to allow numbers.
I am not sure what I have to change the “firstname” Type or Collation to; in order to allow storing numbers and letters combination that field.

Link to comment
Share on other sites

I think you will have to change class Cuatomer in file /classes/Customer.php

There is a validation type definition of fields array, so you need to do is change it to something else.

     protected     $fieldsValidate = array('secure_key' => 'isMd5', 'lastname' => 'isName', 'firstname' => 'isName', 'email' => 'isEmail', 'passwd' => 'isPasswd',
        'id_gender' => 'isUnsignedId', 'birthday' => 'isBirthDate', 'newsletter' => 'isBool', 'optin' => 'isBool', 'active' => 'isBool', 'note' => 'isCleanHtml', 'is_guest' => 'isBool');



you can just remove it from list to avoid validation

Link to comment
Share on other sites

Thanks for response.
You directed me into a correct direction (I assumed it get validated in sql) anyhow, I end up change it to:
“isGenericName” and now it works.
There is another validation in Address.PHP (inside class folder) that needs to be changed as well
So conclusion is per default PS installation it is not possible to have 50 cents as a customer :-)

Link to comment
Share on other sites

I found a better solution!
Under class folder file Validate.php, change:

    /**
   * Check for name validity
   *
   * @param string $name Name to validate
   * @return boolean Validity is ok or not
   */
   static public function isName($name)
   {
       return preg_match('/^[^0-9!<>,;?=+()@#"°{}_$%:]*$/u', stripslashes($name));
   }


To:

    /**
   * Check for name validity
   *
   * @param string $name Name to validate
   * @return boolean Validity is ok or not
   */
   static public function isName($name)
   {
       return preg_match('/^[^!<>,;?=+()@#"°{}_$%:]*$/u', stripslashes($name));
   }




Now I don’t have to look for “isName” in all my files and changed them manually :)

Link to comment
Share on other sites

×
×
  • Create New...