DEV Community

James Moberg
James Moberg

Posted on

TrackingURLs - A ColdFusion function to parse Shipping Tracking Numbers

Just a quick post regarding TrackingURLs, a ColdFusion CFC to identify shipping tracking numbers (UPS, USPS, Fedex, OnTrac, DHL, S10) and generate a tracking URL.

Sample Integration

<cfset TrackingURLs = new TrackingURLs()>

<cfset result = TrackingURLs.getTrackingInfo(Form.TrackingNumber)>
<cfif request.isURL(result.url)>
       <cf_newlocation url="#result.url#">
<cfelse>
       <cfoutput>
              <p>Sorry. Tracking number "#EncodeForHTML(Form.TrackingNumber)#" seems invalid.</p>
       </cfoutput>
</cfif>
Enter fullscreen mode Exit fullscreen mode

GitHub Project

GitHub logo JamoCA / TrackingURLs

A ColdFusion CFC to parse & identify ship tracking numbers.

TrackingURLs

A ColdFusion CFC to parse & identify ship tracking numbers.

<cfscript>
TrackingURLs = new TrackingURLs();

cfparam(name="Form.TrackingNumber", default="");

result = TrackingURLs.getTrackingInfo(Form.TrackingNumber);

if (request.isURL(result.url)){
    //location(result.url);
    writedump(result);
} else {
    writeoutput("<p>Sorry. Tracking number "#EncodeForHTML(Form.TrackingNumber)#" seems invalid.</p>");
}

writeOutput("<p>isFedex = #TrackingURLs.isFedex(Form.TrackingNumber)#</p>");

writeOutput("<p>isUSPS = #TrackingURLs.isUSPS(Form.TrackingNumber)#</p>");

writeOutput("<p>isDHL = #TrackingURLs.isDHL(Form.TrackingNumber)#</p>");

writeOutput("<p>isS10 = #TrackingURLs.isS10(Form.TrackingNumber)#</p>");

writeOutput("<p>isOnTrac = #TrackingURLs.isOnTrac(Form.TrackingNumber)#</p>");
</cfscript>

Top comments (2)

Collapse
 
windzbazel profile image
windzbazel

"Sounds interesting! Could you provide more details or perhaps a brief overview of how the jrs tracking example URLs ColdFusion function works? Thanks!"

Collapse
 
gamesover profile image
James Moberg

The ColdFusion TreackingURL CFC doesn't currently support "JRS Tracking". Are you requesting support that support be added? If so, I'll need to see a pattern of their "Philippines JRS Express Tracking number / Airbill No / OR Number / BC number" in order to add support. Are their tracking numbers distinct from other services?