Export Amazon Order List for DPD Label Printing

DPD supports 1000 address book entries and short names can be used to save order addresses. A single import of 200 entries is allowed by DPD. The CSV order is shown below


  •  Short Name * (max 20 characters)
  • Country Code * (IATA - max 2 characters). Click here for a list of Country Codes
  • Postal/Zip Code (max 10 characters)
  • Organisation (max 35 characters)
  • Property (max 35 characters)
  • Street * (max 35 characters)
  • Locality (max 35 characters)
  • Town * (max 35 characters)
  • County (max 35 characters)
  • Contact (max 25 characters)
  • Telephone (max 15 characters)
  • Email (max 50 characters)
  • Text No. (max 20 characters) 
* are mandatory fields
If you are an amazon seller and find it time consuming to enter individual address for shipping in DPD, here is a small script to quickly import address in DPD from amazon orders.

Amazon's Seller Central allow export of order report with the shipping address. Image below shows the page where you can download new orders report ORDERS > ORDER REPORTS

The downloaded file is in tab delimited file and has following columns 
  • order-id
  • order-item-id
  • purchase-date
  • payments-date
  • reporting-date
  • promise-date
  • days-past-promise
  • buyer-email
  • buyer-name
  • buyer-phone-number
  • sku
  • product-name
  • quantity-purchased
  • quantity-shipped
  • quantity-to-ship
  • ship-service-level
  • recipient-name
  • ship-address-1
  • ship-address-2
  • ship-address-3
  • ship-city
  • ship-state
  • ship-postal-code
  • ship-country
The following php script is the solution to directly convert tab delimited file in CSV format in accordance to DPD order.(WAMP or LAMP required to make script work)





<?php
header('Content-Type: text/csv');
header('Content-Disposition: attachment; filename=dpd.csv');
$filename = "c:\info.txt";
$fd = fopen ($filename, "r");
$contents = fread ($fd,filesize ($filename));
fclose ($fd);
$newline = "\n";
$splitcontents = explode($newline, $contents);
$counter = "";
$oldid = "";
foreach ( $splitcontents as $column )
{
error_reporting(0);
$counter = $counter+1;
#echo " $color\n<br>";
#echo "<tr>";
$delimiter = " ";
$splitcontents1 = explode($delimiter, $column);
if($oldid != $splitcontents1[0] && $counter != 1)
{
echo "\"".$splitcontents1[0]."\",";       # Short Name
echo "\"".$splitcontents1[23]."\",";   # Country Code
echo "\"".$splitcontents1[22]."\",";      # Postal Code
#echo "\"".$splitcontents1[1]."\",";
#echo "\"".$splitcontents1[2]."\",";
#echo "\"".$splitcontents1[3]."\",";
#echo "\"".$splitcontents1[4]."\",";
#echo "\"".$splitcontents1[5]."\",";
#echo "\"".$splitcontents1[6]."\",";
#echo "\"".$splitcontents1[7]."\",";
#echo "\"".$splitcontents1[8]."\",";

#echo "\"".$splitcontents1[10]."\",";
#echo "\"".$splitcontents1[11]."\",";
#echo "\"".$splitcontents1[12]."\",";
#echo "\"".$splitcontents1[13]."\",";
#echo "\"".$splitcontents1[14]."\",";
#echo "\"".$splitcontents1[15]."\",";
echo "\"".$splitcontents1[16]."\",";      # Organisation
echo "\"\",";            # Property
echo "\"".$splitcontents1[17]."\",";      # Street
echo "\"".$splitcontents1[18]."\",";      # Locality
#echo "\"".$splitcontents1[19]."\",";      
echo "\"".$splitcontents1[20]."\",";      # Town
echo "\"".$splitcontents1[21]."\",";      # County
echo "\"\",";            # Contact
echo "\"".$splitcontents1[6]."\",";       # Telephone
echo "\"\",";            # E-mail
echo "\"\"";            # Text No
echo "\n";
}
$oldid= $splitcontents1[0];
}
?>

Comments

jowdjbrown said…
If you are an amazon seller and find it time consuming to enter individual address for shipping in DPD, here is a small script to quickly import address in DPD from amazon orders.etiloga.com.mx
Olivia Princess said…
I’ll probably keep it short and sweet and link to this instead if thats cool. Thanks.
see here

Popular posts from this blog

Switching from Notepad++ FTP to Visual Studio Code FTP

Simple PHP Script to read Tab Delimited File

jTable to edit and process MySQL table using CodeIgnitor : Part 2