View Full Version : [Core Hack] Small tweak to Admin Canned Comments to include only customers First name

09-05-2012, 06:52 PM
Objective: In the stock canned comments, you can choose "customer name" which will simply put the customer's full name in the case (as in capitalization) they originally entered it, I don't find that very useful. I wanted a quick insert of the customer's First name only to use in order comments and I wanted the spelling corrected to capitalize the first letter in case they did not when creating the order (looks more proper). It would be super cool if we could use database variable in the pre-made comments but since we currently cannot, I did this:

This was a very fast and easy edit to admin/orders.php

I am working with osCMax 2.5 and no prior edits to orders.php, the process was as follows:

Inserted 2 lines just after "<!-- BOF: Canned Comments -->" at 538-539 as follows:

<?php $customername= explode(" ", $order->customer['name']); /*make an array of the first and last name */
$customernameuc = ucfirst("$customername[0]"); /* make a varialble of the first name only and capitalize it */ ?>

Next, 3 lines down which is now 542, I changed this:

<option value="<?php echo $order->customer['name']; ?>"> <?php echo OPTION_NAME_OF_CUSTOMER; ?></option>


<option value="<?php echo "Hello ", $customernameuc ?>"> <?php echo OPTION_NAME_OF_CUSTOMER; ?></option>

Now when I click the Canned Comment for Customer Name, it inserts "Hello Firstname" at the beginning of the comment box. Then I edit my other comments from admin [Localization-->Pre Made comments] depending on the condition of the comment I want to send. For example, my most common is a statement confirming shipment so I added a pre-made comment like this


Thank you for your order with www.______.net; your items have been processed for shipping.

Package delivery confirmation and/or tracking information (depending on shipping method) can be viewed at: https://tools.usps.com/go/TrackConfirmAction_input?origTrackNum=

With this tweak, I simply have to click "Customers Name" then my pre-made comment for USPS shipping and then I paste the USPS tracking number at the end of it.

This works great for my application, maybe others will enjoy it too.