Hi, does anyone know how I can return the users surname as capitalize text? or even lowercase, as then I can use css to change it?
At the moment it would look like this, John SMITH and I need it to look like John Smith.
Thanks Ash
At the moment it would look like this, John SMITH and I need it to look like John Smith.
Thanks Ash
There is some code "somewhere" on these forums that will make you enter the namse normal instead of the PS way.
I never understand why PS wants the last names in CAPITAL, but hee, you cant have it all.
I never understand why PS wants the last names in CAPITAL, but hee, you cant have it all.
I need to display it in the user info areas in a "normal" way, not have it look like its being shouted at the user. It looks a lot better as Name Surname, than Name SURNAME!!!
How do you use that php function?
:)
How do you use that php function?
:)
Found it:
To remove auto capital on lastname you have to edit this files:
This will NOT change the names already in the database!
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!
From 1255013855:
Found it:
This will NOT change the names already in the database!
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.
I think this should be a standard feature.... or at least an option in the Back Office to enable this.
Here are the files I use for version 1.2.5.0. I have replaced strtoupper with ucfirst.
/Kjeld
/Kjeld
Attached Files
Great! I used ECK!'s idea and it seems to have worked like a charm.... all we need is for this to be a admin option in the next release!
I don't think you should do it the way Eck! suggests. "Tools::strtoupper" is used for other things than lastname.
/Kjeld
/Kjeld
Ahhh ok! ... Ill backout and replace the files with yours! Thanks!...
just need to make a note when the next update comes out I update the new code.
just need to make a note when the next update comes out I update the new code.
From 1259260749:
I don't think you should do it the way Eck! suggests. "Tools::strtoupper" is used for other things than lastname.
/Kjeld
/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)
Any chance this actually will make it into the next release? This may be the only negative thing I've encountered in Prestashop yet. :) It's an amazing package.
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;
}
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.
From 1255013855:
Found it:
To remove auto capital on lastname you have to edit this files:
This will NOT change the names already in the database!
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'); ?>



Back to top










