DATE_SUB(NOW(), INTERVAL 30 DAY)'); foreach ($orders as $order) { $this->export_order($order['id'], $order['order_no']); } } public function export_order($order_id, $code) { $file = "data/import/Import/{$code}.xml"; if (file_exists($file)) { return false; } $xml = $this->get_order_xml($order_id); $handle = fopen($file, 'w'); fwrite($handle, $xml); fclose($handle); return true; } public function get_order_xml($order_id) { $order = new Order(); $order->createFromDB($order_id, true, false, true); $order->fetchRawDates(); $order->fetchItems(); $smarty = createSmarty(true); $smarty->assign([ 'order' => $order, 'winshop' => $this, ]); return $smarty->fetch('export/order.WinShop.tpl'); } public function get_order_item_variation($item) { preg_match('/\(Velikost.*?: ([^\)]+)/i', $item['descr'], $matches); return $matches[1]; } }