jimi007 Posted February 4, 2015 Share Posted February 4, 2015 Hi,I have Prestashop 1.6 and I am trying to save first name and last name of customer in capitalize format in database. so its will look good every where e.g PDF, emails etccurrentjamil ahmedTargetJamil AhmedI have achieve this with CSS and jQuery but its only working on front-end and not saving it in database so it will work everywhere as I need.Can any expert guide me which file or classes,temple or controller I need to edit so when ever user create account or update his information then first name and last name will save in capitalize format.ThanksI hope Its not difficult for experts Link to comment Share on other sites More sharing options...
tuk66 Posted February 5, 2015 Share Posted February 5, 2015 Try to use actionObjectAddBefore hook and change form fields before saving. Inside the hook use something like: $my_field = Tools::ucfirst($my_field); Link to comment Share on other sites More sharing options...
jimi007 Posted February 5, 2015 Author Share Posted February 5, 2015 Many Thanks for help... I am not an expert developer so I will be very thankful to you if you can guide me where should I paste above code... otherwise no problem Link to comment Share on other sites More sharing options...
las3r Posted February 6, 2015 Share Posted February 6, 2015 Many Thanks for help... I am not an expert developer so I will be very thankful to you if you can guide me where should I paste above code... otherwise no problem This is not a simple copy paste. Maybe for us developers, but not for you as a store owner. You have these options: 1) Create a module for this (as @tuk66 mentions) - you will need programming experience 2) Change some code straight in the prestashop code and hope it works. On every update of the store software you'll have to redo this since the changes will be overwritten. Example for (2): If you'd use javascript in stead of css, this would automatically change the first letter to a capital (if it isn't a capital), the form will be saved properly. Sample defined below (note: this uses jQuery) Example: http://jsfiddle.net/9zPTA/31/ Link to comment Share on other sites More sharing options...
zombie process Posted February 7, 2015 Share Posted February 7, 2015 (edited) You could override the customer class and modify the constructor: public function __construct($id = null) { parent::__construct($id); if ($this->id) { $this->firstname = Tools::ucfirst($this->firstname); $this->lastname = Tools::ucfirst($this->lastname ); } } Edited February 7, 2015 by zombie process (see edit history) Link to comment Share on other sites More sharing options...
Sam Minerve Posted February 17, 2015 Share Posted February 17, 2015 Hi, I'd like to do the same for the city name. So, in the Address class, I modified the constructor by adding : $this->city = Tools::ucwords($this->city); But, it doesn't work. Any idea, please ? Thank you. Link to comment Share on other sites More sharing options...
tuk66 Posted February 18, 2015 Share Posted February 18, 2015 The constructor is maybe a wrong place. Link to comment Share on other sites More sharing options...
zombie process Posted February 18, 2015 Share Posted February 18, 2015 Well, this should work. can you post the constructor? Link to comment Share on other sites More sharing options...
Sam Minerve Posted February 18, 2015 Share Posted February 18, 2015 Thank you guys for your replies. So, in the Address class, around line 156 to 163, you have this code : public function __construct($id_address = null, $id_lang = null) { parent::__construct($id_address); /* Get and cache address country name */ if ($this->id) $this->country = Country::getNameById($id_lang ? $id_lang : Configuration::get('PS_LANG_DEFAULT'), $this->id_country); } I changed it to : public function __construct($id_address = null, $id_lang = null) { parent::__construct($id_address); /* Get and cache address country name */ if ($this->id) { $this->country = Country::getNameById($id_lang ? $id_lang : Configuration::get('PS_LANG_DEFAULT'), $this->id_country); $this->company = Tools::ucwords($this->company); } Link to comment Share on other sites More sharing options...
Sam Minerve Posted February 18, 2015 Share Posted February 18, 2015 Sorry, my post is wrong, I start again. Link to comment Share on other sites More sharing options...
Sam Minerve Posted February 18, 2015 Share Posted February 18, 2015 So, I changed the code to : public function __construct($id_address = null, $id_lang = null) { parent::__construct($id_address); /* Get and cache address country name */ if ($this->id) { $this->country = Country::getNameById($id_lang ? $id_lang : Configuration::get('PS_LANG_DEFAULT'), $this->id_country); $this->city = Tools::ucwords($this->city); } } Link to comment Share on other sites More sharing options...
zombie process Posted February 18, 2015 Share Posted February 18, 2015 it's Tools::ucfirst Link to comment Share on other sites More sharing options...
Sam Minerve Posted February 19, 2015 Share Posted February 19, 2015 Thank you Zombie process. (En fait, je viens de me rendre compte qu'avec Tools::ucwords, ça fonctionnait également. J'avais cru le contraire car le nom de la ville apparaissait effectivement en minuscule dans le back-office à l'onglet Clients -> Adresses. Mais lorsqu'on clique sur la ligne du client en question pour afficher le détail, là, on voit le nom avec une majuscule. Bizarre... Mais bon, mon problème est résolu. Merci !) Link to comment Share on other sites More sharing options...
Alexandre 001 Posted January 22, 2016 Share Posted January 22, 2016 Hello. I post for find same solution in prestashop 1.6.4. Can you help me, because I'm not developper and I don't want to break thomething. The second thing is that I also use a link to my ebay shop prestashop store. Suddenly accounts are imported without going through the PrestaShop form. Is there a way to force uppercase directly into the database ?Thank you Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now