Ash Bryant Posted October 8, 2009 Share Posted October 8, 2009 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 Link to comment Share on other sites More sharing options...
Eck! Posted October 8, 2009 Share Posted October 8, 2009 Where are you displaying the text? You can use the PHP function ucwords() to acheive this. Link to comment Share on other sites More sharing options...
TropischBruin Posted October 8, 2009 Share Posted October 8, 2009 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. Link to comment Share on other sites More sharing options...
Ash Bryant Posted October 8, 2009 Author Share Posted October 8, 2009 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? Link to comment Share on other sites More sharing options...
TropischBruin Posted October 8, 2009 Share Posted October 8, 2009 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 More sharing options...
Eck! Posted October 9, 2009 Share Posted October 9, 2009 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 More sharing options...
Splash Posted November 26, 2009 Share Posted November 26, 2009 I think this should be a standard feature.... or at least an option in the Back Office to enable this. Link to comment Share on other sites More sharing options...
presta-dyr Posted November 26, 2009 Share Posted November 26, 2009 Here are the files I use for version 1.2.5.0. I have replaced strtoupper with ucfirst./Kjeld strtoupper.zip Link to comment Share on other sites More sharing options...
Splash Posted November 26, 2009 Share Posted November 26, 2009 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! Link to comment Share on other sites More sharing options...
presta-dyr Posted November 26, 2009 Share Posted November 26, 2009 I don't think you should do it the way Eck! suggests. "Tools::strtoupper" is used for other things than lastname./Kjeld Link to comment Share on other sites More sharing options...
Splash Posted November 26, 2009 Share Posted November 26, 2009 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. Link to comment Share on other sites More sharing options...
Eck! Posted December 9, 2009 Share Posted December 9, 2009 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 More sharing options...
SteveP Posted February 2, 2010 Share Posted February 2, 2010 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. Link to comment Share on other sites More sharing options...
Stanislav Novák Posted March 5, 2010 Share Posted March 5, 2010 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 More sharing options...
outlet.ee Posted March 19, 2010 Share Posted March 19, 2010 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 More sharing options...
JohnsonZA Posted May 22, 2010 Share Posted May 22, 2010 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 More sharing options...
Vinc3nzo Posted November 16, 2012 Share Posted November 16, 2012 Hi! for prestashop 1.5 you have solution? Link to comment Share on other sites More sharing options...
jimi007 Posted February 4, 2015 Share Posted February 4, 2015 Any solution for Prestashop 1.6 ? Link to comment Share on other sites More sharing options...
Recommended Posts