18 require_once SQ_INCLUDE_PATH.
'/asset_management.inc';
48 'order_history' => Array(
50 'type' =>
'serialise',
58 'status_message' => Array(
65 'type' =>
'serialise',
68 'delivery_id' => Array(
73 'delivery_state' => Array(
75 'type' =>
'serialise',
78 'order_form_value' => Array(
80 'type' =>
'serialise',
83 'ecom_ref_no' => Array(
89 'transaction_id' => Array(
93 'description' =>
'The ID of the payment transaction returned by the Payment Gateway',
96 'billing_name' => Array(
100 'description' =>
'The billing name returned by the Payment Gateway',
102 'billing_addr' => Array(
106 'description' =>
'The billing address returned by the Payment Gateway',
108 'delivery_name' => Array(
112 'description' =>
'The delivery name returned by the Payment Gateway',
114 'delivery_addr' => Array(
118 'description' =>
'The delivery address returned by the Payment Gateway',
120 'order_xml' => Array(
124 'description' =>
'The XML representation of this Order asset',
126 'order_grand_total' => Array(
130 'description' =>
'The grand total price of this Order asset',
147 if (version_compare($current_version,
'0.2',
'<=')) {
148 pre_echo(
'STARTING ECOMMERCE CHECKOUT UPGRADE - VERSION 0.3');
150 $root_folder = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'root_folder');
151 $children = $GLOBALS[
'SQ_SYSTEM']->am->getChildren($root_folder->id, $this->getAssetType(), FALSE);
153 pre_echo(
'Upgrading '.count($children).
' assets...');
154 foreach ($children as $assetid => $type) {
155 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid, $this->
getAssetType());
156 if (is_null($asset))
continue;
157 $products_info = $asset->attr(
'products');
159 $ecomm_checkout_id = array_keys($GLOBALS[
'SQ_SYSTEM']->am->getParents($assetid,
'ecommerce_checkout'));
160 if (empty($ecomm_checkout_id))
continue;
161 $ecomm_checkout = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($ecomm_checkout_id[0]);
162 if (is_null($ecomm_checkout))
continue;
164 if (!$GLOBALS[
'SQ_SYSTEM']->am->acquireLock($asset->id,
'attributes')) {
165 trigger_localised_error(
'CMS0025', E_USER_WARNING,
'0.2', $asset->name, $asset->id);
170 $flat_charges_total = 0;
173 $flat_charges_total = $ecomm_checkout->getFlatCharges();
175 $cart->setCartContainer($products_info);
176 $total_cost = $cart->getGrandTotalExDelivery($ecomm_checkout->attr(
'taxation_rate')/100, FALSE, $flat_charges_total);
180 $asset->setAttrValue(
'order_grand_total', $total_cost);
181 if (!$asset->saveAttributes()) {
182 trigger_localised_error(
'CMS0026', E_USER_WARNING,
'0.2');
186 $GLOBALS[
'SQ_SYSTEM']->am->releaseLock($asset->id,
'attributes');
189 pre_echo(
'UPGRADE COMPLETE - FROM VERSION '.$current_version.
' TO 0.3');
192 $res = parent::_upgrade($current_version);