Jump to content

Save First name and Last name of customer in Capitalize format


jimi007

Recommended Posts

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 etc

current

jamil ahmed

Target

Jamil Ahmed

I 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.

Thanks
I hope Its not difficult for experts

Link to comment
Share on other sites

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

  • 2 weeks later...

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

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

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

  • 11 months later...

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...