17 require_once SQ_INCLUDE_PATH.
'/asset.inc';
19 define(
'SQ_ECOM_ORDER_STATUS_PROCESSING', 0);
20 define(
'SQ_ECOM_ORDER_STATUS_SUCCESS', 1);
21 define(
'SQ_ECOM_ORDER_STATUS_FAILED', 2);
48 $this->_ser_attrs =
true;
49 $this->
Asset($assetid);
66 if (!parent::_createAdditional($link))
return false;
69 $initial_path = $this->id;
70 require_once SQ_INCLUDE_PATH.
'/general_occasional.inc';
71 $valid_paths = make_valid_web_paths(Array($initial_path));
72 $good_paths = $GLOBALS[
'SQ_SYSTEM']->am->webPathsInUse($link[
'asset'], $valid_paths, $this->
id,
true);
93 $allowed_links = parent::_getAllowedLinks();
94 $allowed_links[SQ_LINK_NOTICE][
'product'] = Array(
'card' =>
'M',
'exclusive' =>
false);
96 return $allowed_links;
112 return parent::create($link);
130 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
131 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
135 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
136 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
139 return parent::setAttrValue($name, $value);
154 if (empty($products)) {
155 trigger_localised_error(
'ECOM0014', E_USER_WARNING);
160 $run_level_changed =
false;
161 if (!$GLOBALS[
'SQ_SYSTEM']->runLevelEnables(SQ_RUN_LEVEL_FORCED)) {
162 $GLOBALS[
'SQ_SYSTEM']->setRunLevel(SQ_RUN_LEVEL_FORCED);
163 $run_level_changed =
true;
168 foreach ($products as $id => $value) {
170 $product = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($id);
172 if ($GLOBALS[
'SQ_SYSTEM']->am->createAssetLink($this, $product, SQ_LINK_NOTICE) == 0) {
173 trigger_localised_error(
'ECOM0019', E_USER_WARNING);
176 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($product);
180 if ($run_level_changed) {
181 $GLOBALS[
'SQ_SYSTEM']->restoreRunLevel();
200 if (is_numeric($status)) {
203 case SQ_ECOM_ORDER_STATUS_PROCESSING :
204 $new_status = SQ_ECOM_ORDER_STATUS_PROCESSING;
205 if (empty($message)) {
206 $status_message = translate(
'ecom_order_status_processing');
208 $status_message = $message;
211 case SQ_ECOM_ORDER_STATUS_SUCCESS :
212 $new_status = SQ_ECOM_ORDER_STATUS_SUCCESS;
213 $status_message = translate(
'ecom_order_status_success');
215 case SQ_ECOM_ORDER_STATUS_FAILED :
216 $new_status = SQ_ECOM_ORDER_STATUS_FAILED;
217 $status_message = translate(
'ecom_order_status_failed');
226 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
227 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
230 $GLOBALS[
'SQ_SYSTEM']->setRunLevel(SQ_RUN_LEVEL_FORCED);
236 if (!empty($status_message)) {
243 if (!$GLOBALS[
'SQ_SYSTEM']->am->acquireLock($this->id,
'attributes')) {
248 $GLOBALS[
'SQ_SYSTEM']->am->releaseLock($this->
id,
'attributes');
251 $GLOBALS[
'SQ_SYSTEM']->restoreRunLevel();
254 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
256 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
259 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
278 'status' => $this->
attr(
'status'),
279 'status_message' => $this->
attr(
'status_message'),
308 $keywords = parent::getAvailableKeywords();
310 $keywords[
'checkout_assetid'] = translate(
'ecom_order_keyword_checkout_assetid');
311 $keywords[
'order_summary'] = translate(
'ecom_order_keyword_order_summary');
312 $keywords[
'status'] = translate(
'ecom_order_keyword_status');
313 $keywords[
'status_message'] = translate(
'ecom_order_keyword_status_message');
314 $keywords[
'edit_url'] = translate(
'ecom_order_keyword_edit_url');
315 $keywords[
'order_xml'] = translate(
'ecom_order_keyword_order_xml');
316 $keywords[
'order_grand_total'] = translate(
'ecom_order_keyword_order_grand_total');
333 if (!isset($this->_tmp[
'checkout_asset'])) {
334 $link_to_checkout = $GLOBALS[
'SQ_SYSTEM']->am->getLink($this->
id, SQ_LINK_NOTICE,
'ecommerce_checkout',
true,
'checkout',
'minor');
335 $this->_tmp[
'checkout_asset'] = array_get_index($link_to_checkout,
'majorid', 0);
338 return $this->_tmp[
'checkout_asset'];
366 return $this->
attr(
'summary');
379 return $this->
attr(
'status');
392 return $this->
attr(
'status_message');
409 $url = $GLOBALS[
'SQ_SYSTEM']->am->getAssetURL($id);
415 strstr($url,
'?') ? $connector =
'&' : $connector =
'?';
417 $url .= $connector.
'edit_order_id='.$this->id;
419 return '<a href="'.$url.
'">'.$url.
'</a>';
432 return $this->
attr(
'order_xml');
445 return $this->
attr(
'order_grand_total');
459 if ($this->
attr(
'delivery_id') != 0) {
460 $method =& $GLOBALS[
'SQ_SYSTEM']->am->getAsset($this->
attr(
'delivery_id'));
477 $order_history = $this->
attr(
'order_history');
479 while (isset($order_history[$index])) {
482 $order_history[$index] = $msg;
485 $GLOBALS[
'SQ_SYSTEM']->setRunLevel(SQ_RUN_LEVEL_FORCED);
489 $GLOBALS[
'SQ_SYSTEM']->restoreRunLevel();