first commit
This commit is contained in:
52
class/class.WinShop.php
Normal file
52
class/class.WinShop.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
class WinShop
|
||||
{
|
||||
public function export()
|
||||
{
|
||||
$orders = sqlQuery('SELECT id, order_no FROM orders WHERE date_created > 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];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user