Contributions
Capitalize First Letter for Create Account Fields
This may be the simplest contribution ever. Many of our customers were to lazy to capitalize the first letter of the following fields :
First Name
Last Name
City
Business Name
Street Address
This drove me crazy, so, I fixed this for them on the fly using the ucwords() function.
-------------------
Example from create_account.php
To capitalize the first letter of the "first name" field:
FIND :
$firstname = tep_db_prepare_input($HTTP_POST_VARS['firstname']);
CHANGE TO :
$firstname = tep_db_prepare_input($HTTP_POST_VARS['firstname']);
$firstname = ucwords($firstname);
------------
Done! Simply do that for any field you wish to capitalize for your customers.
Expand All / Collapse All
So simple yet so complicated!
Converting last names is not such an easy task, what about all those MacDonalds that become Macdonalds or the Hyphen-Hyphens that become the Hyphen-hyphens or the van der Capitals that become the Van Der Capitals...
Have a look at this on php.net:
http://www.php.net/manual/en/function.ucwords.php
then scroll down a bit. The contributions from the Italians are pretty comprehensive but still in the end none of them work 100%...
Mind you all is well if you are a MacDonald but there again what about the Macallisters who then become the MacAllisters!
Thanks to the OP and others for adding to this. I was looking for just this modification and low and behold it's a simple change. There are several modules that need to be modified (those already mentioned below plus checkout_shipping_address.php) to catch all the places where a user might make a change to his name and address.
In addition to the name I also include the fields to proper case the street, city and state.
Here's the list of modules to update:
checkout_shipping_address.php
address_book_process.php
account_edit.php
create_account.php
Here's the code I added (note I added this below where all the current code is, right after then state and county code is:
$firstname = ucwords($firstname);
$lastname = ucwords(strtolower($lastname));
$street_address = ucwords(strtolower($street_address));
$city = ucwords(strtolower($city));
$state = strtoupper($state);
Note for account_edit.php you only need the first and last name.
In order for this to be complete you also should add the ucwords to the appropriate location inside of account_edit.php and address_book_process.php as well.
A nifty little tip from phi148
It only seemed to work for the first name only, so I had to add the code to
the last name also.
In catalog/create_account
Around line 23 change this:
$firstname = tep_db_prepare_input($HTTP_POST_VARS['firstname']);
$lastname = tep_db_prepare_input($HTTP_POST_VARS['lastname']);
to this:
$firstname = tep_db_prepare_input($HTTP_POST_VARS['firstname']);
$firstname = ucwords(strtolower($firstname));
$lastname = tep_db_prepare_input($HTTP_POST_VARS['lastname']);
$lastname = ucwords(strtolower($lastname));
To also get rid of those annoying ALL CAPS entries, use this:
$firstname = ucwords(strtolower($firstname))
This may be the simplest contribution ever. Many of our customers were to lazy to capitalize the first letter of the following fields :
First Name
Last Name
City
Business Name
Street Address
This drove me crazy, so, I fixed this for them on the fly using the ucwords() function.
-------------------
Example from create_account.php
To capitalize the first letter of the "first name" field:
FIND :
$firstname = tep_db_prepare_input($HTTP_POST_VARS['firstname']);
CHANGE TO :
$firstname = tep_db_prepare_input($HTTP_POST_VARS['firstname']);
$firstname = ucwords($firstname);
------------
Done! Simply do that for any field you wish to capitalize for your customers.
Note: Contributions are used at own risk.