Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] UPS XML Tracking


heliosquare

Recommended Posts

I am having some trouble with this contrib.  I am tracking based on reference number.  Submitted a reference number will sometimes display correct tracking information, but if I resubmit again, it will display incorrectly (large sections of XML will be displayed usually in the location field).

 

When I click on details on a delivered package, the scheduled Delivery date is incorrect.  When I view the returned XML at the command line, there is no 'TrackResponse/Shipment/ScheduledDeliveryDate'.

 

Thanks for any ideas!

UPS returns different info. when a reference number is used and it also requires additional parameters to be passed in the request in order to send back a valid response. This contrib. was written only with UPS-issued tracking codes in mind. The following is from the UPS Developers PDF:

 

When tracking a package using a reference number, the Tracking tool returns information appropriate

to the request. The request parameters are the reference number plus at least one of the following

optional qualifiers: shipper number, pickup date range, destination postal code and destination country

or destination country alone.

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

If your shipments contain more than one package the UPS XML tracking contrib. will now display every package associated with a given tracking code.

 

Download the update here:

Click me

 

Also moved some code around for optimization's sake...

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 -

First off, great work on the contribution, and thanks for being so active in its support.

 

I just installed the contribution (using the next-to-last version - I don't have the multiple package fix you just added) and the back-end stuff seems to be working fine. Tracking numbers are added to the DB as they should be, and they show up in the order history. When I try to actually track, I always get "There seems to be a communication error with the UPS servers. Please contact the webmaster of this site to report this error." I've checked to make sure I've got curl installed correctly, and as far as I can tell, I do. I also made a test.xml and ran curl from the command line, which spit back what looked like a properly formatted XML response from UPS. When I comment out error_reporting(0); no errors come up.

 

I have a feeling this is a really simple boneheaded error that I managed to miss somehow, but any help you can offer in pointing it out would be great.

 

Thanks in advance,

Aaron

Link to comment
Share on other sites

The only situation where you will see "There seems to be a communication error with the UPS servers. Please contact the webmaster of this site to report this error." is when the post() function fails...notably the line $xmlResponse = curl_exec ($ch);

 

Create a new php file and paste the following into it:

<?php

$url = "http://www.frigidfluidco.com";
$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);

if (!xmlResponse) {
?echo 'libcurl isnt working properly!';
} else {
?echo $xmlResponse;
}
?>

 

upload it to your web server and open it with your browser. If it executes properly then you should see my site's home page. If you do see it try changing the $url to https://www.frigidfluidco.com and run it again. Maybe the problem lies with openSSL...

Edited by heliosquare

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 assistance. It loaded the first example fine, and failed when changed to https://. So it's probably a problem with curl's SSL support. I'll see if I can get newer version installed, hopefully that will take care of the problem.

 

Thanks again!

 

Aaron

Link to comment
Share on other sites

The only situation where you will see "There seems to be a communication error with the UPS servers. Please contact the webmaster of this site to report this error." is when the post() function fails...notably the line $xmlResponse = curl_exec ($ch);

 

Create a new php file and paste the following into it:

<?php

$url = "http://www.frigidfluidco.com";
$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);

if (!xmlResponse) {
?echo 'libcurl isnt working properly!';
} else {
?echo $xmlResponse;
}
?>

 

upload it to your web server and open it with your browser. If it executes properly then you should see my site's home page. If you do see it try changing the $url to https://www.frigidfluidco.com and run it again. Maybe the problem lies with openSSL...

ok i have installed it and tried the above code because i get the tracking nr but the popup shows me a blank page.

the error i get with the above code is

Fatal error: Call to undefined function: curl_init() in /home/www/htdocs/showtime4bfg.com/mates/testcurl.php on line 4

does that mean i dont have curl installed???

 

Regards John

Link to comment
Share on other sites

Fatal error: Call to undefined function: curl_init() in /home/www/htdocs/showtime4bfg.com/mates/testcurl.php on line 4

does that mean i dont have curl installed???

 

Regards John

that means you do not have php compiled with libcurl. you may have the command line curl installed. if you do have the command line curl installed you theoretically can get this contrib. to work if you can figure out how to formulate the request using the proper parameters.

 

to run command line curl commands in a php script you would need to do something like:

 

exec(curl -[parameters] );

 

I'm not very familiar with using the command line so I can't really be of much help in that regard...

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

Hello All,

 

I have a problem with this contrib. I have installed it without any problems, and the info box links work and the tracking page works, but when I go to input the tracking number into the admin side, the tracking # does not appear in the e-mail to the customer (should it?) also how do I add the track buttons in the account history and account history info page. I have read the whole post but I am still lost!

 

 

Thanks for any posts

 

-Mike

Link to comment
Share on other sites

The tracking code is not mailed to the customer when you put it into the Admin. I purposefully made it this way because I like the idea of "forcing" the customer to come back to the site, log in and use their "My Account" section in order to track the shipment.

 

When I change the status of an order from Pending or Processing to Delivered (which is also when I insert the tracking code) I copy-n-paste a standard message into the comments text box informing the customer that their order has shipped and give them instructions to log into their account, Click the Order History link and track the order from there.

 

As for adding the track buttons I'm not sure what to tell you. The directions are pretty self-explainatory. I need more details of your problems...

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

Hello,

 

Thanks for the fast reply!!! I found out how to add the buttons to the account history etc.. I have another question. When I click the track button there is a popup but instead of displaying the tracking information it displays the UPS info except where the tracking number is suppose to be there is this:

 

10002: The XML document is well formed but the document is not valid

 

It seems that the link is not passing the Tracking number to the popup window. Any ideas ??

 

 

Thanks for any comments!

 

-Mike

Link to comment
Share on other sites

Hello,

 

I seem to be having the same problem as beemertec had with this code. the Tracking number shows up in the database but not in the account_history and account_history_info pages. Any ideas:

 

here is the code for my account_history.php page.

 

Any suggestions would be appreciated

 

 

Thanks,

Mike

 

<?php
/*
 $Id: account_history.php,v 1.63 2003/06/09 23:03:52 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 require('includes/application_top.php');
// begin UPS XML Tracking
 require(DIR_WS_CLASSES . 'order.php');
// end UPS XML Tracking

 if (!tep_session_is_registered('customer_id')) {
   $navigation->set_snapshot();
   tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
 }

 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ACCOUNT_HISTORY);

 $breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_ACCOUNT, '', 'SSL'));
 $breadcrumb->add(NAVBAR_TITLE_2, tep_href_link(FILENAME_ACCOUNT_HISTORY, '', 'SSL'));
?>
<!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; ?>">
<title><?php echo TITLE; ?></title>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<?php
// begin UPS XML Tracking
?>
<script language="javascript"><!--
function popupTrackerWindow(url) {
 window.open(url,'popupTrackerWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,re
sizable=no,copyhistory=no,width=650,height=500')
}
//--></script>
<?php
// end UPS XML Tracking
?>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="3" cellpadding="3">
 <tr>
   <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
   </table></td>
<!-- body_text //-->
   <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
           <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_history.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
         </tr>
       </table></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
     <tr>
       <td>
<?php
 $orders_total = tep_count_customer_orders();

 if ($orders_total > 0) {
   $history_query_raw = "select o.orders_id, o.date_purchased, o.delivery_name, o.billing_name, ot.text as order_total, s.orders_status_name from " . TABLE_ORDERS . " o, " . TABLE_ORDERS_TOTAL . " ot, " . TABLE_ORDERS_STATUS . " s where o.customers_id = '" . (int)$customer_id . "' and o.orders_id = ot.orders_id and ot.class = 'ot_total' and o.orders_status = s.orders_status_id and s.language_id = '" . (int)$languages_id . "' order by orders_id DESC";
   $history_split = new splitPageResults($history_query_raw, MAX_DISPLAY_ORDER_HISTORY);
   $history_query = tep_db_query($history_split->sql_query);

   while ($history = tep_db_fetch_array($history_query)) {
     $products_query = tep_db_query("select count(*) as count from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$history['orders_id'] . "'");
     $products = tep_db_fetch_array($products_query);

     if (tep_not_null($history['delivery_name'])) {
       $order_type = TEXT_ORDER_SHIPPED_TO;
       $order_name = $history['delivery_name'];
     } else {
       $order_type = TEXT_ORDER_BILLED_TO;
       $order_name = $history['billing_name'];
     }
// begin UPS XML Tracking
   $track_order = new order($history['orders_id']);
   $code = $track_order->info['ups_track_num'];
// end UPS XML Tracking
?>
         <table border="0" width="100%" cellspacing="0" cellpadding="2">
           <tr>
             <td class="main"><?php echo '<b>' . TEXT_ORDER_NUMBER . '</b> ' . $history['orders_id']; ?></td>
             <td class="main" align="right"><?php echo '<b>' . TEXT_ORDER_STATUS . '</b> ' . $history['orders_status_name']; ?></td>
           </tr>
         </table>
         <table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
           <tr class="infoBoxContents">
             <td><table border="0" width="100%" cellspacing="2" cellpadding="4">
               <tr>
                 <td class="main" width="50%" valign="top"><?php echo '<b>' . TEXT_ORDER_DATE . '</b> ' . tep_date_long($history['date_purchased']) . '<br><b>' . $order_type . '</b> ' . tep_output_string_protected($order_name); ?></td>
                 <td class="main" width="30%" valign="top"><?php echo '<b>' . TEXT_ORDER_PRODUCTS . '</b> ' . $products['count'] . '<br><b>' . TEXT_ORDER_COST . '</b> ' . strip_tags($history['order_total']); ?></td>

<?php
// begin UPS XML Tracking

 if ($code != NULL) {
   echo '      <td class="main" width="10%"><a href="' . tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, (isset($HTTP_GET_VARS['page']) ? 'page=' . $HTTP_GET_VARS['page'] . '&' : '') . 'order_id=' . $history['orders_id'], 'SSL') . '">' . tep_image_button('small_view.gif', SMALL_IMAGE_BUTTON_VIEW) . '</a></td>' . "\n";
   echo '      <td class="main" width="10%"><a href="javascript:popupTrackerWindow(\'' . tep_href_link(FILENAME_POPUP_TRACKER, 'action=track&tracknum=' . $code) . '\')">' . tep_image_button('small_upstrack.gif') . '</a></td>' . "\n";
 } else {
?>
                 <td class="main" width="20%"><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, (isset($HTTP_GET_VARS['page']) ? 'page=' . $HTTP_GET_VARS['page'] . '&' : '') . 'order_id=' . $history['orders_id'], 'SSL') . '">' . tep_image_button('small_view.gif', SMALL_IMAGE_BUTTON_VIEW) . '</a>'; ?></td>
<?php
 }
// end UPS XML Tracking
?>
               </tr>
             </table></td>
           </tr>
         </table>
         <table border="0" width="100%" cellspacing="0" cellpadding="2">
           <tr>
             <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
           </tr>
         </table>
<?php
   }
 } else {
?>
         <table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
           <tr class="infoBoxContents">
             <td><table border="0" width="100%" cellspacing="2" cellpadding="4">
               <tr>
                 <td class="main"><?php echo TEXT_NO_PURCHASES; ?></td>
               </tr>
             </table></td>
           </tr>
         </table>
<?php
 }
?>
       </td>
     </tr>
<?php
 if ($orders_total > 0) {
?>
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
         <tr>
           <td class="smallText" valign="top"><?php echo $history_split->display_count(TEXT_DISPLAY_NUMBER_OF_ORDERS); ?></td>
           <td class="smallText" align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $history_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
         </tr>
       </table></td>
     </tr>
<?php
 }
?>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
     <tr>
       <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
         <tr class="infoBoxContents">
           <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
             <tr>
               <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
               <td><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT, '', 'SSL') . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'; ?></td>
               <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
             </tr>
           </table></td>
         </tr>
       </table></td>
     </tr>
   </table></td>
<!-- body_text_eof //-->
   <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- right_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>
<!-- right_navigation_eof //-->
   </table></td>
 </tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

Link to comment
Share on other sites

Hello.

 

I installed this contrib today. The tracking itself works great. I'm using 2.2ms2, and have a problem when accessing my orders through the admin.. or when a customer checks their order history.

 

This shows up in the admin orders, cant see what customers have ordered, or the order history.

 

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

 

select customers_id, customers_name, customers_company, customers_street_address, customers_suburb, customers_city, customers_postcode, customers_state, customers_country, customers_telephone, customers_email_address, customers_address_format_id, delivery_name, delivery_company, delivery_street_address, delivery_suburb, delivery_city, delivery_postcode, delivery_state, delivery_country, delivery_address_format_id, billing_name, billing_company, billing_street_address, billing_suburb, billing_city, billing_postcode, billing_state, billing_country, billing_address_format_id, payment_method, cc_type, cc_owner, cc_number, cc_expires, currency, currency_value, date_purchased, orders_status, last_modified, ups_track_num from orders where orders_id = '4'

 

[TEP STOP]

 

Any idea on how to correct this?

 

Thanks!

Link to comment
Share on other sites

add that field to your orders table...

 

ALTER TABLE `orders` ADD `ups_track_num` VARCHAR( 20 ) NULL ;

 

copy-n-paste that line into phpmyadmin or use the mysql command line...

Edited by heliosquare

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

Thanks! I have added that table. I had receieved another similar error , but fixed that.

 

But now when I check out, I get:

 

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

 

insert into orders (customers_id, customers_name, customers_company, customers_street_address, customers_suburb, customers_city, customers_postcode, customers_state, customers_country, customers_telephone, customers_email_address, customers_address_format_id, delivery_name, delivery_company, delivery_street_address

 

 

Can't check out because of this. I tried taking the customers_company out of a few files, tried looking at the db, still the same error. I think someone else here had the same problem. I'm using 2.2ms2 with the contrib from 12/6/03....Anyone know what I should do for this? This seems like the only error I have at the moment, and most important one. What should I do?

 

Thanks much.

Link to comment
Share on other sites

Ahhh. also did somthing in phpmyadmin.. now when I try to look at my admin, inside the paypal ipn... this notice comes up:

 

1054 - Unknown column 'o.paypal_ipn_id' in 'where clause'

 

select count(*) as total from paypal_ipn as p, paypal_ipn_orders as po, orders as o where p.paypal_ipn_id = po.paypal_ipn_id AND po.paypal_ipn_id = o.paypal_ipn_id AND o.paypal_ipn_id = p.paypal_ipn_id

 

[TEP STOP]

 

There was something I did previously that corrected it, for the life of me can't remember, any info would be appreciated, again, thanks.

Link to comment
Share on other sites

you should post these questions to the general support forum as they really aren't related to this contribution. you are much more likely to get responses there. your database appears to be screwed up but you aren't giving enough info. to stimulate a valid response...my suggestion is that you re-trace everything you did since the last time it was working properly to see if you can pin point the problem(s). This can be painstaking at times but whatcha gonna do...

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

Okay, after going through this entire thread a few times, I realized I did what zenpig had quoted

 

"I'd hate to see anyone run the .sql on the orders table if they were using 2.2; backup kids :)"

 

I ran the orders.sql while I'm on ms2.2. So there is no way to un-do that right? Painstaking, yep. Anyways just want to say thanks, and this contrib is great, I know I'll use it again in the future knowing that.

Link to comment
Share on other sites

  • 2 weeks later...

I have the same problem where I get the error msg

Fatal error: Call to undefined function: curl_init()

 

I have curl installed but not compiled. I know the path where curl is located /usr/bin/curl

 

What do I need to change in the tracking.php to make this mod work?

Link to comment
Share on other sites

So I looked at the way that the authorizenet_direct.php function sucessfully gets around not having curl compiled into php.

 

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 \"$data\" https://secure.authorize.net/gateway/transact.dll", $response);

}

else {

$url = "<https://secure.authorize.net/gateway/transact.dll>";

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL,$url);

curl_setopt($ch, CURLOPT_VERBOSE, 0);

curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); //Windows 2003 Compatibility

$authorize = curl_exec($ch);

curl_close($ch);

$response = split(",", $authorize);

}

 

I am trying to apply this to the tracking.php to make it work for me

 

so far I have this

 

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 $url", $xmlResponse);

 

 

it isn't working cause $xmlResponse is not correct...

 

Maybe someone that understands this stuff better than I will help out. This will solve many folks problems.

 

FYI-

I have the authorizenet module installed and working so the following are already defined for me.

 

MODULE_PAYMENT_AUTHORIZENET_CURL

MODULE_PAYMENT_AUTHORIZENET_CURL_PATH

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