After using this forum for several years to find assistance and answers, i think i finally might have something worthwhile to share. for awhile now we have been researching the best way to communicate UPS tracking information to our customers. until now, the best solutions i've found were:
~ copy/paste each tracking number into zen manually.
~ have UPS quantum view or something similar email the customer automatically, which does the job, but in my opinion doesn't look as professional as i would like
~ implement some type of importing from worldship (for example, export tracking numbers to csv file and import into zen)
well, i wasn't thrilled with any of these options. now, we have found a way to provide a customer with a tracking link automatically, without having to copy/paste or import/export anything from Worldship. If you're interested, read on:
While focusing on how to get the tracking numbers into ZenCart, it escaped my mind that you can track a package without having the tracking number. UPS provides tracking tools that allow you to track by various criteria, including Date Range, Package Reference, Shipper Number and more. So, when preparing a shipment for UPS, you must enter the zen invoice number in a "Reference" field. doesn't matter which one (ups allows up to 5 i think). The only catch is that it must be exactly the same, and must be the only thing in the reference field. For example, if the invoice number is 1212, you must enter 1212 in the reference field. if you put inv#1212, or #1212, or 1212W or anything that is not an exact match, it will not work.
next, we added the ups tracking code to whatever areas of the website we want to use them in (in this case, i've added to the tpl_account_default.php page.) Please note that you will need a UPS account, and you will need to register at ups.com to receive an HTML License to use below.
in tpl_account_default.php, find the following lines:
below it add:PHP Code:<th scope="col"><?php echo TABLE_HEADING_VIEW; ?></th>
next, find:PHP Code:<th scope="col"><?php echo 'Track'; ?></th>
underneath it, add:PHP Code:<td align="right"><?php echo '<a href="' . zen_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $orders['orders_id'], 'SSL') . '"> ' .
zen_image_button(BUTTON_IMAGE_VIEW_SMALL, BUTTON_VIEW_SMALL_ALT) . '</a>'; ?></td>
this sends a request to UPS based on your account number, and asks it to find any packages that have a reference number matching this invoice number. as long as you have properly noted the invoice number in UPS when preparing the shipment, you should see a nice ups tracking page appear. (note, the if statement above uses an order status called 'Shipped', so that the tracking link is only displayed for orders that have already shipped. if you have different order status names, you'll need to change that line to match your setup or delete the if statement altogether. We've used almost identical code on the orders.php page, let me know if anyone needs that code for guidance.HTML Code:<td> <?php $invoice = $orders['orders_id'] ; if ($orders['orders_status_name'] == 'Shipped') { ?><FORM method="post" action = "http://wwwapps.ups.com/WebTracking/OnlineTool" target="_blank"> <INPUT type="hidden" size=35 maxlength="35" name="InquiryNumber" value=<?php echo $invoice?>> <INPUT type="hidden" size=10 maxlength="10" name="SenderShipperNumber" value="YOUR_UPS_ACCOUNT#"> <INPUT type="hidden" name="UPS_HTML_License" value="YOUR_HTML_LICENSE_KEY_OBTAINED_FROM_UPS"> <INPUT type="hidden" name="UPS_HTML_Version" value="3.0"> <INPUT type="hidden" name="TypeOfInquiryNumber" value="R"> <input type="image" src="images/track_ups3.gif" value="submit" alt="submit"> </FORM><?php ; } ?></td>
not sure how many people will find this helpful, but it's been GREAT for us. customers love it and the staff loves it. the main snag is that the info displayed is only as good as the info being entered - meaning if you forget to reference the invoice number on the package, the tracking will not work. that being said, our warehouse was already in the habit of referencing the invoice number (as i'm sure many are), so it wasn't an issue. the code is also looking for an icon calls track_ups3.gif which needs to be added to your images/ folder. i have attached an example, or you can make your own (or use text instead).
ps - if anyone is wondering, i did contact UPS Tech to confirm that the HTML Access Key wasn't anything sensitive that couldn't be viewed publicly. i was assured that unless your UPS username and password are exposed, the HTML License poses no security threats.
i'd love any comments or feedback. while i don't consider myself very skilled with php, i'll try my best to assist anyone who is trying to implement this. Also, after thinking about this problem/solution for so long - this seems so very simple, i'm not sure how we overlooked it. i guess that begs the question, is it too good to be true? could someone familiar with ups/zen take a peek and let me know if i'm missing something huge here. we've been using on 2 live sites for about a week now and it seems to be doing great.
i take no responsibility for the effects of this code on your cart. as always, perform backups before making changes, and test before using on a live cart.
-Joe



