Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
ecommerce_checkout_management.inc
1 <?php
17 require_once SQ_INCLUDE_PATH.'/asset_management.inc';
18 
30 {
31 
32 
38  {
39  $this->Asset_Management($pm);
40 
41  $this->vars['go_to_confirmation_button_text'] = Array(
42  'added' => '0.1',
43  'type' => 'text',
44  'default' => 'Go To Confirmation',
45  'description' => 'Go To Confirmation Button Text',
46  'is_contextable' => TRUE,
47  );
48 
49  $this->vars['confirm_order_button_text'] = Array(
50  'added' => '0.1',
51  'type' => 'text',
52  'default' => 'Confirm Order',
53  'description' => 'Confirm Order Button Text',
54  'is_contextable' => TRUE,
55  );
56 
57  $this->vars['return_to_checkout_button_text'] = Array(
58  'added' => '0.1',
59  'type' => 'text',
60  'default' => 'Return To Checkout',
61  'description' => 'Return To Checkout Button Text',
62  'is_contextable' => TRUE,
63  );
64 
65  // taxation variables
66  $this->vars['taxation_name'] = Array(
67  'added' => '0.2',
68  'type' => 'text',
69  'default' => 'GST',
70  'description' => 'Taxation Name',
71  'is_contextable' => TRUE,
72  );
73 
74  $this->vars['taxation_rate'] = Array(
75  'added' => '0.2',
76  'type' => 'float',
77  'default' => 10,
78  'parameters' => Array(
79  'range_lower' => 0,
80  'range_upper' => 100,
81  ),
82  );
83 
84  $this->vars['flat_charge_assetid'] = Array(
85  'added' => '0.3',
86  'type' => 'serialise',
87  'default' => Array(),
88  );
89 
90  $this->vars['tax_charge_assetid'] = Array(
91  'added' => '0.3',
92  'type' => 'serialise',
93  'default' => Array(),
94  );
95 
96  $this->vars['quantity_selector'] = Array(
97  'added' => '0.3',
98  'type' => 'selection',
99  'default' => 'metadata',
100  'parameters' => Array(
101  'multiple' => FALSE,
102  'allow_empty' => FALSE,
103  'options' => Array(
104  'metadata' => 'Metadata Text Field',
105  'attribute' => 'Asset Attribute',
106  ),
107  ),
108  );
109 
110  $this->vars['quantity_attribute'] = Array(
111  'added' => '0.3',
112  'type' => 'text',
113  'default' => '',
114  );
115 
116  $this->vars['quantity_field'] = Array(
117  'added' => '0.3',
118  'type' => 'assetid',
119  'default' => '',
120  );
121 
122  $this->vars['enforce_quantities'] = Array(
123  'added' => '0.3',
124  'type' => 'boolean',
125  'default' => 'FALSE',
126  'parameters' => Array(
127  'allow_empty' => FALSE,
128  ),
129  );
130 
131  $this->vars['quantity_message_cart'] = Array(
132  'added' => '0.3',
133  'type' => 'text',
134  'default' => 'There is an insufficient amount of items in stock to proceed with your order. Your order quantities have been altered to reflect the amount available. Items which are currently not in stock have been deleted from your cart. These items with insufficient quantities are listed below:',
135  'is_contextable' => TRUE,
136  );
137 
138  $this->vars['quantity_message_checkout'] = Array(
139  'added' => '0.3',
140  'type' => 'text',
141  'default' => 'There is an insufficient amount of items in stock to proceed with your order. Your order has not been processed. The items with insufficient quantities are listed below:',
142  'is_contextable' => TRUE,
143  );
144 
145  $this->vars['country_question'] = Array(
146  'added' => '0.3',
147  'type' => 'assetid',
148  'default' => '',
149  'is_admin' => 'TRUE',
150  );
151 
152  $this->vars['accept_empty_country_question'] = Array(
153  'added' => '0.4',
154  'type' => 'boolean',
155  'default' => FALSE,
156  'is_admin' => TRUE,
157  'description' => 'This attribute indicates whether delivery prices per weight metric are applied even without a country question specified',
158  'parameters' => Array(
159  'allow_empty' => FALSE,
160  ),
161  );
162 
163  $this->vars['taxable_countries'] = Array(
164  'added' => '0.3',
165  'type' => 'serialise',
166  'default' => Array(),
167  'is_admin' => 'TRUE',
168  );
169 
170  $this->vars['item_weight_selector'] = Array(
171  'added' => '0.3',
172  'type' => 'selection',
173  'default' => 'metadata',
174  'parameters' => Array(
175  'multiple' => FALSE,
176  'allow_empty' => FALSE,
177  'options' => Array(
178  'metadata' => 'Metadata Text Field',
179  'attribute' => 'Asset Attribute',
180  ),
181  ),
182  );
183 
184  $this->vars['item_weight_metadata_source'] = Array(
185  'added' => '0.3',
186  'type' => 'assetid',
187  'default' => '',
188  'is_admin' => TRUE,
189  );
190 
191  $this->vars['item_weight_attribute_source'] = Array(
192  'added' => '0.3',
193  'type' => 'text',
194  'default' => '',
195  'is_admin' => TRUE,
196  );
197 
198  $this->vars['delivery_weight_fee_mapping'] = Array(
199  'added' => '0.3',
200  'type' => 'serialise',
201  'default' => Array(),
202  'is_admin' => FALSE,
203  );
204 
205  $this->vars['default_delivery_weight_fee'] = Array(
206  'added' => '0.3',
207  'type' => 'float',
208  'default' => 0.0,
209  'is_admin' => TRUE,
210  );
211 
212  $this->vars['default_max_product_quantity'] = Array(
213  'added' => '0.4',
214  'type' => 'int',
215  'default' => '',
216  'is_admin' => TRUE,
217  'parameters' => Array(
218  'allow_negative' => FALSE,
219  'allow_empty' => TRUE,
220  'range_lower' => 1,
221  ),
222  );
223 
224  $this->vars['international_delivery_fee_exempt_countries'] = Array(
225  'added' => '0.3',
226  'type' => 'serialise',
227  'default' => Array(),
228  'is_admin' => 'TRUE',
229  );
230 
231  $this->vars['international_delivery_fee'] = Array(
232  'added' => '0.3',
233  'type' => 'float',
234  'default' => 0.0,
235  'is_admin' => TRUE,
236  );
237 
238  $this->vars['conditional_delivery_fees'] = Array(
239  'added' => '0.3',
240  'type' => 'serialise',
241  'default' => Array(),
242  'is_admin' => TRUE,
243  );
244 
245  $this->vars['customise_receipt'] = Array(
246  'added' => '0.3',
247  'type' => 'boolean',
248  'default' => FALSE,
249  'is_admin' => TRUE,
250  );
251 
252  $this->vars['currency_symbol'] = Array(
253  'added' => '0.3',
254  'type' => 'text',
255  'default' => '$',
256  'is_admin' => TRUE,
257  );
258 
259  $this->vars['float_precision'] = Array(
260  'added' => '0.3',
261  'type' => 'int',
262  'default' => '2',
263  'is_admin' => TRUE,
264  );
265 
266  $this->vars['max_delivery_fee'] = Array(
267  'added' => '0.4',
268  'type' => 'float',
269  'default' => 0.0,
270  'is_admin' => TRUE,
271  );
272 
273  $this->vars['refund_info_text'] = Array(
274  'added' => '0.4',
275  'type' => 'text',
276  'default' => '',
277  'description' => 'Text to display if some products in cart are non-refundable',
278  );
279  $this->vars['actions'] = Array(
280  'added' => '0.4',
281  'type' => 'serialise',
282  'default' => Array(),
283  'description' => 'Actions that needs to be executed at the end of checkout',
284  );
285 
286 
287 
288  }//end constructor
289 
290 
297  function getEventList()
298  {
299  return Array(
300  Array(
301  'event_name' => 'requestKeywords',
302  'broadcast_type_code' => 'content_type',
303  'broadcast_strict_type_code' => FALSE,
304  'options' => Array(
305  'side_of_link' => 'major',
306  'indirect' => TRUE,
307  'is_exclusive' => NULL,
308  'is_dependant' => 1,
309  'value' => '',
310  'link_type' => SQ_LINK_TYPE_2,
311  ),
312  ),
313  );
314 
315  }//end getEventList()
316 
317 
326  function _upgrade($current_version)
327  {
328  // ensure that the correct order submission folders are created underneath all Ecommerce_Checkout assets (introduced in 0.4)
329  // also move all existing orders underneath the Completed Orders folder
330 
331  if (version_compare($current_version, '0.3', '<=')) {
332  pre_echo('STARTING ECOMMERCE CHECKOUT UPGRADE - VERSION 0.4');
333 
334  // check each Ecommerce_Checkout asset
335  $sql = 'SELECT assetid
336  FROM sq_ast
337  WHERE type_code = '.MatrixDAL::quote('ecommerce_checkout');
338  try {
339  $checkout_assetids = MatrixDAL::executeSqlAssoc($sql);
340  } catch (Exception $e) {
341  throw new Exception('Unable to locate Ecommerce_Checkout assets due to database error: '.$e->getMessage());
342  }
343 
344  $sub_assets = Array(
345  'pending_orders' => 'folder',
346  'orders_to_review' => 'folder',
347  );
348 
349  foreach ($checkout_assetids as $row => $info) {
350  $checkout = $GLOBALS['SQ_SYSTEM']->am->getAsset($info['assetid']);
351 
352  // create 2 folders for each asset
353  foreach ($sub_assets as $link_value => $type) {
354  $asset = new $type();
355  $copy_link = Array(
356  'asset' => $checkout,
357  'value' => $link_value,
358  'link_type' => SQ_LINK_TYPE_2,
359  'is_dependant' => 1,
360  'is_exclusive' => 1,
361  );
362 
363  $asset->setAttrValue('name', ucwords(str_replace('_',' ', $link_value)));
364  if (!$asset->create($copy_link)) return FALSE;
365  }
366 
367  // update the existing Orders folder
368  $order_folder_link = $GLOBALS['SQ_SYSTEM']->am->getLink($checkout->id, SQ_LINK_TYPE_2, 'folder', TRUE, 'orders');
369  if (!$GLOBALS['SQ_SYSTEM']->am->updateLink($order_folder_link['linkid'], SQ_LINK_TYPE_2, 'completed_orders')) return FALSE;
370  // change the name
371  $order_folder = $GLOBALS['SQ_SYSTEM']->am->getAsset($order_folder_link['minorid']);
372  $order_folder->setAttrValue('name', 'Completed Orders');
373  $order_folder->saveAttributes();
374  }
375 
376  pre_echo('COMPLETED ECOMMERCE CHECKOUT UPGRADE - VERSION 0.4');
377 
378  }
379 
380  // first do things as normal
381  $res = parent::_upgrade($current_version);
382 
383  return $res;
384 
385  }//end _upgrade()
386 
387 
388 }//end class
389 
390 ?>