Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2009
    Posts
    17
    Plugin Contributions
    1

    Default 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

  2. #2
    Join Date
    Jun 2009
    Posts
    17
    Plugin Contributions
    1

    Default XML Export help needed

    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)

    PHP Code:
    $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

  3. #3
    Join Date
    Jan 2004
    Posts
    66,450
    Plugin Contributions
    81

    Default Re: XML Export help needed

    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.

 

 

Similar Threads

  1. Export Orders in XML
    By scottmcclean in forum General Questions
    Replies: 1
    Last Post: 19 May 2013, 05:20 PM
  2. Export orders to XML
    By srhtech in forum Managing Customers and Orders
    Replies: 6
    Last Post: 13 Oct 2011, 08:02 AM
  3. UPS Worldship XML Export
    By cryogenicz in forum All Other Contributions/Addons
    Replies: 4
    Last Post: 13 Dec 2010, 07:33 AM
  4. Export Products in XML?
    By theladebug in forum General Questions
    Replies: 1
    Last Post: 19 Jan 2009, 12:13 AM
  5. Zen Cart XML Export
    By esoin in forum General Questions
    Replies: 5
    Last Post: 17 Apr 2008, 12:34 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg