Downloads

Tracking information is probably the most important thing the customer is interested in seeing after an order is placed! The customer wants to know "Where's my stuff?", and you don't want him bugging you about it.

This module lets your customer (or you, the admin) track shipped packages. It uses a hook to interface with installed shipping methods, so it can support tracking packages sent by any carrier, provided the hook is implemented. This module comes with hooks pre-written for FedEx, UPS and USPS.

It works by modifying the user order history page (e.g. user/4/orders) to display a clickable tracking number (or numbers) associated with each order. The user can click on the number and get real-time tracking details for his merchandise.

I decided to display the tracking number on the order history page so the customer wouldn't have to drill down and look for the tracking number - it should be right up top, since it's the thing they care about most. (This active tracking link should also be available on any page where the tracking number appears, but to do that easily requires modifications to the core Ubercart modules.)

To Use:

Install uc_tracking module. Enable it at admin/build/modules.

Note that none of the shipping quote modules are listed as dependencies. That is not a mistake - this module checks for shipping methods implementing the hook. However, if you want to get tracking information for a specific carrier you MUST have that carrier's shipping quotes module installed, enabled, and configured with the correct authorization information (user id, password) needed to contact the carrier's server. It is NOT necessary to turn on shipping quotes for that carrier - simply enabling the module is sufficient.

When you ship a package, you need to choose the carrier from the select box at admin/store/orders/#/shipments/#/edit and enter a tracking number. The carriers displayed are chosen from the list of enabled shipping quotes modules. Tracking numbers will now show up as active links in the user order history page at user/#/orders. Clicking these links will contact the carrier's server to get and display real-time tracking information.

Implementation details:

No Ubercart core modules were harmed in the making of this contribution. However, some functions were ruthlessly overridden, resulting in some core modules with hurt feelings.

Specifically, the user/#/orders menu, defined in uc_order_menu(), was overridden to call my uc_tracking_order_history() function instead of the core uc_order_history() function. Likewise, the uc_shipping_shipment_edit form was altered to force the admin to select a carrier to associate with the entered tracking number ("Other" is also allowed...). This is necessary because to track a package, the code needs to know which carrier the tracking number is for.

This module defines hook_uc_tracking() and provides implementations for FedEx, UPS, and USPS tracking. Adding support for other carriers only requires implementation of that one hook.

hook_uc_tracking() returns an associative array in a specific format containing tracking details. The format of this array is described in the comments in uc_tracking.module.

The code is commented throughout.

It is intended that the implementations of hook_uc_tracking() provided for FedEx, UPS, and USPS will be moved into their corresponding shipping quotes modules and removed from this uc_tracking module.

Bug Fixes / Features added in version 1.03:

Fixed typo in dependencies

Added support for multiple packages per order

Bug Fixes / Features added in version 1.02:

Added support for tracking USPS Delivery Confirmation numbers

Added support for international shipping in the UPS and USPS functions

I like the idea, but there's some changes I want to see before this gets included into core. Instead of using a hook, I think each shipping method should have its own tracking function. This would be listed as a 'track' callback much like 'quote' or 'ship'.

Similarly, I think the tracking functions ought to be chosen based on the shipment's shipping method rather than the carrier. The carrier is meant to be a human-readable text field, but the shipping method is more of an id for the shipping system. I've made a change to the shipping module to allow "manual" shipments to choose which method they will be identified with, even though no shipping label will be made.

I've attached a version of the tracking module that includes those changes. It still needs work because I got stuck while linking to the tracking page. I blame my lack of test data, and other priorities taking precedence. Anyway, the order pane that shows the tracking numbers ought to eventually go in the tracking module, which will link to the tracking results. If someone can make that happen, that'd be great.

I feel like I'm kind of doing a hit & run, but hopefully this can still be sorted out.

Please can you give me the url of the shipping quote mod you refer to that needs to be pre-installed in order to get yours to work.

To get my module to work, unzip/untar it into site/all/modules then install it by checking the right box at admin/build/modules and pressing the "Save Configuration" button. That's all you have to do to install any module.

Regarding Lyle's changes - his version is an intermediate version between my standalone module and what he plans to put into core. I would not recommend using it at this point - it requires some manual changes to uc_ups, uc_fedex, and uc_usps, and doesn't implement the tracking links properly yet.

My module works just fine. When it gets modified and put into a core distribution, you can use the core version. Until then, just download the 1.03 version above.

Anyway, the order pane that shows the tracking numbers ought to eventually go in the tracking module, which will link to the tracking results.

I like the uc_tracking_order_pane(). If that replaces uc_shipping_order_pane(), shouldn't the other stuff in uc_shipping for handling tracking numbers also be moved to uc_tracking? For example, instead of the form code in uc_shipment_shipment_edit(), uc_tracking_form_alter() could be used to add the fields for inputting a tracking number. Otherwise you'll be able to enter tracking numbers in uc_shipping but not see them on the order page unless uc_tracking is enabled. The two modules should be separate (with uc_tracking having a dependency on uc_shipping) or merged.

I've got your mods working - there were a number of bugs and other stuff I had to change. I'm still a little unsure about a couple of things:

I'm guessing it's because the order can be viewed either from admin/store/orders/# or from user/#/order/# ? But that doesn't matter since the link that does the callback doesn't care which page it's one. Or did you mean to make a tab next to the shippments and packages tabs?

Incidentally, why is the existing menu user/#/order/# and not user/#/orders/# (order vs. orders) - "orders" is used everywhere else...

The tracking information doesn't currently show up in the invoice view - I gather that's the point of 'show' => array('view', 'invoice', 'customer') - I'm not sure where to fix this.

I understand the purpose of uc_tracking_order_actions(), but I don't see that it gets called anywhere - what was your intention here? There doesn't seem to be a hook into uc_order_actions(), which is where I would expect this code to appear, and you wouldn't want to put it INTO uc_order_actions() because that would make uc_order depend on uc_tracking. Were you thinking of making some structural changes to uc_order?

I'm now stuck as to where/what exactly to amend to make it Canada Post compliant

You now have to create a function to do the Canada Post tracking. See the uc_tracking.module code for three examples - uc_ups_uc_tracking(), uc_usps_uc_tracking(), and uc_fedex_uc_tracking(). Lots of comments in the code describe the output needed from these hooks. Writing a function for Canada Post requires you to understand the Canada Post web services API for obtaining tracking information. I assume it will be very similar to the code written to do Canada Post shipping quotes, so you should start there and get the quotes working first then delve into the API docs to see how to properly form your tracking requests.

I couldn't decide whether the tracking module should be merged into shipping or if they should be kept separate. I kept trying to do both at once, and that's why I felt I couldn't get anything done.

I think I would like to keep the form elements and database handling of tracking numbers in shipping because it's a major piece of the returned data from the shipping APIs like UPS and FedEx. Hooking into that process is a tricky proposition, and not worth it in my mind. Even if they don't have the tracking module enabled, they should still be recorded. They just won't be used by Ãœbercart. The administrator can still see the tracking numbers when viewing the shipments. It should be reasonable to enable the tracking module to access the tracking information through the order pane and the tracking pages.

I would like the returned tracking information to be available to the store administrators, who might not have access to the user profiles. It keeps the breadcrumbs in the admin section automatically and keeps everything contained in one section. Maybe these aren't valid concerns though. It's not like I finished figuring out what I was doing with it.

"order" was probably a typo on someone's part. I'll ask Ryan to make sure there wasn't actually a good reason.

hook_order_actions() was added a few days ago to uc_order_actions. I decided that the shipping module needed links to the packages and shipments pages, as well as the tracking page.

I'm always working off the latest code. That's where all the fun happens.

Can any shipping company having API for tracking be added to this module? I talked to one of my shipping company "aramex" in this regard for API. They will be sending me the API shipment tracking link and information? Can it be done?

Sorry, I'm no programmer. Is there a way (link/website/resource) from where I can learn to implement the hook() in the module for DHL and aramex?

From the README "...if you want to get tracking information for a specific carrier you MUST have that carrier's shipping quotes module installed, enabled, and configured with the correct authorization information (user id, password) needed to contact the carrier's server."

DHL has a proprietary API. You will need to sign an NDA to obtain the spec, and you are forbidden to allow anyone who hasn't signed the NDA access to your source code which their API. In practice, that means you can only distribute compiled source, precluding a PHP implementation. It's stupid, but that's what they say - allowing someone to see your source code is equivalent to disclosing a company secret.

Yes, you can easily add additional tracking methods to this module. The best way to do this is to use the example of the methods that are already in the module - modifying one of these for your shipping company is the simplest way to go.