You are here

function _uc_importer_export_orders in Ubercart 5

Export orders as XML.

1 call to _uc_importer_export_orders()
uc_importer_export in uc_importer/uc_importer.module
Constructs the XML representation of the store from the ids given.

File

uc_importer/uc_importer.module, line 687
XML product importer and exporter.

Code

function _uc_importer_export_orders($orders) {
  $xml = '<orders>';
  foreach ($orders as $order_id) {
    $order = uc_order_load($order_id);
    if (!empty($order)) {
      $xml .= '<order>';
      $xml .= '<order_status>' . uc_order_status_data($order->order_status, 'title') . '</order_status>';
      $xml .= '<order_total>' . $order->order_total . '</order_total>';
      $xml .= '<primary_email>' . htmlspecialchars($order->primary_email, ENT_QUOTES, "UTF-8") . '</primary_email>';
      $xml .= '<delivery_first_name>' . htmlspecialchars($order->delivery_first_name, ENT_QUOTES, "UTF-8") . '</delivery_first_name>';
      $xml .= '<delivery_last_name>' . htmlspecialchars($order->delivery_last_name, ENT_QUOTES, "UTF-8") . '</delivery_last_name>';
      $xml .= '<delivery_phone>' . htmlspecialchars($order->delivery_phone, ENT_QUOTES, "UTF-8") . '</delivery_phone>';
      $xml .= '<delivery_company>' . htmlspecialchars($order->delivery_company, ENT_QUOTES, "UTF-8") . '</delivery_company>';
      $xml .= '<delivery_street1>' . htmlspecialchars($order->delivery_street1, ENT_QUOTES, "UTF-8") . '</delivery_street1>';
      $xml .= '<delivery_street2>' . htmlspecialchars($order->delivery_street2, ENT_QUOTES, "UTF-8") . '</delivery_street2>';
      $xml .= '<delivery_city>' . htmlspecialchars($order->delivery_city, ENT_QUOTES, "UTF-8") . '</delivery_city>';
      $xml .= '<delivery_zone>' . $order->delivery_zone . '</delivery_zone>';
      $xml .= '<delivery_zip>' . htmlspecialchars($order->delivery_zip, ENT_QUOTES, "UTF-8") . '</delivery_zip>';
      $xml .= '<delivery_country>' . $order->delivery_country . '</delivery_country>';
      $xml .= '<billing_first_name>' . htmlspecialchars($order->billing_first_name, ENT_QUOTES, "UTF-8") . '</billing_first_name>';
      $xml .= '<billing_last_name>' . htmlspecialchars($order->billing_last_name, ENT_QUOTES, "UTF-8") . '</billing_last_name>';
      $xml .= '<billing_phone>' . htmlspecialchars($order->billing_phone, ENT_QUOTES, "UTF-8") . '</billing_phone>';
      $xml .= '<billing_company>' . htmlspecialchars($order->billing_company, ENT_QUOTES, "UTF-8") . '</billing_company>';
      $xml .= '<billing_street1>' . htmlspecialchars($order->billing_street1, ENT_QUOTES, "UTF-8") . '</billing_street1>';
      $xml .= '<billing_street2>' . htmlspecialchars($order->billing_street2, ENT_QUOTES, "UTF-8") . '</billing_street2>';
      $xml .= '<billing_city>' . htmlspecialchars($order->billing_city, ENT_QUOTES, "UTF-8") . '</billing_city>';
      $xml .= '<billing_zone>' . $order->billing_zone . '</billing_zone>';
      $xml .= '<billing_zip>' . htmlspecialchars($order->billing_zip, ENT_QUOTES, "UTF-8") . '</billing_zip>';
      $xml .= '<billing_country>' . $order->billing_country . '</billing_country>';
      $xml .= '<payment_method>' . $order->payment_method . '</payment_method>';
      if (!empty($order->products)) {
        $xml .= '<products>';
        foreach ($order->products as $product) {
          $xml .= '<product>';
          $xml .= '<qty>' . $product->qty . '</qty>';
          $xml .= '<name>' . htmlspecialchars($product->title, ENT_QUOTES, "UTF-8") . '</name>';
          if ($product->manufacturer) {
            $xml .= '<manufacturer>' . htmlspecialchars($product->manufacturer, ENT_QUOTES, "UTF-8") . '</manufacturer>';
          }
          $xml .= '<model>' . htmlspecialchars($product->model, ENT_QUOTES, "UTF-8") . '</model>';
          $xml .= '<cost>' . $product->cost . '</cost>';
          $xml .= '<price>' . $product->price . '</price>';
          $xml .= '<weight>' . $product->weight . '</weight>';
          $xml .= '<data>' . htmlspecialchars($product->data, ENT_QUOTES, "UTF-8") . '</data>';
          $xml .= uc_importer_invoke('export', 'order-product', $order_id, $product->order_product_id);
          $xml .= '</product>';
        }
        $xml .= '</products>';
        $quote = $order->quote;
        $xml .= '<quote>';
        $xml .= '<method>' . $quote['method'] . '</method>';
        $xml .= '<accessorials>' . $quote['accessorials'] . '</accessorials>';
        $xml .= '<rate>' . $quote['rate'] . '</rate>';
        $xml .= '<quote_form>' . htmlspecialchars($quote['quote_form'], ENT_QUOTES, "UTF-8") . '</quote_form>';
        $xml .= uc_importer_invoke('export', 'quote', $order_id);
        $xml .= '</quote>';
        if (!empty($order->line_items)) {
          $xml .= '<line_items>';
          foreach ($order->line_items as $line_item) {
            $xml .= '<line_item>';
            $xml .= '<type>' . $line_item['type'] . '</type>';
            $xml .= '<title>' . htmlspecialchars($line_item['title'], ENT_QUOTES, "UTF-8") . '</title>';
            $xml .= '<amount>' . $line_item['amount'] . '</amount>';
            $xml .= '<weight>' . $line_item['weight'] . '</weight>';
            $xml .= uc_importer_invoke('export', 'line_item', $line_item->line_item_id);
            $xml .= '</line_item>';
          }
          $xml .= '</line_items>';
        }
      }
      $xml .= uc_importer_invoke('export', 'order', $order_id);
      $xml .= '</order>';
    }
  }
  $xml .= '</orders>';
  return $xml;
}