Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] UPS XML Tracking


heliosquare

Recommended Posts

I am much closer on this now...figured out the command to run curl with for folks without libcurl but able to run curl from command line:

exec("$curl_path -d \"$xmlRequest\" $url",$xmlResponse);

 

Still not working...no errors but blank....please help.

 

 

 

<?php

/*

03/15/2004

Updated this file to display multiple packages (if applicable). Also moved some code around for optimization's sake.

*/

 

/* All you need to do in this file is edit the following 4 variables:

$userid

$pass

$access_key

$timezone

*/

require('includes/classes/xmldocument.php');

 

if ($action == "track") {

// error_reporting(0); // tell the server not to output any error messages (for security) leave it commented out to debug

$userid = "******"; // the username from UPS

$pass = "*******"; // the password from UPS

$access_key = "************"; // license key from UPS

if (isset($show) && $show == 'detail') {

$activity = "activity";

} else {

$activity = "none";

}

$timezone = 'Pacific'; // set this to the timezone of your server

$protocol = 'https';

//$host = 'wwwcie.ups.com'; // use for testing purposes only

$host = 'www.ups.com';

$port = '443';

$path = '/ups.app/xml/Track';

$version = 'UPSXML Track 1.0001';

$timeout = '60';

$xpci_version = '1.0001';

 

function post($protocol, $host, $port, $path, $version, $timeout, $xmlRequest) {

$url = $protocol."://".$host.":".$port.$path;

 

// $ch = curl_init();

// curl_setopt($ch, CURLOPT_URL, $url);

// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

// curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

// curl_setopt($ch, CURLOPT_HEADER, 0);

// curl_setopt($ch, CURLOPT_POST, 1);

// curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlRequest);

// curl_setopt($ch, CURLOPT_TIMEOUT, (int)$timeout);

 

// $xmlResponse = curl_exec ($ch);

// curl_close ($ch);

 

 

 

 

}

// exec("$curl_path -d $url , $xmlResponse);

// exec("$curl_path -d \"post\" $url", $xmlResponse);

// exec("$curl_path -d \"$data\" https://secure.authorize.net/gateway/transact.dll", $response);

// exec("$curl_path -d \"$xmlRequest\" -H \"Content-Type: text/xml\" https://www.ups.com:443/ups.app/xml/Track" , $xmlResponse);

 

 

$accessRequestHeader =

"<?xml version=\"1.0\"?>\n".

"<AccessRequest xml:lang=\"en-US\">\n".

" <AccessLicenseNumber>". $access_key ."</AccessLicenseNumber>\n".

" <UserId>". $userid ."</UserId>\n".

" <Password>". $pass ."</Password>\n".

"</AccessRequest>\n";

$trackingServiceSelectionRequestHeader =

"<?xml version=\"1.0\"?>\n".

"<TrackRequest xml:lang=\"en-US\">\n".

" <Request>\n".

" <TransactionReference>\n".

" <CustomerContext>UPS Package Tracking</CustomerContext>\n".

" <XpciVersion>1.0001</XpciVersion>\n".

" </TransactionReference>\n".

" <RequestAction>Track</RequestAction>\n".

" <RequestOption>" . $activity . "</RequestOption>\n".

" </Request>\n".

" <TrackingNumber>" . $tracknum . "</TrackingNumber>\n" .

"</TrackRequest>\n";

 

$xmlRequest = $accessRequestHeader . $trackingServiceSelectionRequestHeader;

 

// echo $xmlRequest;

 

$xmlResult = post($protocol, $host, $port, $path, $version, $timeout, $xmlRequest);

 

if (MODULE_PAYMENT_AUTHORIZENET_CURL == 'Not Compiled') {

if (function_exists('exec')) {

exec('which curl', $curl_output);

if ($curl_output) {

$curl_path = $curl_output[0];

}

else {

$curl_path = MODULE_PAYMENT_AUTHORIZENET_CURL_PATH;

}

exec("$curl_path -d \"$xmlRequest\" $url",$xmlResponse);

 

 

// echo $xmlRequest;

// echo $xmlResponse;

// echo $xmlResult;

 

 

 

 

}

 

 

 

 

 

 

 

 

if(!$xmlResponse) {

$xmlResponse = "<?xml version=\"1.0\"?>\n".

"<TrackResponse>\n".

" <Response>\n".

" <TransactionReference>\n".

" <CustomerContext>UPS Package Tracking</CustomerContext>\n".

" <XpciVersion>1.0001</XpciVersion>\n".

" </TransactionReference>\n".

" <ResponseStatusCode>99</ResponseStatusCode>\n".

" <ResponseStatusDescription>There seems to be a communication error with the UPS servers. Please contact the webmaster of this site to report this error.</ResponseStatusDescription>\n".

" </Response>\n".

"</TrackResponse>\n";

}

return $xmlResponse;

}

 

function formatDate($var) {

$date = substr($var, -4, 2) . '/' . substr($var, -2, 2) . '/' . substr($var, 0, 4);

return $date;

}

 

function formatTime($var) {

$left = substr($var, 0, 2);

$right = substr($var, -4, 2);

 

if (substr($left, -2, 1) == 0) {

$left = substr_replace($left, ' ', -2, 1);

}

 

if ($left > 12) {

$left -= 12;

$sign = "PM";

} else {

$sign = "AM";

}

 

$time = $left . ':' . $right . ' ' . $sign;

return $time;

}

 

$time_now = date("His");

$time_now = formatTime($time_now);

 

 

// if we want shipment details then we need to request <TrackingNumber> so that details

// for the specific tracking code submitted are displayed

if (isset($show) && $show == 'detail') {

$trackingServiceSelectionRequestHeader .=

" <TrackingNumber>" . $tracknum . "</TrackingNumber>\n" .

"</TrackRequest>\n";

} else {

// we need to request <ShipmentIdentificationNumber> in the event there are multiple packages

// associated with the tracking code submitted

$trackingServiceSelectionRequestHeader .=

" <ShipmentIdentificationNumber>" . $tracknum . "</ShipmentIdentificationNumber>\n" .

"</TrackRequest>\n";

}

 

 

$doc = new XMLDocument();

$xp = new XMLParser();

$xp->setDocument($doc);

$xp->parse($xmlResult);

$doc = $xp->getDocument();

 

$responseVersion = $doc->getValueByPath('TrackResponse/Response/TransactionReference/XpciVersion');

 

if ($responseVersion != $xpci_version) {

$message = 'This module supports only xpci version 1.0001 of the UPS Tracking Interface. Please contact the webmaster for additional assistance.';

}

 

// Get response code. 1 = SUCCESS, 0 = FAIL

$responseStatusCode = $doc->getValueByPath('TrackResponse/Response/ResponseStatusCode');

 

if ($responseStatusCode == '99') {

$errorMsg = $doc->getValueByPath('TrackResponse/Response/ResponseStatusDescription');

}

 

if (($responseStatusCode != '1') && ($responseStatusCode !='99')) {

$errorMsg = $doc->getValueByPath('TrackResponse/Response/Error/ErrorCode');

if ($errorMsg == '151044') {

$errorMsg .=" : ";

$errorMsg .= $doc->getValueByPath('TrackResponse/Response/Error/ErrorDescription') . '<br>The code may not be in the UPS system yet. Please try again later.';

} else {

$errorMsg .= ": ";

$errorMsg .= $doc->getValueByPath('TrackResponse/Response/Error/ErrorDescription');

}

}

// variables common to every shipment. These are needed by at least two of the switch($show) cases.

// All other variables are moved inside their respective cases to reduce redundant processing.

$DeliverTo = $doc->getValueByPath('TrackResponse/Shipment/ShipTo/Address/City') . ', ' . $doc->getValueByPath('TrackResponse/Shipment/ShipTo/Address/StateProvinceCode');

$PickupDate = $doc->getValueByPath('TrackResponse/Shipment/PickupDate');

$PickupDate = formatDate($PickupDate);

$ScheduledDeliveryDate = $doc->getValueByPath('TrackResponse/Shipment/ScheduledDeliveryDate');

$ScheduledDeliveryDate = formatDate($ScheduledDeliveryDate);

$ServiceType = $doc->getValueByPath('TrackResponse/Shipment/Service/Description');

// eof_variables common to every shipment.

?>

<table border="0" cellpadding="0" cellspacing="0" width="575">

<tr>

<td colspan="3"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '15'); ?></td>

</tr>

<tr>

<td valign="middle" width="31"><?php echo tep_image(DIR_WS_IMAGES . 'bar_code.gif'); ?></td>

<td><div class="upscom"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></div></td>

<td valign="middle" width="100%"><span class="UPSheader">Track by Tracking Number</span></td>

</tr>

<tr>

<td colspan="3"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '12', '1'); ?></td>

</tr>

</table>

<?

switch ($show) {

case 'all':

?>

<table class="appheadercolor" border="0" cellpadding="1" cellspacing="0" width="575">

<tr>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '8', '4'); ?></td>

<td height="20" width="100%"><span class="UPSheader2">View Packages Shipped</span></td>

</tr>

</table>

<table bgcolor="#cccccc" border="0" cellpadding="1" cellspacing="0" width="575">

<tr>

<td>

<table bgcolor="#ffffff" border="0" cellpadding="0" cellspacing="0" width="100%">

<tr>

<td bgcolor="#ffffff"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '4'); ?></td>

</tr>

<tr>

<td bgcolor="#ffffff"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?><a href="<?php echo $PHP_SELF; ?>?action=track&tracknum=<?php echo $tracknum; ?>"><?php echo tep_image(DIR_WS_IMAGES . 'btn_back_summary.gif', 'Back to Summary', '158', '14'); ?></a></td>

</tr>

<tr>

<td><div class="modulepad"><br></div></td>

</tr>

</table>

<table bgcolor="#ffffff" border="0" cellpadding="0" cellspacing="0">

<?php

if (isset($message)) {

echo ' <tr>' . "\n";

echo ' <td align="center" bgcolor="#ffffff" colspan="5"><span class="greetUser">' . $message . '</span></td>' . "\n";

echo ' </tr>' . "\n";

echo ' </table>' . "\n";

echo ' </td>' . "\n";

echo ' </tr>' . "\n";

echo '</table>' . "\n";

} elseif (isset($errorMsg)) {

echo ' <tr>' . "\n";

echo ' <td align="center" bgcolor="#ffffff" colspan="5"><span class="greetUser">' . $errorMsg . '</span></td>' . "\n";

echo ' </tr>' . "\n";

echo ' </table>' . "\n";

echo ' </td>' . "\n";

echo ' </tr>' . "\n";

echo '</table>' . "\n";

} else {

?>

<tr>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

<td nowrap ALIGN="left" valign="top" class="ups"><b>Packages in Shipment:</b></td>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

<td ALIGN="LEFT" VALIGN="TOP" width="100%" class="ups"><?php echo $_GET['p']; ?></td>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

</tr>

<tr>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

<td nowrap ALIGN="left" valign="top" class="ups"><b>Service Type:</b></td>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

<td ALIGN="LEFT" VALIGN="TOP" width="100%" class="ups"><?php echo $ServiceType; ?></td>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

</tr>

<tr>

<td bgcolor="#ffffff" colspan="5"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '8'); ?></td>

</tr>

</table>

<table border="0" cellpadding="0" cellspacing="0" width="100%">

<tr>

<td bgcolor="#cccccc"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '210', '8'); ?></td>

<td bgcolor="#ffffff"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '1'); ?></td>

<td bgcolor="#cccccc"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '100', '1'); ?></td>

<td bgcolor="#ffffff"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '1'); ?></td>

<td bgcolor="#cccccc"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '252', '1'); ?></td>

</tr>

<tr>

<td bgcolor="#cccccc" class="ups"><div class="spacing"><b>Tracking Number</b></div></td>

<td bgcolor="#ffffff"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '8'); ?></td>

<td bgcolor="#cccccc" class="ups"><div class="spacing"><b>Status</b></div></td>

<td bgcolor="#ffffff"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '8'); ?></td>

<td bgcolor="#cccccc" class="ups"><div class="spacing"><b>Delivery Information</b></div></td>

</tr>

<tr>

<td bgcolor="#cccccc"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '8'); ?></td>

<td bgcolor="#ffffff"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '1'); ?></td>

<td bgcolor="#cccccc"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '1'); ?></td>

<td bgcolor="#ffffff"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '1'); ?></td>

<td bgcolor="#cccccc"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '1'); ?></td>

</tr>

<tr>

<td bgcolor="#ffffff" colspan="5"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '8'); ?></td>

</tr>

<?php

// loop through all the tracking codes associated with the submitted tracking code and read the

// status of each one

$number = '0';

$root = $doc->getRoot();

$shipment = $root->getElementsByName("Shipment");

for ($i = 0; $i < count($shipment); $i++) {

$package = $shipment[$i]->getElementsByName("Package");

for ($j = 0; $j < count($package); $j++) {

$tracknum = $package[$j]->getValueByPath("/TrackingNumber");

$number++;

if (($number/2) == floor($number/2)) {

$color = '#cccccc';

} else {

$color = '#ffffff';

}

$Activity = $package[$j]->getElementsByName("Activity");

for ($k = 0; $k < count($Activity); $k++) {

$Status = $Activity[$k]->getValueByPath("/Status/StatusType/Code");

switch ($Status) {

case 'I':

$status = 'In Transit';

break;

case 'D':

$status = 'Delivered';

$DeliverDate = $Activity[$k]->getValueByPath("/Date");

$DeliverDate = formatDate($DeliverDate);

$DeliverTime = $Activity[$k]->getValueByPath("/Time");

$DeliverTime = formatTime($DeliverTime);

$DeliverDate .= ' ' . $DeliverTime;

$SignedBy = $Activity[$k]->getValueByPath("/ActivityLocation/SignedForByName");

break;

case 'X':

$status = 'Exception';

break;

case 'P':

$status = 'Pickup';

break;

case 'M':

$status = 'Billing Information Received';

break;

}

if ($Status == 'D') {

$ActivityData = array($tracknum, $status, $DeliverDate, $DeliverTo, $SignedBy);

echo '<tr><td bgcolor="' . $color . '" colspan="5">' . tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '4') . '</td></tr>' . "\n";

echo '<tr bgcolor="' . $color . '">' . "\n";

echo ' <td VALIGN="top" class="ups"><div class="modulepad">' . $ActivityData[0] . '<br>' . tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '1') . '<a href="' . $PHP_SELF . '?action=track&tracknum=' . $tracknum . '&show=detail&p=' . $p . '">' . tep_image(DIR_WS_IMAGES . 'btn_details.gif', 'Detail', '44', '14') . '</a></div></td>' . "\n";

echo ' <td valign="top">' . tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '8') . '</td>' . "\n";

echo ' <td VALIGN="top" class="ups"><div class="modulepad"><b>' . $ActivityData[1] . '</b></div></td>' . "\n";

echo ' <td valign="top">' . tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '8') . '</td>' . "\n";

echo ' <td VALIGN="top" class="upsSmall"><div class="modulepad">' . "\n";

echo ' <table width="100%" border="0" cellspacing="0" cellpadding="0">' . "\n";

echo ' <tr><td valign="top" class="upsSmall">Delivered on: </td><td valign="top" class="upsSmall">' . $ActivityData[2] . '</td></tr>' . "\n";

echo ' <tr><td valign="top" class="upsSmall">Delivered to: </td><td valign="top" class="upsSmall">' . $ActivityData[3] . '</td></tr>' . "\n";

echo ' <tr><td valign="top" class="upsSmall">Signed by: </td><td valign="top" class="upsSmall">' . $ActivityData[4] . '</td></tr>' . "\n";

echo ' </table></div></td>' . "\n";

echo '</tr>' . "\n";

echo '<tr><td bgcolor="' . $color . '" colspan="5">' . tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '4') . '</td></tr>' . "\n";

} else {

$ActivityData = array($tracknum, $status, $ScheduledDeliveryDate, $Activity[$k]->getValueByPath("/ActivityLocation/Address/City") == 'US' ? 'US' : $Activity[$k]->getValueByPath("/ActivityLocation/Address/City") . ', ' . $Activity[$k]->getValueByPath("/ActivityLocation/Address/StateProvinceCode"));

echo '<tr><td bgcolor="' . $color . '" colspan="5">' . tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '4') . '</td></tr>' . "\n";

echo '<tr bgcolor="' . $color . '">' . "\n";

echo ' <td VALIGN="top" class="ups"><div class="modulepad">' . $ActivityData[0] . '<br>' . tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '1') . '<a href="' . $PHP_SELF . '?action=track&tracknum=' . $tracknum . '&show=detail&p=' . $p . '">' . tep_image(DIR_WS_IMAGES . 'btn_details.gif', 'Detail', '44', '14') . '</a></div></td>' . "\n";

echo ' <td valign="top">' . tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '8') . '</td>' . "\n";

echo ' <td VALIGN="top" class="ups"><div class="modulepad"><b>' . $ActivityData[1] . '</b></div></td>' . "\n";

echo ' <td valign="top">' . tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '8') . '</td>' . "\n";

echo ' <td VALIGN="top" class="upsSmall"><div class="modulepad">' . "\n";

echo ' <table width="100%" border="0" cellspacing="0" cellpadding="0">' . "\n";

echo ' <tr><td valign="top" class="upsSmall">Sched. Delivery: </td><td valign="top" class="upsSmall">' . $ActivityData[2] . '</td></tr>' . "\n";

echo ' <tr><td valign="top" class="upsSmall">Location: </td><td valign="top" class="upsSmall">' . $ActivityData[3] . '</td></tr>' . "\n";

echo ' </table></div></td>' . "\n";

echo '</tr>' . "\n";

echo '<tr><td bgcolor="' . $color . '" colspan="5">' . tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '4') . '</td></tr>' . "\n";

}

}

}

}

?>

<tr>

<td bgcolor="#ffffff" colspan="5"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '8'); ?></td>

</tr>

<tr>

<td bgcolor="#ffffff" colspan="5" class="ups"><div class="modulepad"><?php echo tep_image(DIR_WS_IMAGES . 'dotted_rule.gif', '', '544', '1', 'vspace="8"'); ?><br>

Tracking results provided by UPS: <?php echo strftime(DATE_FORMAT_LONG) . ' ' . $time_now . ' ' . $timezone; ?><br><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '8'); ?><br></div></td>

</tr>

</table>

</td>

</tr>

</table>

<?

}

break;

 

case 'detail':

$Status = $doc->getValueByPath('TrackResponse/Shipment/Package/Activity/Status/StatusType/Code');

switch ($Status) {

case 'I':

$status = 'In Transit';

break;

case 'D':

$status = 'Delivered';

$DeliverDate = $doc->getValueByPath('TrackResponse/Shipment/Package/Activity/Date');

$DeliverDate = formatDate($DeliverDate);

$DeliverTime = $doc->getValueByPath('TrackResponse/Shipment/Package/Activity/Time');

$DeliverTime = formatTime($DeliverTime);

$DeliverDate .= ' ' . $DeliverTime;

$SignedBy = $doc->getValueByPath('TrackResponse/Shipment/Package/Activity/ActivityLocation/SignedForByName');

$Location = $doc->getValueByPath('TrackResponse/Shipment/Package/Activity/ActivityLocation/Description');

break;

case 'X':

$status = 'Exception';

break;

case 'P':

$status = 'Pickup';

break;

case 'M':

$status = 'Billing Information Received';

break;

}

// fix to make weight display properly begin -- This fix was contributed by Teddy Caddy

$Weight = substr($doc->getValueByPath('TrackResponse/Shipment/Package/PackageWeight/UnitOfMeasure/Code'), 3, 5) . ' ' . substr($doc->getValueByPath('TrackResponse/Shipment/Package/PackageWeight/UnitOfMeasure/Code'), 0, 3);

// end of fix to make weight display properly

?>

<table class="appheadercolor" border="0" cellpadding="1" cellspacing="0" width="575">

<tr>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '8', '4'); ?></td>

<td height="20" width="100%"><span class="UPSheader2">View Details</span></td>

</tr>

</table>

<table bgcolor="#cccccc" border="0" cellpadding="1" cellspacing="0" width="575">

<tr>

<td>

<table bgcolor="#ffffff" border="0" cellpadding="0" cellspacing="0" width="100%">

<tr>

<td bgcolor="#ffffff"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '4'); ?></td>

</tr>

<tr>

<td bgcolor="#ffffff"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?><a href="<?php echo $PHP_SELF; ?>?action=track&tracknum=<?php echo $tracknum; ?>"><?php echo tep_image(DIR_WS_IMAGES . 'btn_back_summary.gif', 'Back to Summary', '158', '14'); ?></a></td>

</tr>

<tr>

<td><div class="modulepad"><br></div></td>

</tr>

</table>

<table bgcolor="#ffffff" border="0" cellpadding="0" cellspacing="0">

<?php

if (isset($message)) {

echo ' <tr>' . "\n";

echo ' <td align="center" bgcolor="#ffffff" colspan="5"><span class="greetUser">' . $message . '</span></td>' . "\n";

echo ' </tr>' . "\n";

echo ' </table>' . "\n";

echo ' </td>' . "\n";

echo ' </tr>' . "\n";

echo '</table>' . "\n";

} elseif (isset($errorMsg)) {

echo ' <tr>' . "\n";

echo ' <td align="center" bgcolor="#ffffff" colspan="5"><span class="greetUser">' . $errorMsg . '</span></td>' . "\n";

echo ' </tr>' . "\n";

echo ' </table>' . "\n";

echo ' </td>' . "\n";

echo ' </tr>' . "\n";

echo '</table>' . "\n";

} else {

?>

<tr>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

<td nowrap ALIGN="left" valign="top" class="ups"><b>Status:</b></td>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

<td ALIGN="LEFT" VALIGN="TOP" width="100%" class="ups"><?php echo $status; ?></td>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

</tr>

<?php

if ($Status == 'D') {

?>

<tr>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

<td nowrap ALIGN="left" class="ups"><b>Delivered on:</b></td>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

<td ALIGN="LEFT" VALIGN="BOTTOM" width="100%" class="ups"><?php echo $DeliverDate; ?></td>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

</tr>

<tr>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

</tr>

<?php

if (isset($SignedBy) || strlen($SignedBy > 0)) {

?>

<tr>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

<td nowrap ALIGN="left" class="ups"><b>Signed by:</b></td>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

<td ALIGN="LEFT" VALIGN="BOTTOM" width="100%" class="ups"><?php echo $SignedBy; ?></td>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

</tr>

<?php

}

?>

<tr>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

<td nowrap ALIGN="left" class="ups"><b>Location:</b></td>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

<td ALIGN="LEFT" VALIGN="BOTTOM" width="100%" class="ups"><?php echo $Location; ?></td>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

</tr>

<?php

} elseif ($Status != 'D') {

?>

<tr>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

<td nowrap ALIGN="left" class="ups"><b>Scheduled Delivery Date:</b></td>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

<td ALIGN="LEFT" VALIGN="BOTTOM" width="100%" class="ups"><?php echo $ScheduledDeliveryDate; ?></td>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

</tr>

<?php

}

?>

<tr>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

<td nowrap ALIGN="left" class="ups"><b>Shipped to:</b></td>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

<td ALIGN="LEFT" VALIGN="BOTTOM" width="100%" class="ups"><?php echo $DeliverTo; ?></td>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

</tr>

<tr>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

<td nowrap ALIGN="left" class="ups"><b>Shipped or Billed on:</b></td>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

<td ALIGN="LEFT" VALIGN="BOTTOM" width="100%" class="ups"><?php echo $PickupDate; ?></td>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

</tr>

<tr>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?><br><br></td>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

<td width="100%"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

</tr>

<tr>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

<td nowrap ALIGN="left" class="ups"><b>Tracking Number:</b></td>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

<td ALIGN="LEFT" VALIGN="BOTTOM" width="100%" class="ups"><?php echo $tracknum; ?></td>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

</tr>

<tr>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

<td nowrap ALIGN="left" class="ups"><b>Service Type:</b></td>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

<td ALIGN="LEFT" VALIGN="BOTTOM" width="100%" class="ups"><?php echo $ServiceType; ?></td>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

</TR>

<tr>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

<td nowrap ALIGN="left" class="ups"><b>Weight:</b></td>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

<td ALIGN="LEFT" VALIGN="BOTTOM" width="100%" class="ups"><?php echo $Weight; ?></td>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

</tr>

<?php

if ($_GET['p']) {

?>

<tr>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?><br><br></td>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

<td width="100%"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

</tr>

<tr>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

<td nowrap ALIGN="left" class="ups"><b>Multiple Packages:</b></td>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

<td ALIGN="LEFT" VALIGN="BOTTOM" width="100%" class="ups"><?php echo $_GET['p']; ?> <a href="<?php echo $PHP_SELF; ?>?action=track&tracknum=<?php echo $tracknum; ?>&show=all&p=<?php echo $_GET['p']; ?>"><?php echo tep_image(DIR_WS_IMAGES . 'btn_show_all.gif', 'Show All', '60', '14', 'align="top"'); ?></a></td>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

</tr>

<?php

}

?>

<tr>

<td colspan="5" width="100%"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

</tr>

</table>

<table bgcolor="#ffffff" border="0" cellpadding="0" cellspacing="0" width="100%">

<tr>

<td colspan="7"><div class="modulepad"><?php echo tep_image(DIR_WS_IMAGES . 'dotted_rule.gif', '', '544', '1', 'vspace="8"'); ?><br></div></td>

</tr>

<tr>

<td bgcolor="#ffffff" colspan="7"><div class="modulepad"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '4'); ?><br></div></td>

</tr>

</table>

<table bgcolor="#ffffff" border="0" cellpadding="0" cellspacing="0" width="100%">

<tr>

<td colspan="7" class="ups"><div class="modulepad"><span class="brownbold">Package Progress:</span><br></div></td>

</tr>

<tr>

<td bgcolor="#cccccc"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '95', '8'); ?></td>

<td bgcolor="#ffffff"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '8'); ?></td>

<td bgcolor="#cccccc"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '80', '8'); ?></td>

<td bgcolor="#ffffff"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '8'); ?></td>

<td bgcolor="#cccccc"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '186', '8'); ?></td>

<td bgcolor="#ffffff"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '8'); ?></td>

<td bgcolor="#cccccc"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '200', '8'); ?></td>

</tr>

<tr>

<td bgcolor="#cccccc" valign="middle" class="ups"><div class="spacing"><b>Date</b></div></td>

<td bgcolor="#ffffff"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '8'); ?></td>

<td bgcolor="#cccccc" class="ups"><div class="spacing"><b>Time</b></div></td>

<td bgcolor="#ffffff"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '8'); ?></td>

<td bgcolor="#cccccc" class="ups"><div class="spacing"><b>Location</b></div></td>

<td bgcolor="#ffffff"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '8'); ?></td>

<td bgcolor="#cccccc" class="ups"><div class="spacing"><b>Activity</b></div></td>

</tr>

<tr>

<td bgcolor="#cccccc"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '8'); ?></td>

<td bgcolor="#ffffff"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '8'); ?></td>

<td bgcolor="#cccccc"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '8'); ?></td>

<td bgcolor="#ffffff"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '8'); ?></td>

<td bgcolor="#cccccc"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '8'); ?></td>

<td bgcolor="#ffffff"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '8'); ?></td>

<td bgcolor="#cccccc"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '8'); ?></td>

</tr>

<?php

$number = '0';

$Date ='';

$root = $doc->getRoot();

$shipment = $root->getElementsByName("Shipment");

for ($i = 0; $i < count($shipment); $i++) {

$package = $shipment[$i]->getElementsByName("Package");

for ($j = 0; $j < count($package); $j++) {

$Activity = $package[$j]->getElementsByName("Activity");

for ($k = 0; $k < count($Activity); $k++) {

if ($Date != $Activity[$k]->getValueByPath("/Date")) {

$Date = $Activity[$k]->getValueByPath("/Date");

$number++;

if (($number/2) == floor($number/2)) {

$color = '#cccccc';

} else {

$color = '#ffffff';

}

echo '<tr bgcolor="' . $color . '">' . "\n";

echo '<td VALIGN="top" class="ups"><div class="modulepad">' . formatDate($Date) . '</div></td>' . "\n";

} else {

echo '<tr bgcolor="' . $color . '">' . "\n";

echo '<td VALIGN="top" class="ups"><div class="modulepad">' . tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '8') . '</div></td>' . "\n";

}

$ActivityData = array(formatTime($Activity[$k]->getValueByPath("/Time")), $Activity[$k]->getValueByPath("/ActivityLocation/Address/City") == 'US' ? 'US' : $Activity[$k]->getValueByPath("/ActivityLocation/Address/City") . ', ' . $Activity[$k]->getValueByPath("/ActivityLocation/Address/StateProvinceCode"), $Activity[$k]->getValueByPath("/Status/StatusType/Description"));

echo ' <td valign="top">' . tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '8') . '</td>' . "\n";

echo ' <td VALIGN="top" class="ups"><div class="modulepad">' . $ActivityData[0] . '</div></td>' . "\n";

echo ' <td valign="top">' . tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '8') . '</td>' . "\n";

echo ' <td VALIGN="top" class="ups"><div class="modulepad">' . $ActivityData[1] . '</div></td>' . "\n";

echo ' <td valign="top">' . tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '8') . '</td>' . "\n";

echo ' <td VALIGN="top" class="ups"><div class="modulepad">' . $ActivityData[2] . '</div></td>' . "\n";

echo '</tr>' . "\n";

}

}

}

?>

<tr>

<td bgcolor="#ffffff" colspan="7"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '8'); ?></td>

</tr>

<tr>

<td bgcolor="#ffffff" colspan="7" class="ups"><div class="modulepad"><?php echo tep_image(DIR_WS_IMAGES . 'dotted_rule.gif', '', '544', '1', 'vspace="8"'); ?><br>

Tracking results provided by UPS: <?php echo strftime(DATE_FORMAT_LONG) . ' ' . $time_now . ' ' . $timezone; ?><br><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '8'); ?><br></div></td>

</tr>

</table>

</td>

</tr>

</table>

<?

}

break;

 

case '':

$Status = $doc->getValueByPath('TrackResponse/Shipment/Package/Activity/Status/StatusType/Code');

switch ($Status) {

case 'I':

$status = 'In Transit';

break;

case 'D':

$status = 'Delivered';

$DeliverDate = $doc->getValueByPath('TrackResponse/Shipment/Package/Activity/Date');

$DeliverDate = formatDate($DeliverDate);

$DeliverTime = $doc->getValueByPath('TrackResponse/Shipment/Package/Activity/Time');

$DeliverTime = formatTime($DeliverTime);

$DeliverDate .= ' ' . $DeliverTime;

$SignedBy = $doc->getValueByPath('TrackResponse/Shipment/Package/Activity/ActivityLocation/SignedForByName');

$Location = $doc->getValueByPath('TrackResponse/Shipment/Package/Activity/ActivityLocation/Description');

break;

case 'X':

$status = 'Exception';

break;

case 'P':

$status = 'Pickup';

break;

case 'M':

$status = 'Billing Information Received';

break;

}

?>

<table class="appheadercolor" border="0" cellpadding="1" cellspacing="0" width="575">

<tr>

<td height="20"><span class="UPSheader2"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?>View Tracking Summary</span></td>

<td align="right" height="20"> </td>

</tr>

</table>

<table bgcolor="#cccccc" border="0" cellpadding="1" cellspacing="0" width="575">

<tr>

<td colspan="3" width="573">

<table bgcolor="#ffffff" border="0" cellpadding="0" cellspacing="0" width="100%">

<tr>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '8'); ?></td>

</tr>

<tr>

<td class="ups"><div class="modulepad">To see a detailed report for this shipment, please select the "Detail" link.<br></div></td>

</tr>

<tr>

<td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '8'); ?></td>

</tr>

</table>

<table border="0" cellpadding="0" cellspacing="0" width="100%">

<tr>

<td bgcolor="#cccccc"

Link to comment
Share on other sites

  • Replies 324
  • Created
  • Last Reply

Top Posters In This Topic

Ok, I got the command line to work properly with this contrib. Below is the code for the post() function found in /includes/classes/tracking.php

 

Simply replace the existing post() function with the code shown below. Nothing else needs to be changed.

 

    function post($protocol, $host, $port, $path, $version, $timeout, $xmlRequest) {
  $url = $protocol."://".$host.":".$port.$path;
     // uncomment the line below if you need to use the command line to send the curl request.
     // remember to comment out lines $ch = curl_init(); through curl_close($ch);
     exec('curl --data ' . escapeshellarg($xmlRequest) . ' ' . $url . '', $xmlResponse);

//Begin curl request using the compiled curl version
/*
     $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_HEADER, 0);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlRequest);
  curl_setopt($ch, CURLOPT_TIMEOUT, (int)$timeout);

     $xmlResponse = curl_exec ($ch);
     curl_close ($ch);
*/
//End curl request using the compiled curl version

     if(!$xmlResponse) {
 $xmlResponse = "<?xml version=\"1.0\"?>\n".
  	 "<TrackResponse>\n".
  	 "  <Response>\n".
  	 "    <TransactionReference>\n".
       "      <CustomerContext>UPS Package Tracking</CustomerContext>\n".
       "      <XpciVersion>1.0001</XpciVersion>\n".
       "    </TransactionReference>\n".
       "    <ResponseStatusCode>99</ResponseStatusCode>\n".
       "    <ResponseStatusDescription>There seems to be a communication error with the UPS servers.  Please contact the webmaster of this site to report this error.</ResponseStatusDescription>\n".
          "  </Response>\n".
          "</TrackResponse>\n";
  }
//Use the line below for the compiled curl version
     //return $xmlResponse;
//Use the line below for the command line curl version
     return $xmlResponse[0];
}

Do you ship UPS?

Give your customers order tracking without leaving your site. Track multi-package shipments. XML, cURL

 

Download the contribution here:

UPS Tracking

Link to comment
Share on other sites

is there a way to add multiple tracking numbers to one order? some of our orders are split, meaning that some items in the order are shipped from location a, and other items in the order are shipped from location b. so basically some customers will be recieving multiple packages for one order. i would like to know if, or what would need to be done to be able to provide the customer with multiple tracking numbers.

Link to comment
Share on other sites

I want to update to admin/order.php to include a function that on update, checks if the customer e-mail box is checked AND the ups_track_num and if both included then in customer's e-mail include the following link in the e-mail after the comments are displayed

http://wwwapps.ups.com/WebTracking/processRequest?HTMLVersion=5.0&Requester=NES&AgreeToTermsAndConditions=yes&loc=en_US&tracknum='$ups_track_num'

Any help on how to do this would be appreciated.

Edited by Jayman007
Link to comment
Share on other sites

So I did the update for command line curl and on the tracking result page I get

Looking for TrackResponse

Looking for TrackResponse

Looking for TrackResponse

Looking for TrackResponse

Looking for TrackResponse

Looking for TrackResponse

Looking for TrackResponse

Looking for TrackResponse

 

 

So I added an

echo $xmlResponse[0];

 

After the exec(curl

 

And now I get

 

UPS Package Tracking1.00010FailureHard151044No tracking information availableLooking for TrackResponse

Looking for TrackResponse

Looking for TrackResponse

Looking for TrackResponse

Looking for TrackResponse

Looking for TrackResponse

Looking for TrackResponse

Looking for TrackResponse

Looking for TrackResponse

 

 

I then added an

echo $xmlRequest;

 

To verify the request was good, and it is.

 

So is it possible that

 

      exec('curl --data ' . escapeshellarg($xmlRequest) . ' ' . $url . '', $xmlResponse);

 

is incorrect? Why do I get a failure on my requests?

Link to comment
Share on other sites

So is it possible that

 

 ? ? ?exec('curl --data ' . escapeshellarg($xmlRequest) . ' ' . $url . '', $xmlResponse);

 

is incorrect?  Why do I get a failure on my requests?

the code isn't incorrect because it works perfectly on my server (I have it configured to use the command line code right now just for proof of concept). In fact, the error you are getting probably has nothing to do with curl since you are getting a response. I have a feeling the code in the "request" part of your tracking.php is messed up somewhere. The pasted code you were showing me in the private msgs. was consistently messed up...looked like you were moving stuff around in an attempt to make this work. I am referring to lines below:

$accessRequestHeader =
    "<?xml version=\"1.0\"?>\n".
    "<AccessRequest xml:lang=\"en-US\">\n".
    "   <AccessLicenseNumber>". $access_key ."</AccessLicenseNumber>\n".
    "   <UserId>". $userid ."</UserId>\n".
    "   <Password>". $pass ."</Password>\n".
    "</AccessRequest>\n";
$trackingServiceSelectionRequestHeader =
    "<?xml version=\"1.0\"?>\n".
    "<TrackRequest xml:lang=\"en-US\">\n".
    "  <Request>\n".
    "    <TransactionReference>\n".
    "      <CustomerContext>UPS Package Tracking</CustomerContext>\n".
    "      <XpciVersion>1.0001</XpciVersion>\n".
    "    </TransactionReference>\n".
    "    <RequestAction>Track</RequestAction>\n".
    "    <RequestOption>" . $activity . "</RequestOption>\n".
    "  </Request>\n";
  if (isset($show) && $show == 'detail') {
     $trackingServiceSelectionRequestHeader .=
       "  <TrackingNumber>" . $tracknum . "</TrackingNumber>\n" .
    "</TrackRequest>\n";
     } else {
     $trackingServiceSelectionRequestHeader .=
    "  <ShipmentIdentificationNumber>" . $tracknum . "</ShipmentIdentificationNumber>\n" .
    "</TrackRequest>\n";
     }

these lines MUST stay together in order for the request to be sent properly. I remember that you, for whatever reason, had this section split up. UPS isn't getting valid data from your site but I highly doubt it is because of curl. Just for something to try you could put the full path to curl in the code:

replace

exec('curl --data ' . escapeshellarg($xmlRequest) . ' ' . $url . '', $xmlResponse);

with

exec('path/to/curl --data ' . escapeshellarg($xmlRequest) . ' ' . $url . '', $xmlResponse);

doubt this will do anything since curl must already be in your server's path to have given you the response you posted in your message...

Do you ship UPS?

Give your customers order tracking without leaving your site. Track multi-package shipments. XML, cURL

 

Download the contribution here:

UPS Tracking

Link to comment
Share on other sites

The curl is working. I have tried it for a command line without the path. I threw out my tracking.php and started fresh with the one from the package. Here is what I am using, only have pulled out my ups details.

 

<?php

/*

03/15/2004

   Updated this file to display multiple packages (if applicable).  Also moved some code around for optimization's sake.

*/

 

/* All you need to do in this file is edit the following 4 variables:

   $userid

   $pass

   $access_key

   $timezone

*/

 require('includes/classes/xmldocument.php');

 

 if ($action == "track") {

   error_reporting(0);  // tell the server not to output any error messages (for security) leave it commented out to debug

$userid = "******"; // the username from UPS

$pass = "*****"; // the password from UPS

$access_key = "*****"; // license key from UPS

   if (isset($show) && $show == 'detail') {

     $activity = "activity";

   } else {

     $activity = "none";

   }

   $timezone = 'Eastern';  // set this to the timezone of your server

   $protocol = 'https';

//$host = 'wwwcie.ups.com'; // use for testing purposes only

   $host = 'www.ups.com';

   $port = '443';

$path = '/ups.app/xml/Track';

$version = 'UPSXML Track 1.0001';

$timeout = '60';

   $xpci_version = '1.0001';

 

   function post($protocol, $host, $port, $path, $version, $timeout, $xmlRequest) {

  $url = $protocol."://".$host.":".$port.$path;

     // uncomment the line below if you need to use the command line to send the curl request.

     // remember to comment out lines $ch = curl_init(); through curl_close($ch);

     exec('curl --data ' . escapeshellarg($xmlRequest) . ' ' . $url . '', $xmlResponse);

     echo $xmlResponse[0];

 

//Begin curl request using the compiled curl version

/*

     $ch = curl_init();

  curl_setopt($ch, CURLOPT_URL, $url);

  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

  curl_setopt($ch, CURLOPT_HEADER, 0);

  curl_setopt($ch, CURLOPT_POST, 1);

  curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlRequest);

  curl_setopt($ch, CURLOPT_TIMEOUT, (int)$timeout);

 

     $xmlResponse = curl_exec ($ch);

     curl_close ($ch);

*/

//End curl request using the compiled curl version

 

     if(!$xmlResponse) {

 $xmlResponse = "<?xml version=\"1.0\"?>\n".

    "<TrackResponse>\n".

    "  <Response>\n".

    "    <TransactionReference>\n".

       "      <CustomerContext>UPS Package Tracking</CustomerContext>\n".

       "      <XpciVersion>1.0001</XpciVersion>\n".

       "    </TransactionReference>\n".

       "    <ResponseStatusCode>99</ResponseStatusCode>\n".

       "    <ResponseStatusDescription>There seems to be a communication error with the UPS servers.  Please contact the webmaster of this site to report this error.</ResponseStatusDescription>\n".

          "  </Response>\n".

          "</TrackResponse>\n";

  }

//Use the line below for the compiled curl version

     //return $xmlResponse;

//Use the line below for the command line curl version

     return $xmlResponse[0];

}

 

   function formatDate($var) {

     $date = substr($var, -4, 2) . '/' . substr($var, -2, 2) . '/' . substr($var, 0, 4);

     return $date;

   }

 

   function formatTime($var) {

     $left = substr($var, 0, 2);

     $right = substr($var, -4, 2);

 

     if (substr($left, -2, 1) == 0) {

       $left = substr_replace($left, ' ', -2, 1);

     }

 

     if ($left > 12) {

       $left -= 12;

       $sign = "PM";

     } else {

       $sign = "AM";

     }

 

     $time = $left . ':' . $right . ' ' . $sign;

     return $time;

   }

 

   $time_now = date("His");

   $time_now = formatTime($time_now);

 

$accessRequestHeader =

    "<?xml version=\"1.0\"?>\n".

    "<AccessRequest xml:lang=\"en-US\">\n".

    "   <AccessLicenseNumber>". $access_key ."</AccessLicenseNumber>\n".

    "   <UserId>". $userid ."</UserId>\n".

    "   <Password>". $pass ."</Password>\n".

    "</AccessRequest>\n";

$trackingServiceSelectionRequestHeader =

    "<?xml version=\"1.0\"?>\n".

    "<TrackRequest xml:lang=\"en-US\">\n".

    "  <Request>\n".

    "    <TransactionReference>\n".

    "      <CustomerContext>UPS Package Tracking</CustomerContext>\n".

    "      <XpciVersion>1.0001</XpciVersion>\n".

    "    </TransactionReference>\n".

    "    <RequestAction>Track</RequestAction>\n".

    "    <RequestOption>" . $activity . "</RequestOption>\n".

    "  </Request>\n";

// if we want shipment details then we need to request <TrackingNumber> so that details

// for the specific tracking code submitted are displayed

  if (isset($show) && $show == 'detail') {

     $trackingServiceSelectionRequestHeader .=

       "  <TrackingNumber>" . $tracknum . "</TrackingNumber>\n" .

    "</TrackRequest>\n";

     } else {

// we need to request <ShipmentIdentificationNumber> in the event there are multiple packages

// associated with the tracking code submitted

     $trackingServiceSelectionRequestHeader .=

    "  <ShipmentIdentificationNumber>" . $tracknum . "</ShipmentIdentificationNumber>\n" .

    "</TrackRequest>\n";

     }

 

$xmlRequest = $accessRequestHeader . $trackingServiceSelectionRequestHeader;

   $xmlResult = post($protocol, $host, $port, $path, $version, $timeout, $xmlRequest);

 

   $doc = new XMLDocument();

$xp = new XMLParser();

$xp->setDocument($doc);

$xp->parse($xmlResult);

$doc = $xp->getDocument();

 

$responseVersion = $doc->getValueByPath('TrackResponse/Response/TransactionReference/XpciVersion');

 

   if ($responseVersion != $xpci_version) {

     $message = 'This module supports only xpci version 1.0001 of the UPS Tracking Interface. Please contact the webmaster for additional assistance.';

   }

 

// Get response code. 1 = SUCCESS, 0 = FAIL

   $responseStatusCode = $doc->getValueByPath('TrackResponse/Response/ResponseStatusCode');

 

   if ($responseStatusCode == '99') {

     $errorMsg = $doc->getValueByPath('TrackResponse/Response/ResponseStatusDescription');

   }

 

   if (($responseStatusCode != '1') && ($responseStatusCode !='99')) {

     $errorMsg = $doc->getValueByPath('TrackResponse/Response/Error/ErrorCode');

     if ($errorMsg == '151044') {

       $errorMsg .=" : ";

       $errorMsg .= $doc->getValueByPath('TrackResponse/Response/Error/ErrorDescription') . '<br>The code may not be in the UPS system yet.  Please try again later.';

     } else {

    $errorMsg .= ": ";

    $errorMsg .= $doc->getValueByPath('TrackResponse/Response/Error/ErrorDescription');

     }

   }

// variables common to every shipment.  These are needed by at least two of the switch($show) cases.

// All other variables are moved inside their respective cases to reduce redundant processing.

   $DeliverTo = $doc->getValueByPath('TrackResponse/Shipment/ShipTo/Address/City') . ', ' . $doc->getValueByPath('TrackResponse/Shipment/ShipTo/Address/StateProvinceCode');

   $PickupDate = $doc->getValueByPath('TrackResponse/Shipment/PickupDate');

   $PickupDate = formatDate($PickupDate);

   $ScheduledDeliveryDate = $doc->getValueByPath('TrackResponse/Shipment/ScheduledDeliveryDate');

   $ScheduledDeliveryDate = formatDate($ScheduledDeliveryDate);

   $ServiceType = $doc->getValueByPath('TrackResponse/Shipment/Service/Description');

// eof_variables common to every shipment.

?>

           <table border="0" cellpadding="0" cellspacing="0" width="575">

   <tr>

    <td colspan="3"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '15'); ?></td>

            </tr>

            <tr>

                <td valign="middle" width="31"><?php echo tep_image(DIR_WS_IMAGES . 'bar_code.gif'); ?></td>

                <td><div class="upscom"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></div></td>

                <td valign="middle" width="100%"><span class="UPSheader">Track by Tracking Number</span></td>

            </tr>

            <tr>

                <td colspan="3"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '12', '1'); ?></td>

            </tr>

        </table>

<?

switch ($show) {

     case 'all':

?>

           <table class="appheadercolor" border="0" cellpadding="1" cellspacing="0" width="575">

            <tr>

                <td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '8', '4'); ?></td>

                <td height="20" width="100%"><span class="UPSheader2">View Packages Shipped</span></td>

            </tr>

        </table>

        <table bgcolor="#cccccc" border="0" cellpadding="1" cellspacing="0" width="575">

            <tr>

                <td>

                    <table bgcolor="#ffffff" border="0" cellpadding="0" cellspacing="0" width="100%">

                        <tr>

                            <td bgcolor="#ffffff"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '4'); ?></td>

                        </tr>

                           <tr>

                            <td bgcolor="#ffffff"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?><a href="<?php echo $PHP_SELF; ?>?action=track&tracknum=<?php echo $tracknum; ?>"><?php echo tep_image(DIR_WS_IMAGES . 'btn_back_summary.gif', 'Back to Summary', '158', '14'); ?></a></td>

                           </tr>

                        <tr>

                            <td><div  class="modulepad"><br></div></td>

                        </tr>

                    </table>

                    <table bgcolor="#ffffff" border="0" cellpadding="0" cellspacing="0">

<?php

       if (isset($message)) {

         echo '    <tr>' . "\n";

         echo '     <td align="center" bgcolor="#ffffff" colspan="5"><span class="greetUser">' . $message . '</span></td>' . "\n";

         echo '     </tr>' . "\n";

         echo '   </table>' . "\n";

         echo '  </td>' . "\n";

         echo ' </tr>' . "\n";

         echo '</table>' . "\n";

       } elseif (isset($errorMsg)) {

         echo '     <tr>' . "\n";

         echo '        <td align="center" bgcolor="#ffffff" colspan="5"><span class="greetUser">' . $errorMsg . '</span></td>' . "\n";

         echo '     </tr>' . "\n";

         echo '         </table>' . "\n";

         echo '  </td>' . "\n";

         echo ' </tr>' . "\n";

         echo '</table>' . "\n";

       } else {

?>

                        <tr>

                            <td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

                            <td nowrap ALIGN="left" valign="top" class="ups"><b>Packages in Shipment:</b></td>

                            <td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

                            <td ALIGN="LEFT" VALIGN="TOP" width="100%" class="ups"><?php echo $_GET['p']; ?></td>

                            <td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

                        </tr>

                           <tr>

                            <td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

                            <td nowrap ALIGN="left" valign="top" class="ups"><b>Service Type:</b></td>

                            <td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

                            <td ALIGN="LEFT" VALIGN="TOP" width="100%" class="ups"><?php echo $ServiceType; ?></td>

                            <td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

                        </tr>

                           <tr>

                            <td bgcolor="#ffffff" colspan="5"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '8'); ?></td>

                        </tr>

                       </table>

                       <table border="0" cellpadding="0" cellspacing="0" width="100%">

                        <tr>

                            <td bgcolor="#cccccc"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '210', '8'); ?></td>

                            <td bgcolor="#ffffff"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '1'); ?></td>

                            <td bgcolor="#cccccc"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '100', '1'); ?></td>

                            <td bgcolor="#ffffff"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '1'); ?></td>

                            <td bgcolor="#cccccc"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '252', '1'); ?></td>

                        </tr>

                        <tr>

                            <td bgcolor="#cccccc" class="ups"><div class="spacing"><b>Tracking Number</b></div></td>

                            <td bgcolor="#ffffff"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '8'); ?></td>

                            <td bgcolor="#cccccc" class="ups"><div class="spacing"><b>Status</b></div></td>

                            <td bgcolor="#ffffff"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '8'); ?></td>

                            <td bgcolor="#cccccc" class="ups"><div class="spacing"><b>Delivery Information</b></div></td>

                        </tr>

                        <tr>

                            <td bgcolor="#cccccc"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '8'); ?></td>

                            <td bgcolor="#ffffff"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '1'); ?></td>

                            <td bgcolor="#cccccc"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '1'); ?></td>

                            <td bgcolor="#ffffff"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '1'); ?></td>

                            <td bgcolor="#cccccc"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '1'); ?></td>

                        </tr>

                        <tr>

                            <td bgcolor="#ffffff" colspan="5"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '8'); ?></td>

                        </tr>

<?php

// loop through all the tracking codes associated with the submitted tracking code and read the

// status of each one

       $number = '0';

       $root = $doc->getRoot();

       $shipment = $root->getElementsByName("Shipment");

      for ($i = 0; $i < count($shipment); $i++) {

         $package = $shipment[$i]->getElementsByName("Package");

         for ($j = 0; $j < count($package); $j++) {

           $tracknum = $package[$j]->getValueByPath("/TrackingNumber");

           $number++;

           if (($number/2) == floor($number/2)) {

             $color = '#cccccc';

           } else {

             $color = '#ffffff';

           }

           $Activity = $package[$j]->getElementsByName("Activity");

           for ($k = 0; $k < count($Activity); $k++) {

             $Status = $Activity[$k]->getValueByPath("/Status/StatusType/Code");

             switch ($Status) {

               case 'I':

                 $status = 'In Transit';

               break;

               case 'D':

                 $status = 'Delivered';

                 $DeliverDate = $Activity[$k]->getValueByPath("/Date");

                 $DeliverDate = formatDate($DeliverDate);

                 $DeliverTime = $Activity[$k]->getValueByPath("/Time");

                 $DeliverTime = formatTime($DeliverTime);

                 $DeliverDate .= ' ' . $DeliverTime;

                 $SignedBy = $Activity[$k]->getValueByPath("/ActivityLocation/SignedForByName");

               break;

               case 'X':

                 $status = 'Exception';

               break;

               case 'P':

                 $status = 'Pickup';

               break;

               case 'M':

                 $status = 'Billing Information Received';

               break;

             }

             if ($Status == 'D') {

               $ActivityData = array($tracknum, $status, $DeliverDate, $DeliverTo, $SignedBy);

               echo '<tr><td bgcolor="' . $color . '" colspan="5">' . tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '4') . '</td></tr>' . "\n";

               echo '<tr bgcolor="' . $color . '">' . "\n";

               echo ' <td VALIGN="top" class="ups"><div class="modulepad">' . $ActivityData[0] . '<br>' . tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '1') . '<a href="' . $PHP_SELF . '?action=track&tracknum=' . $tracknum . '&show=detail&p=' . $p . '">' . tep_image(DIR_WS_IMAGES . 'btn_details.gif', 'Detail', '44', '14') . '</a></div></td>' . "\n";

               echo ' <td valign="top">' . tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '8') . '</td>' . "\n";

               echo ' <td VALIGN="top" class="ups"><div class="modulepad"><b>' . $ActivityData[1] . '</b></div></td>' . "\n";

               echo ' <td valign="top">' . tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '8') . '</td>' . "\n";

               echo ' <td VALIGN="top" class="upsSmall"><div class="modulepad">' . "\n";

               echo '    <table width="100%" border="0" cellspacing="0" cellpadding="0">' . "\n";

               echo '       <tr><td valign="top" class="upsSmall">Delivered on: </td><td valign="top" class="upsSmall">' . $ActivityData[2] . '</td></tr>' . "\n";

               echo '       <tr><td valign="top" class="upsSmall">Delivered to: </td><td valign="top" class="upsSmall">' . $ActivityData[3] . '</td></tr>' . "\n";

               echo '       <tr><td valign="top" class="upsSmall">Signed by: </td><td valign="top" class="upsSmall">' . $ActivityData[4] . '</td></tr>' . "\n";

               echo '    </table></div></td>' . "\n";

               echo '</tr>' . "\n";

               echo '<tr><td bgcolor="' . $color . '" colspan="5">' . tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '4') . '</td></tr>' . "\n";

             } else {

               $ActivityData = array($tracknum, $status, $ScheduledDeliveryDate, $Activity[$k]->getValueByPath("/ActivityLocation/Address/City") == 'US' ? 'US' : $Activity[$k]->getValueByPath("/ActivityLocation/Address/City") . ', ' . $Activity[$k]->getValueByPath("/ActivityLocation/Address/StateProvinceCode"));

               echo '<tr><td bgcolor="' . $color . '" colspan="5">' . tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '4') . '</td></tr>' . "\n";

               echo '<tr bgcolor="' . $color . '">' . "\n";

               echo ' <td VALIGN="top" class="ups"><div class="modulepad">' . $ActivityData[0] . '<br>' . tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '1') . '<a href="' . $PHP_SELF . '?action=track&tracknum=' . $tracknum . '&show=detail&p=' . $p . '">' . tep_image(DIR_WS_IMAGES . 'btn_details.gif', 'Detail', '44', '14') . '</a></div></td>' . "\n";

               echo ' <td valign="top">' . tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '8') . '</td>' . "\n";

               echo ' <td VALIGN="top" class="ups"><div class="modulepad"><b>' . $ActivityData[1] . '</b></div></td>' . "\n";

               echo ' <td valign="top">' . tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '8') . '</td>' . "\n";

               echo ' <td VALIGN="top" class="upsSmall"><div class="modulepad">' . "\n";

               echo '    <table width="100%" border="0" cellspacing="0" cellpadding="0">' . "\n";

               echo '       <tr><td valign="top" class="upsSmall">Sched. Delivery: </td><td valign="top" class="upsSmall">' . $ActivityData[2] . '</td></tr>' . "\n";

               echo '       <tr><td valign="top" class="upsSmall">Location: </td><td valign="top" class="upsSmall">' . $ActivityData[3] . '</td></tr>' . "\n";

               echo '    </table></div></td>' . "\n";

               echo '</tr>' . "\n";

               echo '<tr><td bgcolor="' . $color . '" colspan="5">' . tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '4') . '</td></tr>' . "\n";

             }

           }

         }

       }

?>

                           <tr>

                   <td bgcolor="#ffffff" colspan="5"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '8'); ?></td>

               </tr>

                  <tr>

                            <td bgcolor="#ffffff" colspan="5" class="ups"><div class="modulepad"><?php echo tep_image(DIR_WS_IMAGES . 'dotted_rule.gif', '', '544', '1', 'vspace="8"'); ?><br>

                            Tracking results provided by UPS: <?php echo strftime(DATE_FORMAT_LONG) . ' ' . $time_now . ' ' . $timezone; ?><br><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '8'); ?><br></div></td>

                        </tr>

                       </table>

                </td>

               </tr>

           </table>

<?

     }

     break;

 

     case 'detail':

       $Status = $doc->getValueByPath('TrackResponse/Shipment/Package/Activity/Status/StatusType/Code');

       switch ($Status) {

         case 'I':

           $status = 'In Transit';

         break;

         case 'D':

           $status = 'Delivered';

           $DeliverDate = $doc->getValueByPath('TrackResponse/Shipment/Package/Activity/Date');

           $DeliverDate = formatDate($DeliverDate);

           $DeliverTime = $doc->getValueByPath('TrackResponse/Shipment/Package/Activity/Time');

           $DeliverTime = formatTime($DeliverTime);

           $DeliverDate .= ' ' . $DeliverTime;

           $SignedBy = $doc->getValueByPath('TrackResponse/Shipment/Package/Activity/ActivityLocation/SignedForByName');

           $Location = $doc->getValueByPath('TrackResponse/Shipment/Package/Activity/ActivityLocation/Description');

         break;

         case 'X':

           $status = 'Exception';

         break;

         case 'P':

           $status = 'Pickup';

         break;

         case 'M':

           $status = 'Billing Information Received';

         break;

       }

// fix to make weight display properly begin -- This fix was contributed by Teddy Caddy

       $Weight = substr($doc->getValueByPath('TrackResponse/Shipment/Package/PackageWeight/UnitOfMeasure/Code'), 3, 5) . ' ' . substr($doc->getValueByPath('TrackResponse/Shipment/Package/PackageWeight/UnitOfMeasure/Code'), 0, 3);

// end of fix to make weight display properly

?>

           <table class="appheadercolor" border="0" cellpadding="1" cellspacing="0" width="575">

            <tr>

                <td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '8', '4'); ?></td>

                <td height="20" width="100%"><span class="UPSheader2">View Details</span></td>

            </tr>

        </table>

        <table bgcolor="#cccccc" border="0" cellpadding="1" cellspacing="0" width="575">

            <tr>

                <td>

                    <table bgcolor="#ffffff" border="0" cellpadding="0" cellspacing="0" width="100%">

                        <tr>

                            <td bgcolor="#ffffff"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '4'); ?></td>

                        </tr>

                           <tr>

                            <td bgcolor="#ffffff"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?><a href="<?php echo $PHP_SELF; ?>?action=track&tracknum=<?php echo $tracknum; ?>"><?php echo tep_image(DIR_WS_IMAGES . 'btn_back_summary.gif', 'Back to Summary', '158', '14'); ?></a></td>

                           </tr>

                        <tr>

                            <td><div  class="modulepad"><br></div></td>

                        </tr>

                    </table>

                    <table bgcolor="#ffffff" border="0" cellpadding="0" cellspacing="0">

<?php

       if (isset($message)) {

         echo '    <tr>' . "\n";

         echo '     <td align="center" bgcolor="#ffffff" colspan="5"><span class="greetUser">' . $message . '</span></td>' . "\n";

         echo '     </tr>' . "\n";

         echo '   </table>' . "\n";

         echo '  </td>' . "\n";

         echo ' </tr>' . "\n";

         echo '</table>' . "\n";

       } elseif (isset($errorMsg)) {

         echo '     <tr>' . "\n";

         echo '        <td align="center" bgcolor="#ffffff" colspan="5"><span class="greetUser">' . $errorMsg . '</span></td>' . "\n";

         echo '     </tr>' . "\n";

         echo '         </table>' . "\n";

         echo '  </td>' . "\n";

         echo ' </tr>' . "\n";

         echo '</table>' . "\n";

       } else {

?>

                        <tr>

                            <td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

                            <td nowrap ALIGN="left" valign="top" class="ups"><b>Status:</b></td>

                            <td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

                            <td ALIGN="LEFT" VALIGN="TOP" width="100%" class="ups"><?php echo $status; ?></td>

                            <td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

                        </tr>

<?php

       if ($Status == 'D') {

?>

                        <tr>

                            <td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

                            <td nowrap ALIGN="left" class="ups"><b>Delivered on:</b></td>

                            <td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

                            <td ALIGN="LEFT" VALIGN="BOTTOM" width="100%" class="ups"><?php echo $DeliverDate; ?></td>

                            <td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

                        </tr>

                        <tr>

                            <td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

                            <td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

                            <td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

                            <td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

                            <td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

                        </tr>

<?php

         if (isset($SignedBy) || strlen($SignedBy > 0)) {

?>

                        <tr>

                            <td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

                            <td nowrap ALIGN="left" class="ups"><b>Signed by:</b></td>

                            <td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

                            <td ALIGN="LEFT" VALIGN="BOTTOM" width="100%" class="ups"><?php echo $SignedBy; ?></td>

                            <td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

                        </tr>

<?php

         }

?>

                        <tr>

                            <td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

                            <td nowrap ALIGN="left" class="ups"><b>Location:</b></td>

                            <td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

                            <td ALIGN="LEFT" VALIGN="BOTTOM" width="100%" class="ups"><?php echo $Location; ?></td>

                            <td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

                        </tr>

<?php

       } elseif ($Status != 'D') {

?>

                           <tr>

                            <td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

                            <td nowrap ALIGN="left" class="ups"><b>Scheduled Delivery Date:</b></td>

                            <td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

                            <td ALIGN="LEFT" VALIGN="BOTTOM" width="100%" class="ups"><?php echo $ScheduledDeliveryDate; ?></td>

                            <td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

                        </tr>

<?php

       }

?>

                           <tr>

                            <td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

                            <td nowrap ALIGN="left" class="ups"><b>Shipped to:</b></td>

                            <td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

                            <td ALIGN="LEFT" VALIGN="BOTTOM" width="100%" class="ups"><?php echo $DeliverTo; ?></td>

                            <td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

                        </tr>

      <tr>

                            <td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

                            <td nowrap ALIGN="left" class="ups"><b>Shipped or Billed on:</b></td>

                            <td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

                            <td ALIGN="LEFT" VALIGN="BOTTOM" width="100%" class="ups"><?php echo $PickupDate; ?></td>

                            <td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

                        </tr>

                           <tr>

                            <td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

                            <td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?><br><br></td>

                            <td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

                            <td width="100%"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

                            <td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

                        </tr>

                        <tr>

                            <td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

                            <td nowrap ALIGN="left" class="ups"><b>Tracking Number:</b></td>

                            <td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

                            <td ALIGN="LEFT" VALIGN="BOTTOM" width="100%" class="ups"><?php echo $tracknum; ?></td>

                            <td><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '10', '1'); ?></td>

                        </tr><

Link to comment
Share on other sites

  • 3 weeks later...

Howdy Folks

 

I am trying to install the contribution to a CRE6 installation that I am using.

 

I have successfully setup most everything. When I add a UPS Tracking number in the edit orders admin section, it is added to the db and the user can find the link in their order history; however, if you click the tracking number, a window pops up with nothing and the following source code:

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html dir="LTR" lang="en">
<head>
<title>UPS Tracking</title>
<base href="http://mywebsite.com/">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<script language="javascript"><!--
var i=0;
function resize() {
 if (navigator.appName == 'Netscape') i=40;
}
//--></script>
</head>
<body>
<center>
<table border="0" width="625" cellpadding="3" cellspacing="0">
<tr>
 <td align="left" width="100%" class="main">

 </td>
</tr>
</table>
</center>
</body>
</html>

I also got the following error log

PHP Parse error:  parse error in /var/www/vhosts/mywebsite.com/htdocs/includes/classes/tracking.php on line 57

Line 57 is:

$xmlResponse = "<?xml version="1.0"?>n".

I had recently added the 13 Apr 2004 - CLI compatible code after I determined that I need it.

 

Any ideas as to what I need to do to get this working? :P

Link to comment
Share on other sites

Line 57 is:

$xmlResponse = "<?xml version="1.0"?>n".

I had recently added the 13 Apr 2004 - CLI compatible code after I determined that I need it.

 

Any ideas as to what I need to do to get this working? :P

what kind of info do you see if you comment out the line

 

error_reporting(0);

 

in classes/tracking.php?

 

You are getting a parse error on line 57 because there are too many " (quotes). It should look like:

 

$xmlResponse = "<?xml version=\"1.0\" ?>\n".

 

are you sure you have openssl support?

Do you ship UPS?

Give your customers order tracking without leaving your site. Track multi-package shipments. XML, cURL

 

Download the contribution here:

UPS Tracking

Link to comment
Share on other sites

Hi Steve,

I just installed your contribution and it appears to be working. However, when I enter in a customer's tracking number I get:

 

151018: Invalid tracking number

 

When I enter the Tracking Code you posted earlier in this thread (1Z6107920342146506) I appear to get legitimate results. So, I'm wondering if I have something setup incorrectly. Is there a way I can tell for certain that I have the contribution installed correctly?

 

Thanks for your work on this contribution.

 

Jay

Link to comment
Share on other sites

Hi Steve,

I just installed your contribution and it appears to be working. However, when I enter in a customer's tracking number I get:

 

151018: Invalid tracking number

 

When I enter the Tracking Code you posted earlier in this thread (1Z6107920342146506) I appear to get legitimate results. So, I'm wondering if I have something setup incorrectly. Is there a way I can tell for certain that I have the contribution installed correctly?

 

Thanks for your work on this contribution.

 

Jay

There isn't anything wrong with the installation because you are getting valid results with valid tracking numbers. I tried a bunch of tracking numbers on your site and they all worked just fine...double-check your customer's tracking numbers becuase they obviously aren't valid. Are you sure they aren't reference numbers? This contrib. can only track UPS-generated codes

Do you ship UPS?

Give your customers order tracking without leaving your site. Track multi-package shipments. XML, cURL

 

Download the contribution here:

UPS Tracking

Link to comment
Share on other sites

Sorry Steve. It looks like when I copied the tracking number into the box (with spaces) it cut off some digits which is why I was getting the "Invalid number" message. When I copy the number without spaces it works fine.

 

Thanks again for this terrific contribution.

Link to comment
Share on other sites

Sorry Steve. It looks like when I copied the tracking number into the box (with spaces) it cut off some digits which is why I was getting the "Invalid number" message. When I copy the number without spaces it works fine.

 

Thanks again for this terrific contribution.

no problem. you ought to upgrade your /classes/tracking.php to the multi-package version (see the contrib. section for the download). Use the tracking code below on your site and then try it on my site to see the difference.

 

1Z6107920348043339

 

As you'll see, if a shipment contains more than one package then tracking.php will return all codes and tracking data associated with the shipment...look for the Show All link under Deliver Information

Do you ship UPS?

Give your customers order tracking without leaving your site. Track multi-package shipments. XML, cURL

 

Download the contribution here:

UPS Tracking

Link to comment
Share on other sites

I have installed this great contribution and everything works great. The only problem I am having is that when you click on the link from the order history screen the popup_tracking.php page is always blank.

 

The tracking.php page where you manually enter a tracking number works fine.

 

I have reinstalled twice and even tried to find what the eror might be on my part, but am at a loss.

 

Any assistance would be very helpful.

 

PM me and I will send you any links or code you need.

Link to comment
Share on other sites

  • 2 weeks later...

This is a great contribution. Thanks

 

Is there any way to be able to configure the contribution to use more than one tracking number. THe reason for this is may be split orderes, backordered items.

 

I have playing around with it, but I can't seem to get alot of sucess.

 

 

THanks

Moneer

Link to comment
Share on other sites

Does anyone find this contrib works with non-US orders? I have tried entering a UPS tracking number for Canada, and I get the error:

 

151044 : No tracking information available

The code may not be in the UPS system yet. Please try again later.

 

 

This package was delivered a week ago, and if you go to the UPS site to track it, all the details are there. I have used the tracking numbers posted here to make sure the contrib is working, and it does work, but all the ones here are US deliveries. This has lead me to wonder if maybe there is a country code that needs to be set in the data sent to the UPS servers. Any help or suggestions would be greatly appreciated.

 

 

Thanks.

 

And before you ask for it, the address for the site is http://www.silverdolphin.ca/store/ so you can verify my code is working.

 

thanks.

 

Greg

Link to comment
Share on other sites

hmmm...I'll have to look into this one. can you send me a tracking code so I can use it for testing? PM me if you don't want to post it here...

Do you ship UPS?

Give your customers order tracking without leaving your site. Track multi-package shipments. XML, cURL

 

Download the contribution here:

UPS Tracking

Link to comment
Share on other sites

  • 4 weeks later...

Hi steve,

 

Appears to be a great contrib.

I've installed it, and it seems to work until there should be some qoutes, but I get no results.

This is what I get from the UPS servers : There seems to be a communication error with the UPS servers. Please contact the webmaster of this site to report this error.

I'm using both one of my own tracking numbers as well as the one you mentioned at the beginning of this thread.

 

I do think that I have cURL running on my providers servers, but i'm not sure if thats working ok.

Is there a way to check wether there is communication between my server and UPS's?

I changed the line error_reporting(1); but there seems not to be happening anything.

Link to comment
Share on other sites

Does anyone have a UPS tracking code that originated outside the US and contains multiple packages? I need one for testing purposes. Thanks.

Do you ship UPS?

Give your customers order tracking without leaving your site. Track multi-package shipments. XML, cURL

 

Download the contribution here:

UPS Tracking

Link to comment
Share on other sites

After lengthy discussions with techs. at UPS I decided to change to code a bit to avoid possible problems caused by admitted inconsistencies between the UPS database servers. In some cases the data available to the XML Tracking program (such as this contrib.) may vary depending on which database it is coming from. UPS is still ironing out some wrinkles that cause odd behavior on the user's end. Some "wrinkles" are unavaoidable at this time but others should be alleviated by the code changes in the new file. The main change is the introduction of output buffering coupled with a callback function. Normally the XML request uses a container called <ShipmentIdentificationNumber> (which is the tracking code) to check for multiple packages. In some cases, if a shipment has only one package, the request will fail. In other cases it will work just fine. Upon failure, the callback function allows the code to automatically resend the request this time using the container <TrackingCode> which should then return valid results or valid errors.

 

Get it here

Do you ship UPS?

Give your customers order tracking without leaving your site. Track multi-package shipments. XML, cURL

 

Download the contribution here:

UPS Tracking

Link to comment
Share on other sites

Hi Steve,

Thanks for the nice contribution! It worked really well for order tracking. However, after I applied the last minor update (2004-Jul-15), it stopped working. It will keep coming back to the first query page.

 

By the way, which part of programming code that you use to calculate the shipping fee? I tried UPS rate & time calculation on UPS site and tested this same address on my site, they gave me different rates. I don't know which parameters should be changed to make them the same? (There are many options on UPS site, such as 'redential pickup', UPS daily pickup, and other options.)

 

Can you give me a hand here? Many thanks!! :)

Edited by stonez
Link to comment
Share on other sites

Hi Steve,

Sorry, I found out those options I mentioned-above are in the admin area and all controllable. Thanks!

 

I test the UPS function and found out the shipping costs from your moudle is less than that of UPS site. In UPS site, it has an item called 'Delivery Area Surcharge', but not in your module. Is there anywhere I can set this option or add this option?

 

Many thanks!

Edited by stonez
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...