b310 has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,

I would like to get some advice and/or opinions on the best way to track customer orders.

I have a database table with order information including tracking number and carrier. I believe the challenge here is that we have multiple carriers.

I wrote a script already that extracts the tracking number and carrier for a customer after they enter a customer id number.

The goal is to have the tracking number appear as a link and link to the appropriate carrier and show the status of the order.

Is this possible to do? If so, how would one handle the issue of having many carriers? Where do I begin?

Any advice/opinions/comments is greatly appreciated.

Thank you in advance.

Replies are listed 'Best First'.
Re: Discussion on Tracking Orders
by arthas (Hermit) on Jun 03, 2003 at 14:21 UTC

    It is very possible. However, you need to study the web sites of the various carriers in order to understand how you should pass them data in order to retrieve the shipment information.

    Carrier tracking numbers have a different structure depending on the carrier, so you can quite easily parse them and understand the carrier they belong to.

    There's however a caveat: some carriers might want tracking number to be passed via POST and not GET, and some might even check the referrer when a tracking request is issued. If this is the case with one of the carriers you use, you can't provide a direct link to you customers. Instead, you'll have to fetch yourself the information from the carrier's web site (using LWP for instance); then, you can parse the resulting page and display the shipment information on your web page.

    For FedEx you might also want to take a look at modules such as Business::FedEx.

    Hope this helps!

    Michele.

      I'm currently assessing the number of carriers being used. I'm also contacting the two I know for sure.

      Once I determine how the data should be passed to each carrier, how would my tracking number link know which carrier belongs to that tracking number?

        You have a couple of choices.

        You can, as per phydeauxarff suggestion, modify your database so that, when entering tracking numbers, you also specify the carrier which they belong to. For instance, when you enter a code such as GE732387457WW (invented) you assign it manually to TNT.

        As an alternative, you can just enter the tracking numbers and have your software determine which carrier they belong to. Just to stay with TNT, you know that a number which satisfies the regex:

        /^GE\d{9}WW$/

        is theirs. You can do the same for other carriers. If you choose this way, remeber that some carriers (i.e. UPS) have more that one format for their tracking numbers.

        Michele.

Re: Discussion on Tracking Orders
by phydeauxarff (Priest) on Jun 03, 2003 at 14:23 UTC
    It sounds like you just need to have a carriers table

    If I read you right, you could have a customers table with customer info, a carrier table with the carrier info, and in orders you would reference these by having each entry contain a customer and carrier ID that allows you to lookup that info.