loading...

TrackingURLs - A ColdFusion function to parse Shipping Tracking Numbers

gamesover profile image James Moberg 惻1 min read

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>

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>

Discussion

markdown guide