Code: Select all
$fullname = ucwords(strtolower($fullname));
$lastname = ucfirst(strtolower($lastname));
I don't think that MySQL has such a string function, although it would be easy to write one; that aside, you could do it in SQL by, for example, replacing:
Code: Select all
lastname
Code: Select all
CONCAT(UCase(Left(`lastname`, 1)),LCase(Right(`lastname`,Length(`lastname`)-1)))
Code: Select all
UPDATE customer SET
`firstname` = CONCAT(UCase(Left(`firstname`, 1)),LCase(Right(`firstname`,Length(`firstname`)-1))),
`lastname` = CONCAT(UCase(Left(`lastname`, 1)),LCase(Right(`lastname`,Length(`lastname`)-1)));
Free v1.4.9 Extensions: Default Specials | Improved Search | Customer Activity Report | Customer Groups | Royal Mail With Handling | Improved Product Page | Random Products | Stock Report | All Products
I can't think of any situation where I would want to display 'eDwaRD lONGshaNKS' (which some customers seem to favour) so it might as well be corrected before it is databased.
I guess 'Simon de Montford' might raise small objection to being called 'Simon De Montford' but rather that than having all reports, emails, invoices, mailshots looking like they were produced by an eight year old.
Free v1.4.9 Extensions: Default Specials | Improved Search | Customer Activity Report | Customer Groups | Royal Mail With Handling | Improved Product Page | Random Products | Stock Report | All Products
I would really appreciate it if someone could show exactly how in which files because i am sure i would mess it up.
Thanks,
Roger
backup first...
in catalog/model/account/customer.php
add this
Code: Select all
$fname = ucwords(strtolower($data['firstname']));
$lname = ucwords(strtolower($data['lastname']));
Code: Select all
public function addCustomer($data) {
Code: Select all
$this->db->escape($data['firstname'])
Code: Select all
$this->db->escape($fname)
Code: Select all
$this->db->escape($data['lasttname'])
Code: Select all
$this->db->escape($lname)
If you want the customer to see this as they type on the registration form
in catalog/view/theme/default/template/account/create.tpl
find this
Code: Select all
<input type="text" name="firstname" value="<?php echo $firstname; ?>" />
Code: Select all
<input type="text" style="text-transform: capitalize;" name="firstname" value="<?php echo $firstname; ?>" />
Code: Select all
<input type="text" name="lastname" value="<?php echo $lastname; ?>" />
Code: Select all
<input type="text" style="text-transform: capitalize;" name="lastname" value="<?php echo $lastname; ?>" />
Save yourself a lot of work and additional variables by just changing the existing variablebillyggla wrote:Code: Select all
$fname = ucwords(strtolower($data['firstname'])); $lname = ucwords(strtolower($data['lastname']));
Code: Select all
$data['firstname'] = ucwords(strtolower($data['firstname']));
$data['lastname'] = ucwords(strtolower($data['lastname']));
I can't understand why such a simple change with such a benefitial effect wasn't included in the core to the point that I haven't bothered to make any similar suggestions.
Free v1.4.9 Extensions: Default Specials | Improved Search | Customer Activity Report | Customer Groups | Royal Mail With Handling | Improved Product Page | Random Products | Stock Report | All Products
Where exactly do I need to add the code to stop new poorly formatted ones from getting added?
It would be great if this could be extended to include address fields.
Thanks as always,
Roger
Change:
Code: Select all
public function addCustomer($data) {
Code: Select all
public function addCustomer($data) {
$data['firstname'] = ucwords(strtolower($data['firstname']));
$data['lastname'] = ucwords(strtolower($data['lastname']));
$data['company'] = ucwords(strtolower($data['company']));
$data['address_1'] = ucwords(strtolower($data['address_1']));
$data['address_2'] = ucwords(strtolower($data['address_2']));
$data['city'] = ucwords(strtolower($data['city']));
$data['postcode'] = strtoupper($data['postcode']);
Free v1.4.9 Extensions: Default Specials | Improved Search | Customer Activity Report | Customer Groups | Royal Mail With Handling | Improved Product Page | Random Products | Stock Report | All Products
Aside from the customer table, customer names are stored (de-normalised) in addresses. They are also stored in orders where they appear as name, shipping name and payment (invoice) name so to straighten out names everywhere would be:rogery wrote:names are still showing unformatted in some places.
Code: Select all
UPDATE customer SET
`firstname` = CONCAT(UCase(Left(`firstname`, 1)),LCase(Right(`firstname`,Length(`firstname`)-1))),
`lastname` = CONCAT(UCase(Left(`lastname`, 1)),LCase(Right(`lastname`,Length(`lastname`)-1)));
UPDATE `order` SET
`firstname` = CONCAT(UCase(Left(`firstname`, 1)),LCase(Right(`firstname`,Length(`firstname`)-1))),
`lastname` = CONCAT(UCase(Left(`lastname`, 1)),LCase(Right(`lastname`,Length(`lastname`)-1))),
`shipping_firstname` = CONCAT(UCase(Left(`shipping_firstname`, 1)),LCase(Right(`shipping_firstname`,Length(`shipping_firstname`)-1))),
`shipping_lastname` = CONCAT(UCase(Left(`shipping_lastname`, 1)),LCase(Right(`shipping_lastname`,Length(`shipping_lastname`)-1))),
`payment_firstname` = CONCAT(UCase(Left(`payment_firstname`, 1)),LCase(Right(`payment_firstname`,Length(`payment_firstname`)-1))),
`payment_lastname` = CONCAT(UCase(Left(`payment_lastname`, 1)),LCase(Right(`payment_lastname`,Length(`payment_lastname`)-1)));
UPDATE address SET
`firstname` = CONCAT(UCase(Left(`firstname`, 1)),LCase(Right(`firstname`,Length(`firstname`)-1))),
`lastname` = CONCAT(UCase(Left(`lastname`, 1)),LCase(Right(`lastname`,Length(`lastname`)-1)));
There is nothing difficult, it is just more of the same but, on the basis that my own requests for help rarely get response, I don't really feel very inclined to spend much of my free time on it.
Free v1.4.9 Extensions: Default Specials | Improved Search | Customer Activity Report | Customer Groups | Royal Mail With Handling | Improved Product Page | Random Products | Stock Report | All Products
Free v1.4.9 Extensions: Default Specials | Improved Search | Customer Activity Report | Customer Groups | Royal Mail With Handling | Improved Product Page | Random Products | Stock Report | All Products
What I meant by petty was that Roger, who has been thankfull and appreciated your help, got the brunt of your frustration. Understandable, but misplaced..
By the way.. I like your extensions.
It's a case of tough love teaching Look how much better you are at it after being forced to learn it on your ownmystifier wrote:Not really petty billyggla; if you look through my posts, I have spent many hours on support and added numerous free extensions. It is a case of putting in what you get out.
I for one appreciate your help and friendly comments!mystifier wrote:There is nothing difficult, it is just more of the same but, on the basis that my own requests for help rarely get response, I don't really feel very inclined to spend much of my free time on it.
I know how frustrated it can be to be on the helping end and get nothing but bad comments from people who themselves only drain the forum and their users but rarely give something back.
But isn't that like the real world?
Norman in 't Veldt
Moderator OpenCart Forums
_________________ READ and Search BEFORE POSTING _________________
Our FREE search: Find your answer FAST!.
[How to] BTW + Verzend + betaal setup.
I must admit, I do sometimes ask questions out of laziness that I could probably solve myself with some effort. That's probably because the support here is too good.
Users browsing this forum: No registered users and 323 guests