Jump to content

Return the surname from the DB as capitalize text


Recommended Posts

Found it:

To remove auto capital on lastname you have to edit this files:

admin/tabs/AdminAddresses.php
=> remove «style=“text-transform: uppercase;“» on:
<input type=“text” size=“33” name=“lastname” value=”’.htmlentities($this->getFieldValue($obj, ‘lastname’), ENT_COMPAT, ‘UTF-8’).’” style=“text-transform: uppercase;” > *

admin/tabs/AdminCustomers.php
=> remove «style=“text-transform: uppercase;“» on:
<input type=“text” size=“33” name=“lastname” value=”’.htmlentities($this->getFieldValue($obj, ‘lastname’), ENT_COMPAT, ‘UTF-8’).’” style=“text-transform: uppercase;” > *

admin/tabs/AdminEmployees.php
=> remove «style=“text-transform: uppercase;“» on:
<input type=“text” size=“33” name=“lastname” value=”’.htmlentities($this->getFieldValue($obj, ‘lastname’), ENT_COMPAT, ‘UTF-8’).’” style=“text-transform: uppercase;” > *

classes/Address.php
=> find this line and change to this: «$fields[‘lastname’] = pSQL($this->lastname);»

classes/Customer.php
=> find this line and change to this: «$fields[‘lastname’] = pSQL($this->lastname);»

classes/Employee.php
=> find this line and change to this: «$fields[‘lastname’] = pSQL($this->lastname);»



This will NOT change the names already in the database!

Link to comment
Share on other sites

Found it:

This will NOT change the names already in the database!


To change the data already in you will need to write an SQL update script or update it manually if there arent many entries.

An alternative method might be this (I havent tested this) - Open classes/Tools.php and round about line 726:

   static function strtoupper($str)
   {
       if (function_exists('mb_strtoupper'))
           return mb_strtoupper($str, 'utf-8');
       return strtoupper($str);
   }


Change to:

   static function strtoupper($str)
   {
       return ucwords(strtolower($str));
   }


This should now save surnames in the correct format.

Link to comment
Share on other sites

  • 1 month later...
  • 2 weeks later...
I don't think you should do it the way Eck! suggests. "Tools::strtoupper" is used for other things than lastname.

/Kjeld


Yes this is not best practice so can only be a quick temporary fix. A better solution would be to add my amended function as a different name into Tools.php eg: public static function lastname($str) and then perform a search (Dreamweaver CTRL-F) for "Tools::strtoupper", then change any calls that relate to "lastname" to "Tools::lastname" (theres only about 15 edits in the whole system)
Link to comment
Share on other sites

  • 1 month later...
  • 1 month later...

Correct code for UTF-8 (PrestaShop version 1.3 - file 'Tools.php')

    static function strtoupper($str)
   {
       if (is_array($str))
           return false;
/*        if (function_exists('mb_strtoupper'))
           return mb_strtoupper($str, 'utf-8');
       return strtoupper($str);
*/
       if (function_exists('mb_convert_case'))
           return mb_convert_case($str, MB_CASE_TITLE, "UTF-8");
       return $str;
   }

Link to comment
Share on other sites

  • 2 weeks later...

How to change the name and address fields to display first letter in capital? I have lot of customers typing in their own name as firstname lastname, I don't mind that but when I print the invoice or label I'd like to have the address label correctly printed. Tried to change it in css but the data are written t the DB as the user has typed.

Link to comment
Share on other sites

  • 2 months later...
Found it:

To remove auto capital on lastname you have to edit this files:

admin/tabs/AdminAddresses.php
=> remove «style=“text-transform: uppercase;“» on:
<input type=“text” size=“33” name=“lastname” value=”’.htmlentities($this->getFieldValue($obj, ‘lastname’), ENT_COMPAT, ‘UTF-8’).’” style=“text-transform: uppercase;” > *

admin/tabs/AdminCustomers.php
=> remove «style=“text-transform: uppercase;“» on:
<input type=“text” size=“33” name=“lastname” value=”’.htmlentities($this->getFieldValue($obj, ‘lastname’), ENT_COMPAT, ‘UTF-8’).’” style=“text-transform: uppercase;” > *

admin/tabs/AdminEmployees.php
=> remove «style=“text-transform: uppercase;“» on:
<input type=“text” size=“33” name=“lastname” value=”’.htmlentities($this->getFieldValue($obj, ‘lastname’), ENT_COMPAT, ‘UTF-8’).’” style=“text-transform: uppercase;” > *

classes/Address.php
=> find this line and change to this: «$fields[‘lastname’] = pSQL($this->lastname);»

classes/Customer.php
=> find this line and change to this: «$fields[‘lastname’] = pSQL($this->lastname);»

classes/Employee.php
=> find this line and change to this: «$fields[‘lastname’] = pSQL($this->lastname);»



This will NOT change the names already in the database!



Also one last occurance for the back office in admin/header.inc.php:

change:
<?php echo Tools::substr($cookie->firstname, 0, 1).'. '.htmlentities(Tools::strtoupper($cookie->lastname), ENT_COMPAT, 'UTF-8'); ?>


to:

<?php echo Tools::substr($cookie->firstname, 0, 1).'. '.htmlentities($cookie->lastname, ENT_COMPAT, 'UTF-8'); ?>

Link to comment
Share on other sites

  • 2 years later...
  • 2 years later...
×
×
  • Create New...