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); }