EDI Order Import/Export


This module provides some simple EDI order import and export functionality. This is useful for stores working with fulfillment houses where orders are passed back and forth in some predetermined format for shipping. The current module assumes some sort of FTP based system and will handle automatic archiving of import files automatically.

The module was developed to be flexible so the import and export strings could be tweaked for different uses. It supports importing and exporting tab, comma, or pipe delimited files and has a simple scripting system that allows different rules to be processed on imports. The module handles exports/imports during cron runs or manually by administrators and works based off of configurable order statuses.

The admin menu to manually import or export orders and reset the cron timers is available at /admin/store/orders/edi.

The admin menu to configure your EDI settings (cron runs, order statuses, import and export formats, etc.) is available at /admin/store/settings/edi/. Instructions for setting your formats may be found in the help text for the different fields.

Please post any bugs or install issues to the issue tracker on drupal.org. Smiling

jorisx@drupal.org's picture
Joined: 10/09/2007
Juice: 6

Is it possible to add a header to the export file ?

Ryan's picture
Joined: 08/07/2007
Juice: 15476
Re: Headers

Hmm... not right now, but it would be easy enough for you to add it in the code.

jorisx@drupal.org's picture
Joined: 10/09/2007
Juice: 6
headers 2

hmm, ok
not sure how to add it in the code (I can read php, but writing is different Eye-wink
also I'm not sure if this is really the right module, I need to export orders (of any kind) so that a filemaker program can read it ... (it's what the client wants Smiling
Do you know of any other expor.module ?
And maybe do you know if ubercart is going to include this or an export option in the core ?
It would seem a really needed, and handy feature, out of the box Smiling

Good works so! this module already helped a lot Smiling

Smiling J!

vincent666's picture
Joined: 05/05/2008
Juice: 2
Import orders from scratch

It seems it is not possible to create orders with the EDI import functionality. Isn't it ?

Ryan's picture
Joined: 08/07/2007
Juice: 15476
Re: Import orders from scratch


steingard's picture
Joined: 03/30/2008
Juice: 70

Hey, I just upgraded to the new one on D.org... I didn't see anything come up in the update.php script, so I'm assuming that there is no db schema change, correct?

Secondly, any reason why the tokens aren't (don't seem to be) using Ubercart's standard tokens? (or does it, and I just don't know what I'm talking about). I suppose this question is relevant, since the latest version of this module provides more tokens/keys to work with than the previous version did.

Lastly, would there be any way to get this setup to export a second order pattern based on the country of the order delivery address? I.e. I am in Canada, and I need to tell UPS that an order is going to the US, and therefore it knows to print up some extra labels for customs clearance. The only way I can see doing this is by exporting 1 pattern for Canadian orders and 1 pattern for US orders... is that making sense?

steingard's picture
Joined: 03/30/2008
Juice: 70
Weight Token/Key

I'm using this great export tool to export orders to UPS Connect, and then have it re-import the tracking info that the system spits out.

It seems to be able to build a compatible comma separated line for each order, however I can't seem to find a token/key that represents the total weight of the products that have been ordered. I can get the quantity & SKU, which is great... but is there a way to add up the weights of the products and output that to a token/key that can be used in EDI?

mcneelycorp's picture
Joined: 10/26/2007
Juice: 72
Re: Weight Token/Key

Hi, Did you find a solution to this?

Elvis McNeely
Blogging about Drupal and web development: http://www.elvisblogs.org/drupal
Offering Drupal, eCommerce and Web services: http://www.lafayetteweb.com

poppers's picture
Joined: 08/12/2008
Juice: 45
Product Export Format

Maybe helpful to some:

I modified the uc_edi module a bit to allow the order export format tokens to be used in the product export format as well. This is because my fulfilment house required a format that needed each product line to include the shipping information. This allows edi output files like the following:

56|08/24/2008|Mr. Poppers||Address Line 1||Cincinnati|OH|45242|1|55-84958021|700|
56|08/24/2008|Mr. Poppers||Address Line 1||Cincinnati|OH|45242|1|55-84958028|700|

Also here is the code I wrote to connect to and read write from my fulfillment houses ftp server to interact with Ryan's EDI moduel and change the order status to Completed and notify the customer the product has been shipped with the tracking info:

$ftplogin = LOGIN;
$ftppass = PASS;
$conn_id = ftp_connect($ftpserver);
$login_result = ftp_login($conn_id, $ftplogin, $ftppass);

if ((!$conn_id) || (!$login_result)){
die ("Unable to connect to FTP server");
} else {
echo "Connected to FTP server" . ftp_pwd($conn_id) . "\n";
* ----------------------------
* 1 - Download each status file from Triple Fin
* 2 - Parse XML from temp file and write new file for ubercart in correct format
* 3 - Move file on triple fin's server to processed folder
* 4 - Unlink temp file
if (ftp_chdir($conn_id, "outbound")) {
echo "Current directory is now: " . ftp_pwd($conn_id) . "\n";
$contents = ftp_nlist($conn_id, ".");
foreach($contents as $file){
$temp_file = $tmpdir . $file;
// Step 1 - download each status file and save temporarily
echo "$i Attempting to download new file $file\n";
if (ftp_get($conn_id, $temp_file, $file, FTP_BINARY)) {
    echo "$i Temp file written to $temp_file\n";
    $statusFileXML =  simplexml_load_file($temp_file) or die("Cannot load SimpleXML from " . $temp_file);
    echo "$i Temp file parsed into SimpleXML from $temp_file\n";
    //Step 2 - iterate through each order and write to a new file
    $out_file = $inbounddir . substr($file,0,strlen($file)-3) . "txt";
    $fh = fopen($out_file, 'w') or die("Cannot write to " . $out_file);
    $ii = 0;
foreach($statusFileXML->order as $order){
$lineout = "ORD|". $order->order_id."|FEDX|";
    $lineout .= ($order->tracking !="NA")?$order->tracking:"Not Available";
    $lineout .= "\n";
fwrite($fh, $lineout);
echo ".";
echo "\n$i Completed writing [$ii] orders to output file for inbound processing$out_file\n";
$new_file = "processed_by_pop/".$file;
    if (ftp_rename($conn_id, $file, $new_file)) {
echo "$i Successfully renamed $file to $new_file\n";
} else {
echo "There was a problem while renaming $file to $new_file\n";
//Step 4 - delete temp file
    echo "$i Temp file removed $temp_file\n";
} else {
    echo "There was a problem retrieving file from FTP server $file\n";
echo "Completed parsing [$i] incoming files\n";
} else {
    echo "Couldn't change directory\n";
echo "------------\n";
if (ftp_chdir($conn_id, "../inbound")) {
* ---------------------------
* 1 - read all outgoing order files from server
* 2 - open each outgoing order file
* 3 - create a temp file and include order_file_header at top
* 4 - upload temp file to inbound directory on triplefin server
* 5 - delete temp file
* 6 - move outgoing order file to processed folder on our server

$dh = opendir($outbounddir) or die("Unable to open $outbounddir\n");
echo "Opening $outbounddir to look for outbound order files to upload to triplefin\n";

//Step 1 - read all outgoing order files from server
while ($file = readdir($dh)) {
if(substr($file,strlen($file)-3,strlen($file)) == "txt"){
//Step 2 - open outgoing file
echo "$i Opening order file for processing $file\n";
$outgoing_file = $outbounddir . $file;
$fh = fopen($outgoing_file, 'r') or die("Cannot read from outgoing file " . $out_file);
$outgoing_data = fread($fh, filesize($outgoing_file));
//Step 3 - open outgoing file
$temp_file = $tmpdir . $file;
echo "$i Create temp file for upload to triple fin $temp_file\n";
$fh = fopen($temp_file, 'w') or die("Cannot write to " . $temp_file);
//Step 4 - upload temp file to server
echo "$i Writing file to server $temp_file\n";
if (ftp_put($conn_id, $file, $temp_file, FTP_ASCII)) {
echo "$i Successfully uploaded $file\n";
} else {
echo "There was a problem while uploading $file\n";
//Step 5 - remove temp file
echo "$i Removing temp file\n";
//Step 6 - move order file to processed
$new_path = $outbounddir . "/processed/" . $file;
echo "$i Moving file to processed directory $new_path\n";
rename($outgoing_file, $new_path);
echo "Finished processing [$i] order files for fulfillment\n";
//closing the directory
echo "Closing FTP connection\n";
uc_edi.zip 15.02 KB
Insurrectus's picture
Spreading the word - Ubercart for president.
Joined: 08/22/2007
Juice: 364
@poppers: I can't get this


I can't get this work. Where do I put the product export format tokens? Will you post up a screen shot of your EDI settings page?


dafeder's picture
Joined: 03/11/2008
Juice: 42
UC 2.x version?

Hi, was wondering if any work is underway for a version of this module compatible with UC 2.x. If not, any major issues to keep in mind if one were to write a 2.x version?

kussmaul's picture
Joined: 12/29/2008
Juice: 12
re: UC 2.x version

I started updating uc_edi for UC 2.x and Drupal 6.x.
Everything appears to be working, and I've added some features.
I'd love to have other people using and enhancing the code.

Jmmb's picture
Joined: 08/23/2007
Juice: 308
Not working on UC 1.x


I just installed this module on a Drupal 5.8-dev site with Store module vsn. 5.x-1.0-alpha5. After enabling the module, I got this message:

user warning: Unknown column 'state' in 'field list' query: INSERT INTO uc_order_statuses (order_status_id, title, state, weight, locked) VALUES ('edi_export', 'Order processed', 'edi_processing', 15, 1),('edi_pending', 'Shipment pending', 'edi_processing', 16, 1); in /home/vfamilyc/public_html/includes/database.mysql.inc on line 172.

I went forward anyway and set permissions, then tried to view the EDI admin page. But instead I just see:

Fatal error: Call to undefined function uc_order_status_list() in /home/vfamilyc/public_html/sites/all/modules/ubercart/uc_edi/uc_edi.module on line 187

Any help would be appreciated!


TR's picture
Bug FinderFAQ ModeratorGetting busy with the Ubercode.
Joined: 11/05/2007
Juice: 3284
Re: Not working on UC 1.x

You're using Ubercart 1.0 alpha 5? That's almost two years old! It's not surprising that some modules will fail to work with that old a version, since many many things have changed.

I've used this module without problems on various versions of Ubercart extending back to 1.0 RC5. I highly recommend you upgrade to the latest Ubercart 1.7 (and Drupal 5.17) then try again.

shajjadbd's picture
Joined: 09/19/2011
Juice: 11
Need emergency help for EDI integration

I am desperately looking help for EDI import/export guide. My requirement is import/export orders into my e-commerce site but I didn't find any format for import orders. I have already setup uc_edi-6.x-1.0 module and created import/export file by following 'order export pattern' in EDI documentation but it doesn't work. I think my format is wrong. Please help me by providing proper instructions and a working import/export format. I need a solution desperately from people like you.


stanman's picture
Joined: 10/21/2010
Juice: 9
Export filename


When first installed UC edi export, de filename was the date , but now suddenly the filename is the order number, where can customize the export filname

Kind regards

Stany Berden