$data = file_get_contents($xml);
$data = new SimpleXMLElement($data);
$date = date(DATE_ATOM);
$result = $data->xpath('/foxydata/transactions/transaction');
$country = ( trim($result[0]->customer_country) == "US" ) ? "USA" : trim($result[0]->customer_country);
$i = 0;
foreach ( $result[0]->transaction_details->transaction_detail as $transaction ) {
$OrderLineItem['OrderLineItem'][$i] = array (
'SKU' => trim((string)$transaction->product_code),
'Qty' => trim((int)$transaction->product_quantity),
'Packed' => trim((string)$transaction->product_weight),
'CuFtPerCarton' => '0.0006'
);
$i++;
}
$ArrayOfOrder = array (
'Order' => array(
'TransInfo' => array(
'ReferenceNum' => trim((string)$result[0]->customer_id) . trim((string)$result[0]->id),
'EarliestShipDate' => $date,
'ShipCancelDate' => strtotime(date(DATE_ATOM, strtotime($date)) . "+1 month"),
'PONum' => trim((string)$result[0]->customer_last_name) . '_' . trim((string)$result[0]->id)
),
'ShipTo' => array(
'Name' => trim((string)$result[0]->customer_first_name) . ' ' . trim((string)$result[0]->customer_last_name),
'CompanyName' => trim((string)$result[0]->customer_company),
'Address' => array(
'Address1' => trim((string)$result[0]->customer_address1),
'Address2' => trim((string)$result[0]->customer_address2),
'City' => trim((string)$result[0]->customer_city),
'State' => trim((string)$result[0]->customer_state),
'Zip' => trim((string)$result[0]->customer_postal_code),
'Country' => $country
),
'EmailAddress1' => trim((string)$result[0]->customer_email),
'CustomerName' => 'DEMO'
),
'ShippingInstructions' => 'DEFAULT',
'Notes' => trim((string)$result[0]->processor_response),
'PalletCount' => 1,
'OrderLineItems' => $OrderLineItem
));