Please note that PrestaShop Community sections are largely self-moderated. PrestaShop team members may or may not participate in non-English sections. To improve the chances of receiving feedback to your question or comment, please post it in English to the main sections of our Forum.

Vous parlez français ? par ici !
Return the surname from the DB as capitalize text
#1 Guest_Ash Bryant_*
Posted 08 October 2009 - 10:47 AM
At the moment it would look like this, John SMITH and I need it to look like John Smith.
Thanks Ash
#2 Guest__*
Posted 08 October 2009 - 03:07 PM
#3 Guest__*
Posted 08 October 2009 - 03:18 PM
I never understand why PS wants the last names in CAPITAL, but hee, you cant have it all.
#4 Guest__*
Posted 08 October 2009 - 03:20 PM
How do you use that php function?
:)
#5 Guest__*
Posted 08 October 2009 - 03:57 PM
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!
#6 Guest__*
Posted 09 October 2009 - 11:16 AM
From 1255013855:
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.
#7 Guest__*
Posted 26 November 2009 - 06:09 PM
#8 Guest__*
Posted 26 November 2009 - 07:31 PM
/Kjeld
Attached File(s)
strtoupper.zip (12bytes)
Number of downloads: 192
#9 Guest__*
Posted 26 November 2009 - 07:34 PM
#10 Guest__*
Posted 26 November 2009 - 07:39 PM
/Kjeld
#11 Guest__*
Posted 26 November 2009 - 07:40 PM
just need to make a note when the next update comes out I update the new code.
#12 Guest__*
Posted 09 December 2009 - 12:58 PM
From 1259260749:
/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)
#13 Guest__*
Posted 02 February 2010 - 04:57 AM
#14 Guest__*
Posted 05 March 2010 - 04:38 PM
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;
}
#15 Guest__*
Posted 19 March 2010 - 02:13 PM
#16 Guest__*
Posted 22 May 2010 - 12:09 PM
From 1255013855:
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'); ?>
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











