X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Capitalise First Letters in Customer Info (https://forum.x-cart.com/showthread.php?t=8203)

vtonya 08-29-2007 10:21 AM

Re: Capitalise First Letters in Customer Info
 
Please, do it for 4.1.7
Very useful mod!

Thank you!

MoonDog 08-31-2007 09:40 PM

Re: Capitalise First Letters in Customer Info
 
Had a hard time trying to implement this mod in v4.1.8 so I started from scratch and made several changes to make it work.

1 - Create a file and call it capitalise2.js and place it in the /skin1 directory

Place the following code in this file:
Code:

function capitalizeMe(obj) {
        val = obj.value;
        newVal = '';
        val = val.split(' ');
        for(var c=0; c < val.length; c++) {
                newVal += val[c].substring(0,1).toUpperCase() +
val[c].substring(1,val[c].length) + ' ';
        }
        obj.value = newVal;
}


2) Then find xcart/skin1/customer/home.tpl

Add this code between <head> and </head>

Code:
Code:

<script language=JavaScript1.3 src="{$SkinDir}/capitalise2.js"></script>

3) Then locate the following templates in the xcart/skin1/main directory

register_personal_info.tpl
register_billing_address.tpl
register_shipping_address.tpl

also locate
xcart/skin1/help/contactus.tpl

Call the script by changing/adding this code to the end of the input fields:

|capitalize:true}" onChange="capitalizeMe(this);" />

For instance:
Change the existing code shown as commented code {* ...*} with the one under it in skin1/main/register_personal_info.tpl:
Code:


{* <input type="text" id="firstname" name="firstname" size="32" maxlength="32" value="{$userinfo.firstname}" /> *}
  <input type="text" id="firstname" name="firstname" size="32" maxlength="32" value="{$userinfo.firstname|capitalize:true}" onChange="capitalizeMe(this);" />
 
{* <input type="text" id="lastname" name="lastname" size="32" maxlength="32" value="{$userinfo.lastname}" /> *}
  <input type="text" id="lastname" name="lastname" size="32" maxlength="32" value="{$userinfo.lastname|capitalize:true}" onChange="capitalizeMe(this);" />


You can test it out now to see if it works by starting up X-Cart and clicking on the 'register' button located on the 'Authentication' menu.
In the 'First Name' box enter a name in lowercase, and then press the tab key or go to the 'Last Name' box and you can see that the first letter has changed to uppercase.
Test the 'Last Name' box also to make sure your code has been correctly entered.

Now also change the code in skin1/main/register_billing_address.tpl:

Code:


{* <input type="text" name="b_firstname" size="32" maxlength="32" value="{$userinfo.b_firstname}" /> *}
  <input type="text" name="b_firstname" size="32" maxlength="32" value="{$userinfo.b_firstname|capitalize:true}" onChange="capitalizeMe(this);" />
 
{* <input type="text" name="b_lastname" size="32" maxlength="32" value="{$userinfo.b_lastname}" /> *}
  <input type="text" name="b_lastname" size="32" maxlength="32" value="{$userinfo.b_lastname | capitalize:true}" onChange="capitalizeMe(this);" />
 
{* <input type="text" id="b_address" name="b_address" size="32" maxlength="64" value="{$userinfo.b_address}" /> *}
  <input type="text" id="b_address" name="b_address" size="32" maxlength="64" value="{$userinfo.b_address|capitalize:true}" onChange="capitalizeMe(this);" />
 
{* <input type="text" id="b_address_2" name="b_address_2" size="32" maxlength="64" value="{$userinfo.b_address_2}" /> *}
  <input type="text" id="b_address_2" name="b_address_2" size="32" maxlength="64" value="{$userinfo.b_address_2|capitalize:true}" onChange="capitalizeMe(this);" />
 
{* <input type="text" id="b_city" name="b_city" size="32" maxlength="64" value="{$userinfo.b_city}" /> *}
  <input type="text" id="b_city" name="b_city" size="32" maxlength="64" value="{$userinfo.b_city|capitalize:true}" onChange="capitalizeMe(this);" />


Since the register_billing_address.tpl file is still open, you can also change the zip code to make sure that it will always be upper case by changing the following code:
Code:

{* <input type="text" id="b_zipcode" name="b_zipcode" size="32" maxlength="32" value="{$userinfo.b_zipcode}" onchange="check_zip_code()"  /> *}
  <input type="text" id="b_zipcode" name="b_zipcode" size="32" maxlength="32" value="{$userinfo.b_zipcode}" onChange="this.value=this.value.toUpperCase();" onchange="check_zip_code();"  />


Do the same with skin1/main/register_shipping_address.tpl:
Code:


{* <input type="text" id="s_firstname" name="s_firstname" size="32" maxlength="32" value="{$userinfo.s_firstname}" /> *}
  <input type="text" id="s_firstname" name="s_firstname" size="32" maxlength="32" value="{$userinfo.s_firstname|capitalize:true}" onChange="capitalizeMe(this);" />
 
{* <input type="text" id="s_lastname" name="s_lastname" size="32" maxlength="32" value="{$userinfo.s_lastname}" /> *}
  <input type="text" id="s_lastname" name="s_lastname" size="32" maxlength="32" value="{$userinfo.s_lastname|capitalize:true}" onChange="capitalizeMe(this);" />
 
{* <input type="text" id="s_address" name="s_address" size="32" maxlength="64" value="{$userinfo.s_address}" /> *}
  <input type="text" id="s_address" name="s_address" size="32" maxlength="64" value="{$userinfo.s_address|capitalize:true}" onChange="capitalizeMe(this);" />
 
{* <input type="text" id="s_address_2" name="s_address_2" size="32" maxlength="64" value="{$userinfo.s_address_2}" /> *}
  <input type="text" id="s_address_2" name="s_address_2" size="32" maxlength="64" value="{$userinfo.s_address_2|capitalize:true}" onChange="capitalizeMe(this);" />
 
{* <input type="text" id="s_city" name="s_city" size="32" maxlength="64" value="{$userinfo.s_city}" /> *}
  <input type="text" id="s_city" name="s_city" size="32" maxlength="64" value="{$userinfo.s_city|capitalize:true}" onChange="capitalizeMe(this);" />


And this is the code to make the zip code all upper case:
Code:

{* <input type="text" id="s_zipcode" name="s_zipcode" size="32" maxlength="32" value="{$userinfo.s_zipcode}" onchange="check_zip_code()" /> *}
  <input type="text" id="s_zipcode" name="s_zipcode" size="32" maxlength="32" value="{$userinfo.s_zipcode}" onChange="this.value=this.value.toUpperCase();" onchange="check_zip_code();" />


And finally the code in skin1/help/contactus.tpl:
Code:


 
{* <input type="text" id="firstname" name="firstname" size="32" maxlength="32" value="{$userinfo.firstname}" /> *}
  <input type="text" id="firstname" name="firstname" size="32" maxlength="32" value="{$userinfo.firstname|capitalize:true}" onChange="capitalizeMe(this);" />
 
{* <input type="text" id="lastname" name="lastname" size="32" maxlength="32" value="{$userinfo.lastname}" /> *}
  <input type="text" id="lastname" name="lastname" size="32" maxlength="32" value="{$userinfo.lastname|capitalize:true}" onChange="capitalizeMe(this);" />
 
{* <input type="text" id="b_address" name="b_address" size="32" maxlength="64" value="{$userinfo.b_address}" /> *}
  <input type="text" id="b_address" name="b_address" size="32" maxlength="64" value="{$userinfo.b_address|capitalize:true}" onChange="capitalizeMe(this);" />
 
{* <input type="text" id="b_address_2" name="b_address_2" size="32" maxlength="64" value="{$userinfo.b_address_2}" /> *}
  <input type="text" id="b_address_2" name="b_address_2" size="32" maxlength="64" value="{$userinfo.b_address_2|capitalize:true}" onChange="capitalizeMe(this);" />
 
{* <input type="text" id="b_city" name="b_city" size="32" maxlength="64" value="{$userinfo.b_city}" /> *}
  <input type="text" id="b_city" name="b_city" size="32" maxlength="64" value="{$userinfo.b_city|capitalize:true}" onChange="capitalizeMe(this);" />


And the code for upper case zip codes:
Code:

{* <input type="text" id="b_zipcode" name="b_zipcode" size="32" maxlength="32" value="{$userinfo.b_zipcode}" onchange="javascript: check_zip_code(document.getElementById('b_country'), this);" /> *}
  <input type="text" id="b_zipcode" name="b_zipcode" size="32" maxlength="32" value="{$userinfo.b_zipcode}" onchange="this.value=this.value.toUpperCase();" onchange="javascript: check_zip_code(document.getElementById('b_country'), this);" />


All the modifications above were made on templates that had no previous modifications. Hope you like it and thanks to PhilJ for the inspiration.

- MoonDog -

vtonya 09-01-2007 12:49 AM

Re: Capitalise First Letters in Customer Info
 
that Is Great!
Thank You For Your Hard Work!

Works Perfect In 4.1.7

Vacman 09-01-2007 07:22 AM

Re: Capitalise First Letters in Customer Info
 
Now I don't know what to think. I am running 4.1.8, followed the exact steps, cleared the template cache, does not work for me. So I went back and checked each step, and same results. The only step I did not do is the zip code step as we're here in the U.S. and do not do any over-seas business.

BTW: Checked it placing a sample order as a customer would.

Here is the weird thing, the contact form does work, but the checkout process does not.

PhilJ 09-01-2007 07:38 AM

Re: Capitalise First Letters in Customer Info
 
If you're using Fastlane Checkout, you'll need to add the...

Code:

<script language=JavaScript1.3 src="{$SkinDir}/capitalise2.js"></script>

to...

Code:

skin1/modules/Fast_Lane_Checkout/home.tpl

also.

Vacman 09-01-2007 08:40 AM

Re: Capitalise First Letters in Customer Info
 
Quote:

Originally Posted by PhilJ
If you're using Fastlane Checkout, you'll need to add the...

Code:

<script language=JavaScript1.3 src="{$SkinDir}/capitalise2.js"></script>

to...

Code:

skin1/modules/Fast_Lane_Checkout/home.tpl

also.



Bingo! Ah - Order is once again restored to the world!

Thanks PhilJ, and thanks MoonDog!

a1deano 09-20-2007 10:11 AM

Re: Capitalise First Letters in Customer Info
 
"What a top man" one of my biggest hates was people writing the first letter of any line in lower case making you alter it manualy - tops marks.

Many thanks for your hard work on this.

Regards Dean

chris.barber 10-04-2007 03:06 PM

Re: Capitalise First Letters in Customer Info
 
Can I just say many thanks for great and easy mod...

but now I'm really confused, I saw this thread yesterday, made a mental note to do the mod today, came back to the thread and never went past page 1, followed all the steps and with no trouble at all got it working first time straight out of the box on 4.1.8.

Made a second mental note to come back to say thanks, here I am, and read page 2 and 3, only to discover others were unable to get it to work on that version... I guess I am just lucky

Oh and thanks for pointing me to the Postcode mod too, I did them both and I am one happy bunny, I hate people who don't capitalise properly, and I just have to fix it, now I don't need to worry.

Thanks again.

imexhouse 12-02-2007 10:07 AM

Re: Capitalise First Letters in Customer Info
 
I wonder how the address field could be modified so street direction, like SW, NW stay in upper case, instead of Sw and Nw.
Any idea?

Chill-Tek 01-14-2008 03:28 PM

Re: Capitalise First Letters in Customer Info
 
this works a treat on 4.1.9. I am fed up with the usual.....

mr joe bloggs

23 west bloggs drive etc et........


When i order stuff on the net i always make sure the details of address are clear and formatted correctly to make sure i get the goods, not someone down the road.


Thanks again.


All times are GMT -8. The time now is 01:29 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.