Jump to content
Sign in to follow this  
spoot

Automated FedEx Labels

Recommended Posts

Hi guys,

Can u help me?

I should change FedEx labels module for international addresses. For example for shipment from USA to GB.

So, what things I should change in module? Currently it working only with USA & Canada addresses, giving olny 2 letters state etc.

 

Thanks.

Share this post


Link to post
Share on other sites

I inherited an osc site with this contribution installed and after a server move (php4to php5), the Fedex images are not working anymore. I would like to update teh version of the contrib, but I have no idea which version is installed. I have no readme or install file. Is there a way for me to check what version is installed?

Does anyone have an idea about why the images have stopped working?

thanks for your help!

Share this post


Link to post
Share on other sites

Hi all,

 

I have an issue with tracking as well. I couldn't find a similar problem on the forum.

 

- When trying to track a package from within the site by using the "track this shipment" link, the customer gets back to the home page, in logged off status

 

- In the email generated for the tracking/status info, when the customers uses the link provided to get the Detailed Invoice, he gets to the login page. After login in, he gets the home page. I'm not sure if the contribution is intended to work that way or if there is a bug somewhere.

 

Any help would be really really appeciated.

 

TIA

Share this post


Link to post
Share on other sites

No, it's not supposed to work that way. It's definitely a bug somewhere (either in your installation or this code).


- The Jackal

Share this post


Link to post
Share on other sites

I finally figured out how to do international shipping with this module. I know alot of people have been asking for this for the last 3 years, so here goes....

 

After about 7 hours of hacking, learning, and crunching, here is more or less the code you need to get it working. You will have to also update abbreviate.php in your catalog/admin/includes folder accordingly to abbreviate your countries into two letter formats for FedEx, and make sure your shipping addresses for international have the proper 'State/Province', or reprogram your OSC to allow blank 'State/Province' fields, or else FedEx might return an invalid state error.

 

Here is the vital piece of code you'll need to insert into ship_fedex.php in catalog/admin. It should be inserted right after the $shipData array.

 

$order_qty_query = tep_db_query("select * from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . $order . "'");
$count = mysql_num_rows($order_qty_query);
	$i=1;
	if (tep_db_num_rows($order_qty_query)) {
     		while (($order_qtys = tep_db_fetch_array($order_qty_query)) && ($i <= $count)) {
       	$products_id = $order_qtys['products_id'];
			$products_weight_query = tep_db_query("select * from " . TABLE_PRODUCTS . " where products_id = '" . $products_id . "'");
			if (tep_db_num_rows($products_weight_query)) {
				$products_weights = tep_db_fetch_array($products_weight_query);
				$order_weight = $order_weight + ($order_qtys['products_quantity'] * ($products_weights['products_weight']));
			}
			$shipData['79-' . $i] = $order_qtys['products_name']; // description of commodity
			$shipData['80-' . $i] = $senders_country; // country of manufacture of commodity
			$shipData['81-' . $i] = '<insert harmonized tariff code here>'; // HS tariff code (10 digits) of commodity
			$shipData['82-' . $i] = $order_qtys['products_quantity']; // quantity of the commodity
			$shipData['1407-' . $i] = number_format($products_weights['products_weight'], 1, '.', '');
			$shipData['1408-' . $i] = $order_qtys['products_price'] . '00' ; // price per commodity
			$shipData['414-' . $i] = 'PCS'; // unit of measurement for how your commodities are counted
		$i++;
		}
	}

 

You'll need to lookup the HS tariff code for your products (you should be able to google it) and replace it accordingly in the example above, and you'll need to designate how your items are measured. For the example above, I used 'PCS' for pieces. You might want to look up what yours is in the FedEx API manual. FYI, you can't just write any unit mesaurement, it has to be abbreviated in the FedEx API format.

 

So this is the most vital section of code to allow you to be able to ship internationally. It will automatically count the number of line items in your order and send it over to be declared in FedEx international shipments. If anyone can build this code into the contrib and release it as an entire package (and if you can credit me) the entire community would be appreciated. I'd do it myself, but I've customized my Fedex contrib code so much that it's unusable by the general public.

 

Good luck.

 

If you still get any shipping errors from Fedex, just let me know -- I may have left out one or two API's that's somewhere else in my code.

Edited by arkane8

Share this post


Link to post
Share on other sites

Hi all, any one using this mod along side Canada Post Automatic labels?

 

I'm just starting to install and the second edit will take out some of Can Post Labels. In admin/orders.php... it says to:

 

Find this:

<td colspan="2" align="right"><?php echo '<a href="' . tep_href_link(FILENAME_ORDERS_INVOICE, 'oID=' . $HTTP_GET_VARS['oID']) . '" TARGET="_blank">' . tep_image_button('button_invoice.gif', IMAGE_ORDERS_INVOICE) . '</a> <a href="' . tep_href_link(FILENAME_ORDERS_PACKINGSLIP, 'oID=' . $HTTP_GET_VARS['oID']) . '" TARGET="_blank">' . tep_image_button('button_packingslip.gif', IMAGE_ORDERS_PACKINGSLIP) . '</a> <a href="' . tep_href_link(FILENAME_ORDERS, tep_get_all_get_params(array('action'))) . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a>'; ?></td>

 

Replace with this:

<td colspan="2" align="right">
<?php
   // begin fedex label mod
   // determine whether this is on the test or production server
   $value_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_FEDEX1_SERVER'");
   $value = tep_db_fetch_array($value_query);
   $fedex_gateway = $value['configuration_value'];

   $orders_query_raw = "select orders_id, fedex_tracking, orders_status from " . TABLE_ORDERS . " where orders_id = '" . (int)$HTTP_GET_VARS['oID'] . "'";
   $orders_query = tep_db_query($orders_query_raw);
   if (tep_db_num_rows($orders_query)) {
       $fedex_orders = tep_db_fetch_array($orders_query);
   }

   // check for a fedex tracking number in the order record
   // if yes tracking number, show "fedex label," "track" and "cancel" options
   $fedex_tracking = $fedex_orders['fedex_tracking'];

   if ($fedex_tracking) {
       // display the label
       echo '<a href="fedex_popup.php?num=' . $fedex_tracking . '&oID=' . $HTTP_GET_VARS['oID'] . '">' . tep_image_button('button_fedex_label.gif', IMAGE_ORDERS_FEDEX_LABEL) . '</a>';
       // cancel the request
       echo '<a href="' . tep_href_link(FILENAME_SHIP_FEDEX, 'oID=' . $HTTP_GET_VARS['oID'] . '&num=' . $fedex_tracking . '&action=cancel&fedex_gateway=' . $fedex_gateway) . '" onClick="return(window.confirm(\'Cancel shipment of order number ' . $order->orders_id . '?\'));">' . tep_image_button('button_cancel_shipment.gif', IMAGE_ORDERS_CANCEL_SHIPMENT) . '</a>';
   }
   elseif ($fedex_orders['orders_status'] != 3) {          // if the order has not been manually marked "delivered,"
// display the "ship" button
echo '<a href="' . tep_href_link(FILENAME_SHIP_FEDEX, 'oID=' . $HTTP_GET_VARS['oID'] . '&action=new&status=3') . '">' . tep_image_button('button_ship.gif', IMAGE_ORDERS_SHIP) . '</a>';
   }
   // end fedex label mod

 echo
  '<a href="' . tep_href_link(FILENAME_ORDERS_INVOICE, 'oID=' . $HTTP_GET_VARS['oID']) . '" TARGET="_blank">' . tep_image_button('button_invoice.gif', IMAGE_ORDERS_INVOICE) . '</a>' .
  '<a href="' . tep_href_link(FILENAME_ORDERS_PACKINGSLIP, 'oID=' . $HTTP_GET_VARS['oID']) . '" TARGET="_blank">' . tep_image_button('button_packingslip.gif', IMAGE_ORDERS_PACKINGSLIP) . '</a>' .
  '<a href="' . tep_href_link(FILENAME_ORDERS, tep_get_all_get_params(array('action'))) . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a>';
?></td>

 

Problem is mine looks like this (modified for Can Post Automatic Labels):

 

<td colspan="2" align="right"><?php echo '<a href="' . tep_href_link(FILENAME_SHIP_CANADAPOST, 'oID=' .(int)$HTTP_GET_VARS['oID'] . '&action=new&status=3') . '">' . tep_image_button('button_ship_canadapost.gif', IMAGE_ORDERS_SHIP) . '</a> <a href="' . tep_href_link(FILENAME_ORDERS_INVOICE, 'oID=' . $HTTP_GET_VARS['oID']) . '" TARGET="_blank">' . tep_image_button('button_invoice.gif', IMAGE_ORDERS_INVOICE) . '</a> <a href="' . tep_href_link(FILENAME_ORDERS_PACKINGSLIP, 'oID=' . $HTTP_GET_VARS['oID']) . '" TARGET="_blank">' . tep_image_button('button_packingslip.gif', IMAGE_ORDERS_PACKINGSLIP) . '</a> <a href="' . tep_href_link(FILENAME_ORDERS, tep_get_all_get_params(array('action'))) . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a>'; ?></td>

 

Any idea's how I can modify this code to work? Thanks in advance...

Share this post


Link to post
Share on other sites

Hi all, after a bunch of trial and error I managed to get this contibution printing labels on the test server. I getting the following errors

Warning: fopen(/shop/images/fedex/205262410000114.png) [function.fopen]: failed to open stream: No such file or directory in /home/flournet/public_html/osc_admin/includes/fedexdc.php on line 251

Warning: fwrite(): supplied argument is not a valid stream resource in /home/flournet/public_html/osc_admin/includes/fedexdc.php on line 252

Warning: Cannot modify header information - headers already sent by (output started at /home/flournet/public_html/osc_admin/includes/fedexdc.php:251) in /home/flournet/public_html/osc_admin/includes/functions/general.php on line 22

 

After going through all 36 pages of the forum 2 twice... and trying to change lines 251 and 252 in admin/includes/fedexdc.php to the absolute path I finally found the problem. What I needed to change to the direct path was admin/includes/configure.php

 

Changed this:

define('DIR_WS_FEDEX_LABELS', DIR_WS_IMAGES . 'fedex/'); 

To This;

define('DIR_WS_FEDEX_LABELS', '/home/******/public_html/osc_admin/images/fedex/');

 

Off to the shop tomorrow to try it on the thermal printer and then see if it works on the product server. After reading through everything I'm still not 100% clear if I need to still call to get approval to use the production server.

 

Thanks everyone who help create this time saving mod!

 

Now, is anyone working on the update to work with Fedex's new Web Services API? I was able to get the Web Services v9 Fedex quotes working... bug there are a bunch of bugs and I lack the (any) skills in figuring out the code. As I understand it... this contribution will go dark on May 2012...

Share this post


Link to post
Share on other sites

 

I had a recent problem that might shed some light on the problem. One of my client's stores had an improperly configured FedEx Real Time Quotes shipping module, with the account number being different. Thinking that FedEx had finally given up support of the labels, I changed the fedex server configuration (fedexdc.php) and I got to the broken Astra Barcode screen you were talking about.

 

ship_fedex.php has a very interesting debug feature that you can use to see if your information is being passed to the final label creation stage. if you set it to 1, you will see what the shipping manifest's array looks like.

// debugging
// setting to 1 displays the array of all shipping
// and manifest data when a ship request is made
$debug = 0;

Later on around line 317

 if ($debug) {
  $shipData[1400] = $total_weight;
  $package_weight = $HTTP_POST_VARS['package_' . $i . '_weight'];
  $package_weight = sprintf("%01.1f", $package_weight);
  $shipData[1401] = $package_weight;
  echo SHIPMENT_REQUEST_DATA . $i . ':<br><pre>';
  print_r($shipData);
  echo '</pre>';
  $manifest_data['tracking_num'] = 'master_trackNum';
  echo MANIFEST_DATA . $i . ':<br><pre>';
  print_r($manifest_data);
  echo '</pre>';
  }
 else {
  $shipData[1400] = $total_weight;
  $package_weight = round($HTTP_POST_VARS['package_' . $i . '_weight'],1);
  $package_weight = sprintf("%01.1f", $package_weight);
  $shipData[1401] = $package_weight;
  $master_trackNum = tep_ship_request($shipData,$ship_type,$order);
  $manifest_data['tracking_num'] = $master_trackNum;
  }
 }

 

I then checked some of the other stores and they were all printing out labels perfectly. Hmm... I went back and put the original server address back in, configured the FedEx Real Time Quotes and FedEx Web Services to have the same credentials and it worked.

 

tl;dr: check to see if your modules are configured with the same credentials (the new ones you got from FedEx for the Web Services modules).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×