Tired of seeing all lowercase or all uppercase customer details in OsCommerce? Here's how to automatically force users to correctly enter their information!


Category: oscommerce

OsCommerce by default can allow people to enter their details in any case with no formatting whatsoever. This can be a pet peeve when you export into accouting packages or similar to have some details in full uppercase and some in all lowercase etc. So, it is possible to mod the code and force the details. However, rather than just do this at the create account stage it is important to do this at *all* stages.
Each modification follows a similar theme of taking

$firstname = tep_db_prepare_input($HTTP_POST_VARS['firstname']);

and adding

$firstname = ucwords($firstname);

or similar.

1. Open create_account.php
Around line #29 change to:-
$firstname = tep_db_prepare_input($HTTP_POST_VARS['firstname']);
$firstname = ucwords($firstname);
$lastname = tep_db_prepare_input($HTTP_POST_VARS['lastname']);
$lastname = ucwords($lastname);
if (ACCOUNT_DOB == 'true') $dob = tep_db_prepare_input($HTTP_POST_VARS['dob']);
$email_address = tep_db_prepare_input($HTTP_POST_VARS['email_address']);
if (ACCOUNT_COMPANY == 'true')
{
$company = tep_db_prepare_input($HTTP_POST_VARS['company']);
$company = ucwords($company);
}
$street_address = tep_db_prepare_input($HTTP_POST_VARS['street_address']);
$street_address = ucwords($street_address);
if (ACCOUNT_SUBURB == 'true')
{
$suburb = tep_db_prepare_input($HTTP_POST_VARS['suburb']);
$suburb = ucwords($suburb);
}
$postcode = tep_db_prepare_input($HTTP_POST_VARS['postcode']);
$postcode = strtoupper($postcode);

$city = tep_db_prepare_input($HTTP_POST_VARS['city']);
$city = ucwords($city);
if (ACCOUNT_STATE == 'true') {
$state = tep_db_prepare_input($HTTP_POST_VARS['state']);
$state = ucwords($state);
if (isset($HTTP_POST_VARS['zone_id'])) {
$zone_id = tep_db_prepare_input($HTTP_POST_VARS['zone_id']);
} else {
$zone_id = false;
}
}
$country = tep_db_prepare_input($HTTP_POST_VARS['country']);
$country = ucwords($country);

2. Open checkout_shipping_address.php
Around line #51 change to:-
$firstname = tep_db_prepare_input($HTTP_POST_VARS['firstname']);
$firstname = ucwords($firstname);
$lastname = tep_db_prepare_input($HTTP_POST_VARS['lastname']);
$lastname = ucwords($lastname);
$street_address = tep_db_prepare_input($HTTP_POST_VARS['street_address']);
$street_address = ucwords($street_address);
if (ACCOUNT_SUBURB == 'true')
{
$suburb = tep_db_prepare_input($HTTP_POST_VARS['suburb']);
$suburb = ucwords($suburb);
}
$postcode = tep_db_prepare_input($HTTP_POST_VARS['postcode']);
$postcode = strtoupper($postcode);
$city = tep_db_prepare_input($HTTP_POST_VARS['city']);
$city = ucwords($city);
$country = tep_db_prepare_input($HTTP_POST_VARS['country']);
$country = ucwords($country);
if (ACCOUNT_STATE == 'true') {
if (isset($HTTP_POST_VARS['zone_id'])) {
$zone_id = tep_db_prepare_input($HTTP_POST_VARS['zone_id']);
} else {
$zone_id = false;
}
$state = tep_db_prepare_input($HTTP_POST_VARS['state']);
$state = ucwords($state);
}
3. Open account_edit.php
Around line #25 change to:-
$firstname = tep_db_prepare_input($HTTP_POST_VARS['firstname']);
$firstname = ucwords($firstname);
$lastname = tep_db_prepare_input($HTTP_POST_VARS['lastname']);
$lastname = ucwords($lastname);
4. Open address_book_process.php
Around line #39 change to:-
$firstname = tep_db_prepare_input($HTTP_POST_VARS['firstname']);
$firstname = ucwords($firstname);
$lastname = tep_db_prepare_input($HTTP_POST_VARS['lastname']);
$lastname = ucwords($lastname);
$street_address = tep_db_prepare_input($HTTP_POST_VARS['street_address']);
$street_address = ucwords($street_address);
if (ACCOUNT_SUBURB == 'true')
{
$suburb = tep_db_prepare_input($HTTP_POST_VARS['suburb']);
$suburb = ucwords($suburb);
}
$postcode = tep_db_prepare_input($HTTP_POST_VARS['postcode']);
$postcode = strtoupper($postcode);

$city = tep_db_prepare_input($HTTP_POST_VARS['city']);
$city = ucwords($city);

$country = tep_db_prepare_input($HTTP_POST_VARS['country']);
$country = ucwords($country);

if (ACCOUNT_STATE == 'true') {
if (isset($HTTP_POST_VARS['zone_id'])) {
$zone_id = tep_db_prepare_input($HTTP_POST_VARS['zone_id']);
} else {
$zone_id = false;
}
$state = tep_db_prepare_input($HTTP_POST_VARS['state']);
$state = ucwords($state);
}

5. Open checkout_payment_address.php
Around line #39 change to:-
$firstname = tep_db_prepare_input($HTTP_POST_VARS['firstname']);
$firstname = ucwords($firstname);

$lastname = tep_db_prepare_input($HTTP_POST_VARS['lastname']);
$lastname = ucwords($lastname);

$street_address = tep_db_prepare_input($HTTP_POST_VARS['street_address']);
$street_address = ucwords($street_address);

if (ACCOUNT_SUBURB == 'true')
{
$suburb = tep_db_prepare_input($HTTP_POST_VARS['suburb']);
$suburb = ucwords($suburb);
}
$postcode = tep_db_prepare_input($HTTP_POST_VARS['postcode']);
$postcode = strtoupper($postcode);

$city = tep_db_prepare_input($HTTP_POST_VARS['city']);
$city = ucwords($city);

$country = tep_db_prepare_input($HTTP_POST_VARS['country']);
$country = ucwords($country);

if (ACCOUNT_STATE == 'true') {
if (isset($HTTP_POST_VARS['zone_id'])) {
$zone_id = tep_db_prepare_input($HTTP_POST_VARS['zone_id']);
} else {
$zone_id = false;
}
$state = tep_db_prepare_input($HTTP_POST_VARS['state']);
$state = ucwords($state);
}

Upload all changes and relax! :)


File Attachments

download  Download: osc_capitalize.zip

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.