public static function cartEnter() { require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'opctracking.php'; $hash2 = uniqid('opc', true); $hashn = JApplication::getHash('opctracking'); $hash = JRequest::getVar($hashn, $hash2, 'COOKIE'); if ($hash2 == $hash) { OPCtrackingHelper::setCookie($hash); } }
function getOrderData($localid, $ind = 0) { require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'opctracking.php'; $order_arr = array(); $order_obj = new stdClass(); OPCtrackingHelper::getOrderVars($localid, $order_arr, $order_obj); $order_data = array(); $ind = '_' . $ind; foreach ($order_arr as $k => $d) { $order_data[$k . $ind] = $d; } $total = $order_arr['bt_order_total']; $order_data['order_total_floor' . $ind] = floor($total); $order_data['order_total_floortxt' . $ind] = $this->number2text(floor($total)); $cents = round(($total - floor($total)) * 100); $order_data['order_total_cents' . $ind] = $cents; return $order_data; $this->number2text(555); $dbj = JFactory::getDBO(); $order_id = $dbj->getEscaped($localid); //ernest get data $order_data = array(); $fieldsOnly = false; if (!empty($localid)) { $q = "SELECT * FROM #__virtuemart_orders WHERE virtuemart_order_id='" . $order_id . "' LIMIT 0,1"; } else { $fieldsOnly = true; $q = "SELECT * FROM #__virtuemart_orders WHERE 1 LIMIT 0,1"; } $dbj->setQuery($q); // basic order data: $arr1 = $dbj->loadAssoc(); if (!empty($arr1)) { $arr1['order_id'] = $arr1['virtuemart_order_id']; $arr1['user_id'] = $arr1['virtuemart_user_id']; foreach ($arr1 as $k => $d) { $order_data[$k . $ind] = $d; } } $total = $order_data['order_total' . $ind]; $order_data['order_total_floor' . $ind] = floor($total); $order_data['order_total_floortxt' . $ind] = $this->number2text(floor($total)); $cents = round(($total - floor($total)) * 100); $order_data['order_total_cents' . $ind] = $cents; $msg = $dbj->getErrorMsg(); if (!empty($msg)) { echo $msg; die; } $order_id = $arr1['order_id']; $user_id = $arr1['user_id']; $qt = "SELECT * from #__virtuemart_order_userinfos WHERE virtuemart_user_id='{$user_id}' AND virtuemart_order_id='{$order_id}' AND address_type = 'BT' LIMIT 0,1"; $dbj->setQuery($qt); // basic user data from order_info $bta = $dbj->loadAssoc(); $msg = $dbj->getErrorMsg(); if (!empty($msg)) { echo $msg; die; } if (!empty($bta)) { foreach ($bta as $key => $value) { $order_data['bt_' . $key . $ind] = $value; } } $qt = "SELECT * from #__virtuemart_order_userinfos WHERE virtuemart_user_id='{$user_id}' AND virtuemart_order_id='{$order_id}' AND address_type = 'ST' LIMIT 0,1"; $dbj->setQuery($qt); $sta = $dbj->loadAssoc(); $msg = $dbj->getErrorMsg(); if (!empty($msg)) { echo $msg; die; } if (!empty($sta)) { //$arr1['ship_to_address'] = $sta; foreach ($sta as $key => $value) { //if (!$fieldsOnly) $order_data['st_' . $key . $ind] = $value; //else $order_data['st_'.$key.$ind] = $order_data['bt_'.$key.$ind]; } } else { if (!empty($bta)) { foreach ($bta as $key => $value) { //if (!$fieldsOnly) $order_data['st_' . $key . $ind] = $value; // else $order_data['st_'.$key.$ind] = 'EMPTY'; } } } // ziskami polozky objednavky $qt = "SELECT * FROM `#__virtuemart_order_items` WHERE virtuemart_order_id='{$order_id}' "; $dbj->setQuery($qt); $prods = $dbj->loadAssocList(); $msg = $dbj->getErrorMsg(); if (!empty($msg)) { echo $msg; die; } if (!empty($prods)) { foreach ($prods as $ind2 => $prod) { foreach ($prod as $key => $value) { // polozka bude vyzarat napr takto: ar1['order_item_name_0_0'] = 'nazov produktu' if ($key != 'order_id') { $order_data[$key . $ind . '_' . $ind2] = $value; } } } } // ok, lets get payment information $q = "select * from `#__virtuemart_order_histories` where virtuemart_order_id = '" . $order_id . "' order by virtuemart_order_history_id desc "; $dbj->setQuery($q); $r = $dbj->loadAssocList(); foreach ($r as $ind2 => $historyitem) { foreach ($historyitem as $key => $value) { // payment date here is in variable (last change): // date_added_0_0 $order_data[$key . $ind . '_' . $ind2] = $value; } } $payment_id = $arr1['virtuemart_paymentmethod_id']; if (!empty($payment) || $payment === '0') { $order_data['payment_method_id_' . $ind2] = $payment; $q = "select * from #__virtuemart_paymentmethods where virtuemart_paymentmethod_id = '" . $payment . "' "; $dbj->setQuery($q); $r = $dbj->loadAssoc(); if (!empty($r)) { foreach ($r as $key => $data) { $order_data[$key . $ind] = $data; } } } if (!empty($order_data['vendor_id_0_0'])) { $this->getVendorInfo($order_data, $order_data['vendor_id_0_0'], $ind); } else { getVendorInfo($order_data, $ind); } return $order_data; }
public static function updateHtml($html, &$order, $afterrender = false) { require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'config.php'; $ty_page = OPCconfig::getValue('ty_page', 'ty_page', 0, array()); if (empty($ty_page)) { return; } if (empty($order)) { return; } if (is_array($order)) { if (isset($order['details'])) { $order = $order['details']['BT']; } } //we must reload order here in case any plugin had changed it in meantime: $id = $order->virtuemart_order_id; if (!empty($id)) { require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php'; $orderModel = OPCmini::getModel('orders'); $order_full = $orderModel->getOrder($id); if (empty($order_full)) { return; } $order = $order_full['details']['BT']; } $status = $order->order_status; if (!is_object($order)) { return; } $payment_id = $order->virtuemart_paymentmethod_id; if (empty($order->order_language)) { $jlang = JFactory::getLanguage(); $cl = $jlang->getTag(); $cl = strtolower(str_replace('-', '_', $cl)); } else { $cl = $order->order_language; } // check conditions: $orightml = $html; $todo = array(); foreach ($ty_page as $k => $ty) { if (!is_object($ty)) { continue; } if ($ty->payment_id != $payment_id) { continue; } if (!empty($ty->language)) { if ($ty->language != $cl) { continue; } } if ($ty->order_status != $status) { continue; } $todo[] = $ty; } if (empty($todo)) { return; } /* COM_ONEPAGE_TY_MODE_0="Prepend to payment generated html" COM_ONEPAGE_TY_MODE_1="Append to payment generated html" COM_ONEPAGE_TY_MODE_2="Replace payment generated html" */ require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'loader.php'; require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'opctracking.php'; $repvals = array(); $order_object = new stdClass(); OPCtrackingHelper::getOrderVars($id, $repvals, $order_object, false); foreach ($todo as $ty2) { $htmla = OPCloader::getArticle($ty2->article_id, $repvals); if (empty($ty2->mode)) { $html = $htmla . '<br />' . $html; } else { if ($ty2->mode == 1) { $html = $html . '<br />' . $htmla; } else { if ($ty->mode == 2) { $html = $htmla; } } } } if (defined('TYMODDONE')) { return $html; } else { define('TYMODDONE', true); } if ($orightml != $html) { if (!$afterrender) { JRequest::setVar('html', $html); } else { $buffer = JResponse::getBody(); $buffer = str_replace($orightml, $html, $buffer); JResponse::setBody($buffer); } } return $html; }
function runEucsv() { $x = @ob_get_clean(); $x = @ob_get_clean(); $x = @ob_get_clean(); $x = @ob_get_clean(); $x = @ob_get_clean(); $x = @ob_get_clean(); $x = @ob_get_clean(); $x = @ob_get_clean(); header('Content-Type: text/csv; charset=utf-8'); header("Content-Disposition: attachment; filename=\"output.csv\";"); $eu = array('AT', 'BE', 'BG', 'CY', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HU', 'IE', 'IT', 'LT', 'LU', 'LV', 'MT', 'NL', 'PL', 'PT', 'RO', 'SE', 'SI', 'SK'); require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'opctracking.php'; $array = array(); $order = new stdClass(); $db = JFactory::getDBO(); // all orders: $q = 'select virtuemart_order_id from #__virtuemart_orders where 1 limit 999999'; $db->setQuery($q); $res = $db->loadAssocList(); $header = false; $ha = array(); foreach ($res as $row) { $order_id = $row['virtuemart_order_id']; $array = array(); $order = new stdClass(); //OPCtrackingHelper::getOrderVars(11, $array, $order); //var_dump($array); die(); OPCtrackingHelper::getOrderVars($order_id, $array, $order); if (!$header) { foreach ($array as $k2 => $c2) { echo '"' . $k2 . '",'; $ha[$k2] = ''; } echo '"is_eu",'; echo "\r\n"; $ha['is_eu'] = ''; $header = true; } //var_dump($ha); die(); $ha2 = $ha; foreach ($array as $k => $c) { //echo '"'.$c.'",'; //country_2_code if (array_key_exists($k, $ha)) { $ha2[$k] = '"' . $c . '",'; } if ($k == 'st_country_2_code') { if (in_array($c, $eu)) { $ha2['is_eu'] = '"X",'; } else { $ha2['is_eu'] = ','; } } } foreach ($ha2 as $val) { echo $val; } echo "\r\n"; } die; }
private function orderCreated(&$data, $old_order_status) { $hash2 = uniqid('opc', true); if (method_exists('JApplication', 'getHash')) { $hashn = JApplication::getHash('opctracking'); } else { $hashn = JUtility::getHash('opctracking'); } $hash = JRequest::getVar($hashn, $hash2, 'COOKIE'); if ($hash2 == $hash) { OPCtrackingHelper::setCookie($hash); } OPCtrackingHelper::orderCreated($hash, $data, $old_order_status); //OPC add-on: if any other plugin updates user data, they should get refreshed: // refresh user data: $user = JFactory::getUser(); $id = $user->id; $user = new JUser($id); $session = JFactory::getSession(); $session->set('user', $user); // end of refresh self::_tyPageMod($data, false); }
$app = JFactory::getApplication(); $app->close(); } else { if ($task === 'loadjs') { require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php'; $file = JRequest::getVar('file', ''); if (!empty($file)) { OPCmini::loadJSfile($file); $app = JFactory::getApplication(); $app->close(); die; } } else { if ($task === 'ping') { require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'opctracking.php'; OPCtrackingHelper::ping(); $app = JFactory::getApplication(); $app->close(); die; } } } //index.php?option=com_onepage&task=loadjs&file=onepage.js $memstart = memory_get_usage(true); define('OPCMEMSTART', $memstart); include JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'onepage.cfg.php'; if (!isset($opc_memory)) { $opc_memory = '128M'; } ini_set('memory_limit', $opc_memory); ini_set('error_reporting', 0);
public function __construct($orderID, $params2, $status, $params, $file = '') { $this->errorMsg = ''; if (empty(OPCtrackingHelper::$config[$status])) { $this->errorMsg .= 'Config not found for status: ' . $status . "<br />\n"; $this->error = true; return; } $this->params = new stdClass(); if (!empty($params)) { $this->params = $params; } //$this->pingUrl = JRoute::_('index.php?option=com_onepage&task=ping&nosef=1&format=raw&tmpl=component', false); $this->pingUrl = OPCtrackingHelper::getUrl() . 'index.php?option=com_onepage&task=ping&nosef=1&format=raw&tmpl=component'; if (method_exists('JApplication', 'getHash')) { $hashn = JApplication::getHash('opctracking'); } else { $hashn = JUtility::getHash('opctracking'); } $opchash = JRequest::getVar($hashn, false, 'COOKIE'); $this->cookieHash = $opchash; $this->pingData = 'hash=' . $this->escapeSingle(str_replace('&', '&', $opchash)); require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php'; $orderModel = OPCmini::getModel('orders'); $this->order = $orderModel->getOrder($orderID); if (empty($this->order)) { $this->errorMsg .= 'Order not found: ' . var_export($config, true) . "<br />\n"; $this->error = true; return; } if (empty($this->order['items']) || !is_array($this->order['items'])) { $this->errorMsg .= 'Order items not found: ' . var_export($config, true) . "<br />\n"; $this->error = true; return; } require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'config.php'; $negative_statuses = OPCconfig::getValue('tracking_negative', 'negative_statuses', 0, array()); if (!empty($negative_statuses)) { $copy_negative_statuses = array(); foreach ($negative_statuses as $key => $ng) { $copy_negative_statuses[$key] = $ng; } $negative_statuses = $copy_negative_statuses; if (is_array($negative_statuses)) { if (isset($this->order['details']['BT'])) { if (in_array($this->order['details']['BT']->order_status, $negative_statuses)) { OPCtrackingHelper::getNegativeOrder($this->order); } } } } if (empty($this->order['details'])) { $this->errorMsg .= 'Order details not found: ' . var_export($config, true) . "<br />\n"; $this->error = true; return; } // check if the tracking was enabled before or after the order was created if (is_array($this->order)) { if (!empty($this->order['details']['BT'])) { $c = $this->order['details']['BT']->created_on; $sql = $c; $date = new JDate($sql); $time = $date->toUnix(); if (!empty(OPCtrackingHelper::$config)) { if (!empty(OPCtrackingHelper::$config[$status])) { // opc update, old codee: $key = 'since' . $file; if (!empty(OPCtrackingHelper::$config[$status]->{$key})) { $since = OPCtrackingHelper::$config[$status]->{$key}; if ($since > $time) { $this->errorMsg .= 'OPC tracking was created AFTER the order was created: ' . var_export(OPCtrackingHelper::$config, true) . 'order created on ' . $c . date(DATE_RFC2822, $time) . ' tracking created on ' . $since . date(DATE_RFC2822, $since) . " <br />\n"; $this->error = true; return; } } $key = $file . '_since'; if (!empty(OPCtrackingHelper::$config[$status]->{$key})) { $since = OPCtrackingHelper::$config[$status]->{$key}; if ($since > $time) { $this->errorMsg .= 'OPC tracking system plugin was set up AFTER the order was created: ' . var_export(OPCtrackingHelper::$config, true) . 'order created on ' . $c . ' ' . date(DATE_RFC2822, $time) . ' tracking created on ' . $since . date(DATE_RFC2822, $since) . " <br />\n"; $this->error = true; return; } } } } } } $this->error = false; $this->pingData .= '&order_status=' . $status; $this->pingData .= '&order_id=' . $orderID; OPCtrackingHelper::getTextFields($this->order); $this->vendor = OPCtrackingHelper::getVendorInfo($this->order['details']['BT']->virtuemart_vendor_id); }
function getOrderVars(&$named) { require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'opctracking.php'; $array = array(); $object = new stdClass(); $named = array(); OPCtrackingHelper::getOrderVars(0, $array, $object, false, $named); return $array; }