Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] UPS XML Tracking


heliosquare

Recommended Posts

Chris,

Do you have my tracking.php file in your /classes/ directory? The original tracking.php file did the same thing for me which is why I re-wrote it...

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

  • Replies 324
  • Created
  • Last Reply

Top Posters In This Topic

Sure do.

 

<?php
/*
?$Id: tracking.php,v 1.00 2003/11/04 10:55:00 steveyeazel Exp $

 

It's only being "required" or "included" by the popup_tracker.php file. Is that correct?

 

 

Thanks,

-Chris

Edited by blueline

Chris Sullivan

Link to comment
Share on other sites

no, that is not correct. The main tracking.php page needs that file included as well...can I see the code for that page? (the page you linked to above)

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

ok, if you give me a few days I'll post a full-fledged 2.2MS2 version...don't have much spare time but hopefully in the next 3 days or so I'll find the time...

Man I would really appreciate that. Only if it's not too much trouble, don't want to impose too much :)

Link to comment
Share on other sites

Sure. Here ya go:

 

/catalog/includes/classes/tracking.php

<?php

/*

 $Id: tracking.php,v 1.00 2003/11/04 10:55:00 steveyeazel Exp $

 

 Copyright (c) 2003 Steve Yeazel

 

 This program is free software; you can redistribute it and/or modify it under the terms

 of the GNU General Public License as published by the Free Software Foundation; either

 version 2 of the License, or (at your option) any later version.

 

 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;

 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

 See the GNU General Public License for more details.

 

 You should have received a copy of the GNU General Public License along with this program;

 If not, you may obtain one by writing to and requesting one from

 

The Free Software Foundation, Inc.,

59 Temple Place, Suite 330,

Boston, MA 02111-1307 USA

*/

 

/*

 Written by Steve Yeazel.

 

 Some code/style borrowed from Torin Walker's UPS XML Rates and Wayne Wetterhahn's UPS Order Tracking XML.

*/

 

 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 = "user";//your username";  // The username from UPS

   $pass = "pass";//your password";  // The password from UPS

   $access_key = "key";//your access key";  // XML license key from UPS

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

     $activity = "activity";

   } else {

     $activity = "none";

   }

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

   $protocol = 'https';

$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_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);

 

     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>0</ResponseStatusCode>\n".

       "    <ResponseStatusDescription>There seems to be a communication error with the UPS servers.  Please contact our webmaster 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);

 

$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;

   $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 != '1') {

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

  $errorMsg .= ": ";

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

   }

 

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

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

   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;

   }

 

   $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');

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

?>

           <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"><img alt="" border="0" height="19" src="/images/bar_code.gif" width="31"></td>

                <td><div class="upscom"><img alt="" height="1" src="/images/pixel_trans.gif" width="10"></div></td>

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

            </tr>

            <tr>

                <td colspan="3"><img alt="" border="0" height="12" src="/images/pixel_trans.gif" width="1"></td>

            </tr>

        </table>

<?php

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

?>

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

            <tr>

                <td><img alt="" border="0" height="4" src="/images/pixel_trans.gif" width="8"></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"><img alt="" height="4" src="/images/pixel_trans.gif" width="1"></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><img alt="" border="0" height="1" src="/images/pixel_trans.gif" width="10"></td><td colspan="4" align="left" bgcolor="#ffffff" width="100%"><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><img alt="" border="0" height="1" src="/images/pixel_trans.gif" width="10"></td><td colspan="4" align="left" bgcolor="#ffffff" width="100%"><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><img alt="" border="0" height="1" src="/images/pixel_trans.gif" width="10"></td>

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

                            <td><img alt="" border="0" height="1" src="/images/pixel_trans.gif" width="10"></td>

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

                            <td><img alt="" border="0" height="1" src="/images/pixel_trans.gif" width="10"></td>

                        </tr>

<?php

 if ($Status == 'D') {

?>

                        <tr>

                            <td><img alt="" border="0" height="1" src="/images/pixel_trans.gif" width="10"></td>

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

                            <td><img alt="" border="0" height="1" src="/images/pixel_trans.gif" width="10"></td>

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

                            <td><img alt="" border="0" height="1" src="/images/pixel_trans.gif" width="10"></td>

                        </tr>

                        <tr>

                            <td><img alt="" border="0" height="1" src="/images/pixel_trans.gif" width="10"></td>

                            <td><img alt="" border="0" height="1" src="/images/pixel_trans.gif" width="10"></td>

                            <td><img alt="" border="0" height="1" src="/images/pixel_trans.gif" width="10"></td>

                            <td><img alt="" border="0" height="1" src="/images/pixel_trans.gif" width="10"></td>

                            <td><img alt="" border="0" height="1" src="/images/pixel_trans.gif" width="10"></td>

                        </tr>

<?php

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

?>

                        <tr>

                            <td><img alt="" border="0" height="1" src="/images/pixel_trans.gif" width="10"></td>

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

                            <td><img alt="" border="0" height="1" src="/images/pixel_trans.gif" width="10"></td>

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

                            <td><img alt="" border="0" height="1" src="/images/pixel_trans.gif" width="10"></td>

                        </tr>

<?php

   }

?>

                        <tr>

                            <td><img alt="" border="0" height="1" src="/images/pixel_trans.gif" width="10"></td>

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

                            <td><img alt="" border="0" height="1" src="/images/pixel_trans.gif" width="10"></td>

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

                            <td><img alt="" border="0" height="1" src="/images/pixel_trans.gif" width="10"></td>

                        </tr>

<?php

 }

?>

                        <tr>

                            <td><img alt="" border="0" height="1" src="/images/pixel_trans.gif" width="10"></td>

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

                            <td><img alt="" border="0" height="1" src="/images/pixel_trans.gif" width="10"></td>

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

                            <td><img alt="" border="0" height="1" src="/images/pixel_trans.gif" width="10"></td>

                        </tr>

      <tr>

                            <td><img alt="" border="0" height="1" src="/images/pixel_trans.gif" width="10"></td>

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

                            <td><img alt="" border="0" height="1" src="/images/pixel_trans.gif" width="10"></td>

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

                            <td><img alt="" border="0" height="1" src="/images/pixel_trans.gif" width="10"></td>

                        </tr>

                           <tr>

                            <td><img alt="" border="0" height="1" src="/images/pixel_trans.gif" width="10"></td>

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

                            <td><img alt="" border="0" height="1" src="/images/pixel_trans.gif" width="10"></td>

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

                            <td><img alt="" border="0" height="1" src="/images/pixel_trans.gif" width="10"></td>

                        </tr>

                        <tr>

                            <td><img alt="" border="0" height="1" src="/images/pixel_trans.gif" width="10"></td>

                            <td><img alt="" border="0" height="1" src="/images/pixel_trans.gif" width="10"><br><br></td>

                            <td><img alt="" border="0" height="1" src="/images/pixel_trans.gif" width="10"></td>

                            <td width="100%"><img alt="" border="0" height="1" src="/images/pixel_trans.gif" width="10"></td>

                            <td><img alt="" border="0" height="1" src="/images/pixel_trans.gif" width="10"></td>

                        </tr>

                        <tr>

                            <td><img alt="" border="0" height="1" src="/images/pixel_trans.gif" width="10"></td>

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

                            <td><img alt="" border="0" height="1" src="/images/pixel_trans.gif" width="10"></td>

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

                            <td><img alt="" border="0" height="1" src="/images/pixel_trans.gif" width="10"></td>

                        </tr>

                        <tr>

                            <td><img alt="" border="0" height="1" src="/images/pixel_trans.gif" width="10"></td>

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

                            <td><img alt="" border="0" height="1" src="/images/pixel_trans.gif" width="10"></td>

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

                            <td><img alt="" border="0" height="1" src="/images/pixel_trans.gif" width="10"></td>

                        </TR>

                        <tr>

                            <td><img alt="" border="0" height="1" src="/images/pixel_trans.gif" width="10"></td>

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

                            <td><img alt="" border="0" height="1" src="/images/pixel_trans.gif" width="10"></td>

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

                            <td><img alt="" border="0" height="1" src="/images/pixel_trans.gif" width="10"></td>

                        </tr>

                           <tr>

                            <td colspan="5" width="100%"><img alt="" border="0" height="1" src="/images/pixel_trans.gif" width="10"></td>

                        </tr>

                    </table>

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

                        <tr>

                            <td colspan="7"><div class="modulepad"><img alt="" border="0" height="1" src="/images/dotted_rule.gif" vspace="8" width="544"><br></div></td>

                        </tr>

                        <tr>

                            <td bgcolor="#ffffff" colspan="7"><div class="modulepad"><img alt="" border="0" height="4" src="/images/pixel_trans.gif" width="1"><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"><img alt="" height="8" src="/images/pixel_trans.gif" width="95"></td>

                            <td bgcolor="#ffffff"><img alt="" height="8" src="/images/pixel_trans.gif" width="1"></td>

                            <td bgcolor="#cccccc"><img alt="" height="8" src="/images/pixel_trans.gif" width="80"></td>

                            <td bgcolor="#ffffff"><img alt="" height="8" src="/images/pixel_trans.gif" width="1"></td>

                            <td bgcolor="#cccccc"><img alt="" height="8" src="/images/pixel_trans.gif" width="186"></td>

                            <td bgcolor="#ffffff"><img alt="" height="8" src="/images/pixel_trans.gif" width="1"></td>

                            <td bgcolor="#cccccc"><img alt="" height="8" src="/images/pixel_trans.gif" width="200"></td>

                        </tr>

                        <tr>

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

                            <td bgcolor="#ffffff"><img alt="" height="8" src="/images/pixel_trans.gif" width="1"></td>

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

                            <td bgcolor="#ffffff"><img alt="" height="8" src="/images/pixel_trans.gif" width="1"></td>

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

                            <td bgcolor="#ffffff"><img alt="" height="8" src="/images/pixel_trans.gif" width="1"></td>

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

                        </tr>

                        <tr>

                            <td bgcolor="#cccccc"><img alt="" height="8" src="/images/pixel_trans.gif" width="1"></td>

                            <td bgcolor="#ffffff"><img alt="" height="8" src="/images/pixel_trans.gif" width="1"></td>

                            <td bgcolor="#cccccc"><img alt="" height="8" src="/images/pixel_trans.gif" width="1"></td>

                            <td bgcolor="#ffffff"><img alt="" height="8" src="/images/pixel_trans.gif" width="1"></td>

                            <td bgcolor="#cccccc"><img alt="" height="8" src="/images/pixel_trans.gif" width="1"></td>

                            <td bgcolor="#ffffff"><img alt="" height="8" src="/images/pixel_trans.gif" width="1"></td>

                            <td bgcolor="#cccccc"><img alt="" height="8" src="/images/pixel_trans.gif" width="1"></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"><img alt="" height="8" src="/images/pixel_trans.gif" width="1"></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"><img alt="" height="8" src="/images/pixel_trans.gif" width="1"></td>' . "\n";

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

           echo ' <td valign="top"><img alt="" height="8" src="/images/pixel_trans.gif" width="1"></td>' . "\n";

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

           echo ' <td valign="top"><img alt="" height="8" src="/images/pixel_trans.gif" width="1"></td>' . "\n";

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

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

         }

       }

     }

?>

                       </table>

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

                        <tr>

                            <td bgcolor="#ffffff" colspan="7"><img alt="" height="8" src="/images/pixel_trans.gif" width="1"></td>

                        </tr>

                        <tr>

                            <td bgcolor="#ffffff" colspan="7" class="ups"><div class="modulepad">Tracking results provided by UPS: <?php echo strftime(DATE_FORMAT_LONG) . ' ' . $time_now . ' ' . $timezone; ?><img alt="" height="8" src="/images/pixel_trans.gif" width="1"><br></div></td>

                        </tr>

                        <tr>

                            <td bgcolor="#ffffff" colspan="7"><img alt="" height="8" src="/images/pixel_trans.gif" width="1"></td>

                        </tr>

                    </table>

                </td>

            </tr>

        </table>

<?php

 }

 } else {

?>

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

   <tr>

       <td height="20"><span class="UPSheader2"><img alt="" height="1" src="/images/pixel_trans.gif" width="10">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><img alt="" height="8" src="/images/pixel_trans.gif" width="1"></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><img alt="" height="8" src="/images/pixel_trans.gif" width="1"></td>

                        </tr>

                    </table>

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

                        <tr>

                            <td bgcolor="#cccccc"><img alt="" height="8" src="/images/pixel_trans.gif" width="210"></td>

                            <td bgcolor="#ffffff"><img alt="" height="1" src="/images/pixel_trans.gif" width="1"></td>

                            <td bgcolor="#cccccc"><img alt="" height="1" src="/images/pixel_trans.gif" width="100"></td>

                            <td bgcolor="#ffffff"><img alt="" height="1" src="/images/pixel_trans.gif" width="1"></td>

                            <td bgcolor="#cccccc"><img alt="" height="1" src="/images/pixel_trans.gif" width="252"></td>

                        </tr>

                        <tr>

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

                            <td bgcolor="#ffffff"><img alt="" height="8" src="/images/pixel_trans.gif" width="1"></td>

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

                            <td bgcolor="#ffffff"><img alt="" height="8" src="/images/pixel_trans.gif" width="1"></td>

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

                        </tr>

                        <tr>

                            <td bgcolor="#cccccc"><img alt="" height="8" src="/images/pixel_trans.gif" width="1"></td>

                            <td bgcolor="#ffffff"><img alt="" height="1" src="/images/pixel_trans.gif" width="1"></td>

                            <td bgcolor="#cccccc"><img alt="" height="1" src="/images/pixel_trans.gif" width="1"></td>

                            <td bgcolor="#ffffff"><img alt="" height="1" src="/images/pixel_trans.gif" width="1"></td>

                            <td bgcolor="#cccccc"><img alt="" height="1" src="/images/pixel_trans.gif" width="1"></td>

                        </tr>

                        <tr>

                            <td bgcolor="#ffffff" colspan="5"><img alt="" height="8" src="/images/pixel_trans.gif" width="1"></td>

                        </tr>

<?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 bgcolor="#ffffff" valign="top" class="ups">

                            <div class="modulepad"><?php echo $tracknum; ?><br><img alt="" height="1" src="/images/pixel_trans.gif" width="1">

                            <a href="<?php echo $PHP_SELF; ?>?action=track&tracknum=<?php echo $tracknum; ?>&show=detail"><img src="/images/btn_lnk_details.gif" WIDTH="44" HEIGHT="14" align="top" border="0" alt="Detail"></a></div></td>

                            <td bgcolor="#ffffff" valign="top"><img alt="" height="8" src="/images/pixel_trans.gif" width="1"></td>

                            <td bgcolor="#ffffff" valign="top" class="ups"><div class="modulepad"><b><?php echo $status; ?></b></div></td>

                            <td bgcolor="#ffffff" valign="top"><img alt="" height="8" src="/images/pixel_trans.gif" width="1"></td>

                            <td bgcolor="#ffffff" valign="top"><div class="modulepad">

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

                                    <tr>

                                        <td><img alt="" height="1" src="/images/pixel_trans.gif" width="96"></td>

                                        <td><img alt="" height="1" src="/images/pixel_trans.gif" width="1"></td>

                                        <td><img alt="" height="1" src="/images/pixel_trans.gif" width="118"></td>

                                    </tr>

<?php

   if ($Status == 'D') {

?>

                                    <tr>

                                        <td valign="top" class="ups">Delivered on:</td>

                 

Edited by blueline

Chris Sullivan

Link to comment
Share on other sites

/catalog/tracking.php

<?php
 require('includes/application_top.php');
 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_TRACKING);
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<meta name="author" content="">
<title><?php echo TITLE; ?></title>
<base href="<?php echo (getenv('HTTPS') == 'on' ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<table border="0" width="770" cellspacing="0" cellpadding="3">
<tr>
  	 <td width="<?php echo BOX_WIDTH; ?>" valign="top">
      	 <table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
     </table>
    	 </td>
       <td width="100%" valign="top">
      	 <table border="0" width="100%" cellspacing="0" cellpadding="0">
      	 <tr>
        	 <td width="100%">
                  	 <table border="0" width="100%" cellspacing="0" cellpadding="0">
            	 <tr>
              	 <td class="prodCatHeading"><?php echo HEADING_TITLE; ?></td>
              	 <td align="right"> </td>
            	 </tr>
           </table>
                   </td>
      	 </tr>
      	 <tr>
        	 <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      	 </tr>
      	 <tr>
        	 <td>
                       <table border="0" width="100%" cellspacing="0" cellpadding="2">
            	 <tr>
              	 <td class="main">
                                   <form method="post" action="<?php echo $PHP_SELF; ?>">
                                   <table border="0" width="100%" cellspacing="0" cellpadding="2">
            	 <tr>
              	 <td align="left" class="main" width="65"><?php echo tep_image(DIR_WS_IMAGES . 'ups_logo.gif'); ?></td>
                                           <td><img src="images/pixel_trans.gif" width="5" height="5"></td>
                                           <td align="left" valign="top" class="main"><b>Enter your UPS tracking number below</b><br><br>
                                           <input type="hidden" name="action" value="track">
                                     <input type="text" name="tracknum" value="<?php echo $tracknum; ?>" maxlength="100" size="20"> 
                                     <input type="submit" name="button" value="Track!"></td>
            	 </tr>
                                   </table>
        	 </form>
                               </td>
                           </tr>
                           <tr>
                   <td>
                    	 <?php include(DIR_WS_CLASSES . FILENAME_TRACKING); ?>
                    	 </td>
                	 </tr>
                       </table>
                   </td>
               </tr>
           </table>
       </td>
   </tr>
</table>
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<br>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

 

There ya go. Thanks.

Chris Sullivan

Link to comment
Share on other sites

check to make sure you have FILENAME_TRACKING inserted in application_top.php. Your tracking.php is failing right where the include is...have a look at the View Source in your browser after entering a value in the input box and you'll see what I mean...

 

you can also try using a hard path instead of the defines in the include:

 

<?php include('includes/classes/tracking.php'); ?>

 

this really shouldn't matter though if you have all of the defines correctly defined...

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

Well, this is weird. I have the definitions correct. The code doesn't seem to get part the <td> tag right before the include statement. All the files are there, and I even tried the hard path to ensure that wasn't the problem. I also checked to make sure the filenames were spelt correctly.

 

Any other ideas?

Thanks,

-Chris

Chris Sullivan

Link to comment
Share on other sites

I'm stumped...I'm going to start working on the MS2.2 version tonight so maybe that release will work for you. I'm also wondering where the hidden input field is coming from on your tracking page that contains the session id...

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

hey blueline, it finally dawned on me to have you try to comment out the following line in /classes/tracking.php:

 

error_reporting(0);

 

I don't think your php build supports cURL. After commenting that line out try entering a tracking code and see what kind of errors you get. If you get something like "call to undefined function curl_init()" then you dont have cURL support. If you don't have cURL support then you are SOL...

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

hey strife,

I started a MS2 version a few days ago and haven't touched it since. give me a couple more days and I'll have it ready to go...

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

helio, you are my savior. I cannot thank you enough for putting in your spare time on this, I really appreciate it.

 

One thing I love about an open source community, people who are knowledgable actually willing to help out us poor noobs. :)

Link to comment
Share on other sites

I'm about ready to scream...I keep getting this error when trying to run a test order:

 

1054 - Unknown column 'customers_company' in 'field list'

 

insert into orders (customers_id, customers_name, customers_company, customers_street_address, customers_suburb, etc, etc...

 

I have looked at admin/includes/classes/order.php AND shop/includes/classes/order.php and have removed BOTH instances of this but I still keep getting the error. "Customers Company" is set to false in my application_top.php. I haven't had this problem until installing this contribution, so where is this coming from?

Am I overlooking something? Do I need to ADD this to my database? Please help!

Link to comment
Share on other sites

Steve,

 

I'm using the latest version of this contribution, UPS Order Tracking XML, and I'm getting this error at the checkout confirmation page.

As I've said, I've removed "customers_company" from admin/includes/classes/order.php, shop/includes/classes/order.php and have even tried removing it from shop/checkout_confirmation.php as well, BUT...

If I remove every instance of "customers_company" from these files, I get the same error again, only this time its "delivery_company" that appears as the error source. And, if I remove THAT from these three files, "billing_name" is the next error I encounter. I also have the require for company set to false in my application_top.php.

In the orders table, in my database, there is no "customers_company" field, no "delivery_company" field and there no occurrences for any billing fields anywhere.

In addition to this problem, I've entered the test tracking number on the tracking page, and it seems to work fine, except that most of the images are not showing (the ones included in the last update), and I'm getting the error "151044: No tracking information available". I tried this test just to see if it works, since I can't seem to get past the "company" errors, etc.

Do I need to update my database with the "company" and all of the billing fields for this contribution to work? It's beginning to look that way...

 

By the way...I'm using a direct download (from my webhost) version of osCommerce 2.2-CVS, and even though I don't know squat about php or mysql, I have been doing well so far...:)

Edited by jwsfun
Link to comment
Share on other sites

I just tried the test tracking number on your site and it returned the tracking info. Could have been UPS returned error 151044 because they were doing something with the system at the time you submitted the form...who knows. The images aren't displaying becuase I didn't use the tep_image() function to call them in the code. I did the first version really fast and posted it before I realized that. My images directory site right under my root while yours is in /root/shop/images. Open /classes/tracking.php and change the path for the images that aren't displaying.

 

I'm almost done with the MS2 version which uses the tep_image() function as well as other functionality and I'll be posting it soon.

 

I'll get back to you regarding the company errors...

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

oh, you are probably using the code from the readme...I was referring to the code I posted on the first page of this thread:

 

1Z6107920342146506

 

I have a feeling you are on a pretty old version of osCom. I don't see any reference to company in application_top.php

 

I know they changed the database tables (added fields, added tables) in more recent versions...you may need to do a bit more work to make the contrib. work with your code. Or you could undo all the changes you made and just use the tracking.php page...

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

Or you could undo all the changes you made and just use the tracking.php page...

 

I'm not sure what you mean, but should I just eliminate all the changes to admin/includes/classes/order.php and shop/includes/classes/order.php? Which changes should be kept?

 

I tried the new number and it worked perfectly. Thanks.

Link to comment
Share on other sites

didn't you go through all the steps as described in the original XML tracking contribution? Those are the changes I was referring to.

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

Steve,

 

Of course I went through all the steps...My question is what changes should be eliminated? You stated that I should just use the tracking.php...HOW can I do that without eliminating the changes made to:

 

account_history_info.php,

includes/application_top.php,

includes/classes/order.php,

includes/languages/english/account_history_info.php,

admin/orders.php,

admin/includes/application_top.php,

admin/includes/classes/order.php,

admin/includes/languages/english/orders.php, OR

admin/includes/functions/html_output.php?

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...