Forums / All Other Contributions/Addons / XML export of orders

XML export of orders

Locked

Views: 1,229

Results 1 to 3 of 3
This thread is locked. New replies are disabled.
14 Jul 2009, 3:42 AM
#1
m23perrault avatar

m23perrault

New Zenner

Join Date:
Jun 2009
Posts:
7
Plugin Contributions:
0

XML export of orders

has anyone seen a module anywhere to export an order to xml. i am looking for a way to integrate with my distributor.

MTPH Software :: A better way to buy software
OC Mobile Spray Tan

24 Jul 2009, 7:00 PM
#2
m23perrault avatar

m23perrault

New Zenner

Join Date:
Jun 2009
Posts:
7
Plugin Contributions:
0

Re: XML export of orders

ok, i have a php file that creates an xml file from orders. i am eventualy going to export that xml file to the distributor for order processing. the creation of the xml file is going good, however once i got past the customer order information, name address etc., i needed to add the product being ordered. problem is that the information is located in a different table and my query skills with xml are a little rusty. I will post the code with what i have, and show you what i need. the fields i need are in the text "NEED THIS INFO" ( i left out the connection string info for the db)

$table_name = 'zen_orders';
$db = mysql_select_db($db_name);
$query = "select * from " . $table_name;
$result = mysql_query($query, $connection) or die("Could not complete database query");
$num = mysql_num_rows($result);

if ($num != 0) {
 $file= fopen("results.xml", "w");
 $_xml ="<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n";
 $_xml .="<OrderList>\r\n";
 while ($row = mysql_fetch_array($result)) {
 if ($row["orders_id"]) {
 $_xml .="\t<Order id=\"" . $row["orders_id"] . "\">\r\n";
 $_xml .="\t\t<Shipping>Budget</Shipping>\r\n";
 $_xml .="\t\t\t<Addressinfo type='ship'>\r\n";
$_xml .="\t\t<Name>" . $row["delivery_name"] . "</Name>\r\n";
$_xml .="\t\t<Company>" . $row["delivery_company"] . "</Company>\r\n";
$_xml .="\t\t<Address1>" . $row["delivery_street_address"] . "</Address1>\r\n";
$_xml .="\t\t<City>" . $row["delivery_city"] . "</City>\r\n";
$_xml .="\t\t<State>" . $row["delivery_state"] . "</State>\r\n";
$_xml .="\t\t<Country>" . $row["delivery_country"] . "</Country>\r\n";
$_xml .="\t\t<Zip>" . $row["delivery_zip"] . "</Zip>\r\n";
$_xml .="\t\t<Item>\r\n";
$_xml .="\t\t<Id>" . $row["NEED THIS INFO"] . "</Id>\r\n";
$_xml .="\t\t<Quantity>" . $row["NEED THIS INFO"] . "</Quantity>\r\n";
$_xml .="\t\t</Item>\r\n";
$_xml .="\t\t\t</Addressinfo>\r\n";
$_xml .="\t</Order>\r\n";
 } else {
 $_xml .="\t<order id=\"Nothing Returned\">\r\n";
$_xml .="\t\t<file>none</file>\r\n";
 $_xml .="\t</order>\r\n";
 } }
 $_xml .="</OrderList>";
 fwrite($file, $_xml);
 fclose($file);
 echo "XML has been written.  <a href=\"results.xml\">View the XML.</a>";
 } else {
 echo "No Records found";
 } ?>

basically i need the quantity ordered and product id from the zen_orders_products table. i know someone has an idea on how to do this. This is also starting to look like a nice mod as well.

MTPH Software :: A better way to buy software
OC Mobile Spray Tan

25 Jul 2009, 2:32 AM
#3
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: XML export of orders

You would need to do another query from the orders_products table using the current order_id as the lookup key, while you're looping through the orders you're exporting.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.