[Fedex_Shipping_Tracking_Script]

Description

Link: [Fedex_Shipping_Tracking_Script]
Author: Marc Pope
Category: Tags
Version: 7.x
License: Public Domain
Posted: Jan. 16, 2009
Updated: Jan. 16, 2009
More by this author...
This is not really a tag, but it is a simple solution to show Fedex tracking data. It shows all available data including the details.

Here is an example of the output: DEMO LINK

Tested on Lasso 7.x thru 8.5.6 on MacOS X. Should work on others.

Parameters

-trackNumb string, optional Fedex Tracking Number (tested with US sample number)

Sample Usage

filename.lasso?trackNumb=999999999999
						

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
<?Lassoscript


///////////////////////////////////////////////////////////////////////
//																	 //
// Fedex Tracker by Marc Pope < marc.pope@falconarea.net >			 //
// v1.0 - Created April 12, 2004									 //
//																	 //
// Free for personal/company use. Not for resale.				     //
// Required: Lasso Professional 7.x & Higher						 //
//																	 //
// This solution based on using the Fedex Tagged Transaction Format  //
//																	 //
// Download the Tagged Transaction Guide for more details:			 //
// www.fedex.com/us/solutions/wis/pdf/TagTransGuide.pdf?link=4		 //
//																	 //
// Thanks to the Lasso Community for ideas!							 //
//																	 //
///////////////////////////////////////////////////////////////////////



?>

<style type="text/css" media="screen"><!--
		.text  { font-size: 10px; font-family: Verdana, Helvetica, Geneva, Swiss, SunSans-Regular }
		.bold  { font-weight: bold; font-size: 10px; font-family: Verdana, Helvetica, Geneva, Swiss, SunSans-Regular }
		-->
</style>

<?Lassoscript

// Set variables from passed data
// format should be  track.lasso?trackNumb=0123456789012345

	var:'trackNumb'= (action_param:'trackNumb');


// header, change as needed.

'<span class="bold"><font size="4">Live Fedex Tracking Results: '+$trackNumb+'</font><br></span><hr>';


// only get results if a tracking number is supplied.

if: $trackNumb !='';

// build query for Fedex's Server

	var:'query'='0,"403"1534,"Y"1537,"' + $trackNumb + '"99,""';


// Get Tracking Data from Fedex

// Note: It is recommended that you acquire a meter number from Fedex
// although i'm not using one here and it still works.. so up to you.
// Using the new PostParams tag to get results.. thanks BlueWorld!

	var:'result'= (Include_URL: 'https://gateway.fedex.com/GatewayDC', -POSTParams=$query);
	

// Parse Results
// Fedex returns a very strange pattern, so we'll make it work

	protect;
		$result = (String_Replace: $result, -Find=',"', -Replace='|||');
		$result = (String_Replace: $result, -Find='"', -Replace='+++');
	/protect;


// build array of results

	var:'FDXArray'=(array);

	protect;
		var:'FDXArray'= $result->(Split:'+++');
	/protect;


// put the results array into a mapped array

var:'FDXmap'=(map);

loop: $FDXArray->(Size);

	var:'tempString'=$FDXArray->(get: (loopcount));
	var:'tempArray'=$tempString->(Split:'|||');
	var:'tempCode'=$tempArray->(Get:'1');
	
	if:$tempArray->(size) > '1';
		var:'tempResult'=$tempArray->(get:'2');
		else;
		var:'tempResult'='';
	/if;
	
	$FDXmap->(Insert: (var:'tempCode')=(var:'tempResult'));
	
/loop;


// display any errors from Fedex

if: $FDXMap->(find: '3') != '';

	'<br><font color="red" class="bold"><br>';
		$FDXMap->(Find: '3');
	'</font>';

else;


// now all the results are in a mapped array called $FDXMap
// see the Fedex Tagged Transaction Guide for code references
// make easy to read variables for the main ones
	
	var:'weight'=$FDXmap->(find:'1401-1'),
		'weightdesc'=$FDXmap->(find:'75-1'),
		'city'=$FDXmap->(find:'15-1'),
		'state'=$FDXmap->(find:'16-1'),
		'zip'=$FDXmap->(find:'17-1'),
		'country'=$FDXmap->(find:'50-1'),
		'UCN'=$FDXmap->(find:'1537-1-1'),
		'orderNumber'=$FDXmap->(find:'1537-1-2'),
		'packageID'=$FDXmap->(find:'1537-1-3'),
		'tempSDate'=$FDXmap->(find:'24-1'),
		'tempDDate'=$FDXmap->(find:'1720-1'),
		'tempDTime'=$FDXmap->(find:'1707-1'),
		'tempEDate'=$FDXmap->(find:'1339-1'),
		'tempETime'=$FDXmap->(find:'1340-1'),
		'tempRDate'=$FDXmap->(find:'1716-1'),
		'tempRTime'=$FDXmap->(find:'1717-1'),
		'serviceType'=$FDXmap->(find:'1704-1'),
		'items'=$FDXmap->(find:'116-1'),
		'signedFor'=$FDXmap->(find:'1706-1'),
		'serviceCode'=$FDXmap->(find:'3025-1');
		

// parse expected delivered date
// this part is messy, but it works.. sorry
// need to rewrite using date tags

var: 'expectedDate'='',
	 'expectedTime'='';
	 
if: $tempEDate !='';
	var: 'ExpectedDate'= $tempEDate->(substring: 5,2) + '/' +
						 $tempEDate->(substring: 7,2) + '/' +
						 $tempEDate->(substring: 1,4);
/if;

if: $tempETime !='';
	var: 'ExpectedTime'= $tempETime->(substring: 1,2) + ':' +
						 $tempETime->(substring: 3,2) + ':' +
						 $tempETime->(substring: 5,2);
/if;

var: 'reattemptDate'='',
	 'reattemptTime'='';
	 
if: $tempRDate !='';
	var: 'ReattemptDate'=$tempRDate->(substring: 5,2) + '/' +
						 $tempRDate->(substring: 7,2) + '/' +
						 $tempRDate->(substring: 1,4);
/if;

if: $tempRTime !='';
	var: 'ReattemptTime'=$tempRTime->(substring: 1,2) + ':' +
						 $tempRTime->(substring: 3,2) + ':' +
						 $tempRTime->(substring: 5,2);
/if;


// parse delivered date

var: 'deliveryDate'='',
	 'shipdate'='',
	 'deliveryTime'='';
	 
if: $tempDDate !='';
	var: 'DeliveryDate'= $tempDDate->(substring: 5,2) + '/' +
						 $tempDDate->(substring: 7,2) + '/' +
						 $tempDDate->(substring: 1,4);
/if;

if: $tempDTime !='';
	var: 'DeliveryTime'= $tempDTime->(substring: 1,2) + ':' +
						 $tempDTime->(substring: 3,2) + ':' +
						 $tempDTime->(substring: 5,2);
/if;

if: $tempSDate !='';
	var: 'ShipDate'= $tempSDate->(substring: 5,2) + '/' +
						 $tempSDate->(substring: 7,2) + '/' +
						 $tempSDate->(substring: 1,4);
/if;
	

// build a table of the info, modify as you wish
// note: not all fields are always populated
	
	'<table border="1" cellpadding="3" cellspacing="0" class="text">
		<tr>
			<td>Package Weight: ' + $weight + $weightDesc '</td>
			<td>Location: ' + $city + ', ' + $state + ' ' + $zip + '</td></tr>
		<tr>
			<td>UCN: ' + $UCN + '</td>
			<td>Country: ' + $country + '</td></tr>
		<tr>
			<td>Order #: ' + $OrderNumber + '</td>
			<td>Package ID: ' + $PackageID + '</td></tr>
		<tr>
			<td>Ship Date: ' + $ShipDate + '</td>
			<td>Delivered On: ' + $DeliveryDate + ' ' + $DeliveryTime + '</td></tr>
		<tr>
			<td>Reattempt Date: ' + $reattemptDate + ' ' + $reattemptTime + '</td>
			<td>Expected Date: ' + $expectedDate + ' ' + $expectedTime + '</td></tr>
		<tr>
			<td>Service Type: ' + $serviceType +  '</td>
			<td>Signed For: ' + $signedFor +  '</td></tr>
		<tr>
			<td>Service Code: ' + $serviceCode +  '</td>
			<td>Items: ' + $items +  '</td></tr></table><br>';
	
// now build scan history into some pretty tables
	
	// 1715-1 contains the number of scan history lines
	
	var:'historyItems'=integer:($FDXmap->(find:'1715-1'));
	
	if: $historyitems > 0;
	
	'<table border="1" cellpadding="3" cellspacing="0" class="text">';
	
			'<tr bgcolor="#DDDDDD" class="bold">';
			'<td>'+ 'Scan Date' +'</td>';
			'<td>'+ 'Scan Time' +'</td>';
			'<td>'+ 'Code' +'</td>';
			'<td>'+ 'Message' +'</td>';
			'<td>'+ 'City' +'</td>';
			'<td>'+ 'State' +'</td>';
			'<td>'+ 'Country' +'</td>';
			'<td>'+ 'Comment' +'</td>';
		'</tr>';
	
	loop: $historyitems;
	
		var: 'scanCode' =    $FDXmap->(find: ('1171-1-'+(loopcount)));
		var: 'scanMsg'  =    $FDXmap->(find: ('1159-1-'+(loopcount)));
		var: 'scanCity'  =   $FDXmap->(find: ('1160-1-'+(loopcount)));
		var: 'scanState'  =  $FDXmap->(find: ('1161-1-'+(loopcount)));
		var: 'scanCountry' = $FDXmap->(find: ('1164-1-'+(loopcount)));
		var: 'scanDate'  =   $FDXmap->(find: ('1162-1-'+(loopcount)));
		var: 'scanTime'  =   $FDXmap->(find: ('1163-1-'+(loopcount)));
		var: 'scanComments'= $FDXmap->(find: ('1711-1-'+(loopcount)));
		
		// reformat date
		
		if: $scanDate !='';
			var:'tempScanDate'= $scanDate;
			
			var: 'ScanDate'= $tempscanDate->(substring: 5,2) + '/' +
						 	 $tempscanDate->(substring: 7,2) + '/' +
						 	 $tempscanDate->(substring: 1,4);
		/if;

		// reformat time
		
		if: $scanTime !='';
			var:'tempScanTime'= $scanTime;
			
			var: 'ScanTime'= $tempscanTime->(substring: 1,2) + ':' +
						 	 $tempscanTime->(substring: 3,2) + ':' +
						 	 $tempscanTime->(substring: 5,2);
		/if;
		
		
		'<tr>';
			'<td>'+ $scanDate +'</td>';
			'<td>'+ $scanTime +'</td>';
			'<td>'+ $scanCode +'</td>';
			'<td>'+ $scanMsg +'</td>';
			'<td>'+ $scanCity +'</td>';
			'<td>'+ $scanState +'</td>';
			'<td>'+ $scanCountry +'</td>';
			'<td>'+ $scanComments +'</td>';
		'</tr>';

	/loop;
	
	'</table>';
	
	/if;
	
	/if;
	

/if;

?>

 

Comments

none

Email:


Password:



Newest

Most Popular

Support tagSwap.net