Customer Title

I’ve been trying to add the option for a Customer Title (Mr/Mrs/Miss etc) to an existing store. Without thinking of searching through the contributions I first hacked the code around to deal with it myself, however after I was half way through I realised how complicated osCommerce makes things. On every order it copies the customer’s name and address into a different table thus duplicating the information instead of just referencing the address via a record id. So even if you update the customer’s details the order details for the customer doesn’t update (try this with an order, update the customer’s details and then view the customer’s order and you’ll see their details haven’t changed!).

I had the bulk of the customer’s title script working until I realised it wasn’t working for the Express Checkout option that is already installed on the site. This of course doesn’t use the database in the same way, but relies on sessions more. So after trying to figure out how to fix this I took a look in the contributions on the osCommerce site and came across a Customer Title contribution which also worked with the Purchase Without Account Contribution, which is the express checkout contribution running on the web site. Great, I thought, this should fix all the issues.

So I grabbed the contribution and updated the site files with the code from it, updated the database and tested it on a test site - worked fine apart from one issue, the title wasn’t displaying on an invoice after an order had been made. I then spent an hour or so comparing the code from the contribution to all the admin files trying to connect the dots on how the address was displayed to where it came from etc. Eventually I discovered that all of my code was correct however the actual customer’s title wasn’t being pulled from the database, once I’d fixed that it all worked perfectly :)

For anyone who does use the contribution and finds the same problem I did simply edit line 28 (ish) in /admin/includes/classes/order.php from

$order_query = tep_db_query("select customers_name, customers_company, etc.

to

$order_query = tep_db_query("select customers_title, delivery_title, billing_title, customers_name, customers_company, etc.

This then pulls the titles out which is what the address format function needs.

Leave a Reply