QuBit_UniversalVariable - Version 1.0.8

Version Notes

Rename page categroy from controller/view naming to correct page category inclueding home, checkout, basket, confirmation, product, category pages; Added listing variable for category pages

Download this release

Release Info

Developer Jing Dong
Extension QuBit_UniversalVariable
Version 1.0.8
Comparing to
See all releases


Code changes from version 1.0.7 to 1.0.8

app/code/local/QuBit/UniversalVariable/Model/Page/Observer.php CHANGED
@@ -1,7 +1,8 @@
1
  <?php
 
2
  class QuBit_UniversalVariable_Model_Page_Observer {
3
 
4
- protected $_version = "1.0.0";
5
  protected $_user = null;
6
  protected $_page = null;
7
  protected $_basket = null;
@@ -33,6 +34,47 @@ class QuBit_UniversalVariable_Model_Page_Observer {
33
  return $this->_getRequest()->getRouteName();
34
  }
35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  /*
37
  * Creates Block View
38
  */
@@ -41,24 +83,163 @@ class QuBit_UniversalVariable_Model_Page_Observer {
41
  $block = $layout->createBlock('QuBit_UniversalVariable_Block_Uv','universal_variable_block');
42
  }
43
 
 
44
  /*
45
- * Sets user information
46
- */
47
- public function _setUser() {
48
- $user = Mage::helper('customer')->getCustomer();
49
- $this->_user = array();
50
- $this->_user['email'] = $user->getEmail();
51
- $this->_user['id'] = $user->getEntityId();
52
- $this->_user['returning'] = $this->_user['id'] ? true : false;
53
- $this->_user['language'] = Mage::app()->getLocale()->getDefaultLocale();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  }
55
 
56
- /*
57
- * Sets current page information
58
- */
59
  public function _setPage() {
60
  $this->_page = array();
61
- $this->_page['category'] = $this->_getModuleName().'/'.$this->_getControllerName().'/'.$this->_getActionName();
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  }
63
 
64
  public function _getAddress($address) {
@@ -74,48 +255,6 @@ class QuBit_UniversalVariable_Model_Page_Observer {
74
  return $billing;
75
  }
76
 
77
- public function _setTranscation() {
78
- // default controllerName is "onepage"
79
- // relax the check, only check if contains checkout
80
- // somecheckout systems has different prefix/postfix,
81
- // but all contains checkout
82
- $isCheckout = strpos($this->_getModuleName(), 'checkout') !== false;
83
-
84
- if ($isCheckout && $this->_getActionName() == "success") {
85
- $orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
86
- if ($orderId) {
87
- $transaction = array();
88
- $order = Mage::getModel('sales/order')->load($orderId);
89
- $items = $order->getAllItems();
90
- $line_items = $this->_getInvoicedLineItems($items);
91
- $shippingAddress = $order->getShippingAddress();
92
- $billingAddress = $order->getBillingAddress();
93
-
94
- $transaction['order_id'] = $order->getIncrementId();
95
- $transaction['currency'] = $this->_getCurrency();
96
- $transaction['subtotal'] = (float) $order->getSubtotal();
97
- // TODO: subtotal_include_tax
98
- $transaction['total'] = (float) $order->getGrandTotal();
99
- $transaction['voucher'] = $order->getCouponCode();
100
- // TODO: voucher_discount
101
- $transaction['tax'] = (float) $order->getTax();
102
- $transaction['shipping_cost'] = (float) $order->getShippingAmount();
103
- $transaction['shipping_method'] = $order->getShippingMethod();
104
- $transaction['billing'] = $this->_getAddress($billingAddress);
105
- $transaction['delivery'] = $this->_getAddress($shippingAddress);
106
- $transaction['line_items'] = $line_items;
107
- $this->_transaction = $transaction;
108
- }
109
- }
110
- }
111
-
112
- public function _setProduct() {
113
- $product = Mage::registry('current_product');
114
- if ($product) {
115
- $this->_product = $this->_getProductModel($product);;
116
- }
117
- }
118
-
119
  public function _getProuctStock($product) {
120
  return (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getQty();
121
  }
@@ -133,42 +272,42 @@ class QuBit_UniversalVariable_Model_Page_Observer {
133
  $product_model['unit_price'] = (float) $product->getPrice();
134
  $product_model['unit_sale_price'] = (float) $product->getFinalPrice();
135
  $product_model['currency'] = $this->_getCurrency();
136
- $product_model['description'] = $product->getDescription();
137
  $product_model['stock'] = $this->_getProuctStock($product);
 
138
  return $product_model;
139
  }
140
 
141
- public function _getLineItems($items) {
142
- $line_items = array();
143
- foreach($items as $item) {
144
- // backwards compaibility, getProduct() is not supported in older version
145
- $productId = $item->getProductId();
146
- $product = Mage::getModel('catalog/product')->load($productId);
147
-
148
- if ($product && $product->isVisibleInSiteVisibility()) {
149
- $litem_model = array();
150
- $litem_model['product'] = $this->_getProductModel($product);
151
- $litem_model['quantity'] = $item->getQty();
152
- $litem_model['subtotal'] = (float) $item->getRowTotalInclTax();
153
- $litem_model['total_discount'] = (float) $item->getDiscountAmount();
154
- array_push($line_items, $litem_model);
155
  }
 
 
156
  }
157
- return $line_items;
158
  }
159
 
160
- public function _getInvoicedLineItems($items) {
 
161
  $line_items = array();
162
  foreach($items as $item) {
163
- // backwards compaibility, getProduct() is not supported in older version
164
  $productId = $item->getProductId();
165
- $product = Mage::getModel('catalog/product')->load($productId);
166
-
167
- if ($product && $product->isVisibleInSiteVisibility()) {
168
- $litem_model = array();
169
- $litem_model['product'] = $this->_getProductModel($product);
170
- $litem_model['quantity'] = (float) $item->getQtyOrdered();
171
- $litem_model['subtotal'] = (float) $item->getRowTotalInclTax();
172
  $litem_model['total_discount'] = (float) $item->getDiscountAmount();
173
  array_push($line_items, $litem_model);
174
  }
@@ -177,75 +316,142 @@ class QuBit_UniversalVariable_Model_Page_Observer {
177
  }
178
 
179
  public function _setListing() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
180
  }
181
 
182
- /*
183
- * Sets basket information
184
- */
185
  public function _setBasket() {
186
- $cart = Mage::getSingleton('checkout/cart');
187
- $quote = $cart->getQuote();
 
 
 
 
 
188
  $basket = array();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
189
  $items = $quote->getAllItems();
190
- $subTotal = $quote->getSubtotal();
191
- $grandTotal = $quote->getGrandTotal();
192
- $line_items = $this->_getLineItems($items);
193
-
194
- $basket['id'] = Mage::getSingleton('checkout/session')->getQuoteId();
195
- $basket['currency'] = $this->_getCurrency();
196
- $basket['subtotal'] = (float) $subTotal;
197
- // TODO: subtotal_incluce_tax
198
- // TODO: tax
199
- // TODO: shipping_cost
200
- // TODO: shipping_method
201
- $basket['total'] = (float) $grandTotal;
202
- $basket['line_items'] = $line_items;
203
  $this->_basket = $basket;
204
  }
205
 
206
- public function setUniversalVariable($observer) {
207
- $this->_setUser();
208
- $this->_setPage();
209
- $this->_setProduct();
210
- $this->_setListing();
211
- $this->_setBasket();
212
- $this->_setTranscation();
213
- $this->_createBlock();
214
-
215
- return $this;
 
216
  }
217
 
218
-
219
- public function getVersion() {
220
- return $this->_version;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
221
  }
222
 
223
- public function getUser() {
224
- return $this->_user;
225
- }
226
 
227
- public function getPage() {
228
- return $this->_page;
229
- }
230
 
231
- public function getProduct() {
232
- return $this->_product;
233
- }
234
 
235
- public function getBasket() {
236
- return $this->_basket;
237
- }
238
 
239
- public function getTransaction() {
240
- return $this->_transaction;
241
- }
242
 
243
- public function getListing() {
244
- return $this->_listing;
245
- }
246
 
247
- public function getMageVersion() {
248
- return Mage::getVersion();
249
  }
 
250
  }
251
  ?>
1
  <?php
2
+
3
  class QuBit_UniversalVariable_Model_Page_Observer {
4
 
5
+ protected $_version = "1.1.1";
6
  protected $_user = null;
7
  protected $_page = null;
8
  protected $_basket = null;
34
  return $this->_getRequest()->getRouteName();
35
  }
36
 
37
+ protected function _getCustomer() {
38
+ return Mage::helper('customer')->getCustomer();
39
+ }
40
+
41
+ protected function _getCategory($category_id) {
42
+ return Mage::getModel('catalog/category')->load($category_id);
43
+ }
44
+
45
+ protected function _getCurrentProduct() {
46
+ return Mage::registry('current_product');
47
+ }
48
+
49
+ protected function _getProduct($productId) {
50
+ return Mage::getModel('catalog/product')->load($productId);
51
+ }
52
+
53
+ protected function _getCurrentCategory() {
54
+ return Mage::registry('current_category');
55
+ }
56
+
57
+ protected function _getCatalogSearch() {
58
+ return Mage::getSingleton('catalogsearch/advanced');
59
+ }
60
+
61
+ protected function _getCheckoutCart() {
62
+ return Mage::getSingleton('checkout/cart');
63
+ }
64
+
65
+ protected function _getCheckoutSession() {
66
+ return Mage::getSingleton('checkout/session');
67
+ }
68
+
69
+ protected function _getSalesOrder() {
70
+ return Mage::getModel('sales/order');
71
+ }
72
+
73
+ protected function _getOrderAddress() {
74
+ return Mage::getModel('sales/order_address');
75
+ }
76
+
77
+
78
  /*
79
  * Creates Block View
80
  */
83
  $block = $layout->createBlock('QuBit_UniversalVariable_Block_Uv','universal_variable_block');
84
  }
85
 
86
+
87
  /*
88
+ * Determine which page type we're on
89
+ */
90
+
91
+ public function _isHome() {
92
+ if (Mage::app()->getRequest()->getRequestString() == "/") {
93
+ return true;
94
+ } else {
95
+ return false;
96
+ }
97
+ }
98
+
99
+ public function _isContent() {
100
+ if ($this->_getModuleName() == 'cms') {
101
+ return true;
102
+ } else {
103
+ return false;
104
+ }
105
+ }
106
+
107
+ public function _isCategory() {
108
+ if ($this->_getControllerName() == 'category') {
109
+ return true;
110
+ } else {
111
+ return false;
112
+ }
113
+ }
114
+
115
+ public function _isSearch() {
116
+ if ($this->_getModuleName() == 'catalogsearch') {
117
+ return true;
118
+ } else {
119
+ return false;
120
+ }
121
+ }
122
+
123
+ public function _isProduct() {
124
+ $onCatalog = false;
125
+ if(Mage::registry('current_product')) {
126
+ $onCatalog = true;
127
+ }
128
+ return $onCatalog;
129
+ }
130
+
131
+ public function _isBasket() {
132
+ $request = $this->_getRequest();
133
+ $module = $request->getModuleName();
134
+ $controller = $request->getControllerName();
135
+ $action = $request->getActionName();
136
+ if ($module == 'checkout' && $controller == 'cart' && $action == 'index'){
137
+ return true;
138
+ } else {
139
+ return false;
140
+ }
141
+ }
142
+
143
+ public function _isCheckout() {
144
+ if (strpos($this->_getModuleName(), 'checkout') !== false && $this->_getActionName() != 'success') {
145
+ return true;
146
+ } else {
147
+ return false;
148
+ }
149
+ }
150
+
151
+ public function _isConfirmation() {
152
+ // default controllerName is "onepage"
153
+ // relax the check, only check if contains checkout
154
+ // somecheckout systems has different prefix/postfix,
155
+ // but all contains checkout
156
+ if (strpos($this->_getModuleName(), 'checkout') !== false && $this->_getActionName() == "success") {
157
+ return true;
158
+ } else {
159
+ return false;
160
+ }
161
+ }
162
+
163
+
164
+ /*
165
+ * Get information on pages to pass to front end
166
+ */
167
+
168
+ public function getVersion() {
169
+ return $this->_version;
170
+ }
171
+
172
+ public function getUser() {
173
+ return $this->_user;
174
+ }
175
+
176
+ public function getPage() {
177
+ return $this->_page;
178
+ }
179
+
180
+ public function getProduct() {
181
+ return $this->_product;
182
+ }
183
+
184
+ public function getBasket() {
185
+ return $this->_basket;
186
+ }
187
+
188
+ public function getTransaction() {
189
+ return $this->_transaction;
190
+ }
191
+
192
+ public function getListing() {
193
+ return $this->_listing;
194
+ }
195
+
196
+ public function getMageVersion() {
197
+ return Mage::getVersion();
198
+ }
199
+
200
+
201
+ /*
202
+ * Set the model attributes to be passed front end
203
+ */
204
+
205
+ public function _getPage() {
206
+ if ($this->_isHome()) {
207
+ return 'home';
208
+ } elseif ($this->_isContent()) {
209
+ return 'content';
210
+ } elseif ($this->_isCategory()) {
211
+ return 'category';
212
+ } elseif ($this->_isSearch()) {
213
+ return 'search';
214
+ } elseif ($this->_isProduct()) {
215
+ return 'product';
216
+ } elseif ($this->_isBasket()) {
217
+ return 'basket';
218
+ } elseif ($this->_isCheckout()) {
219
+ return 'checkout';
220
+ } elseif ($this->_isConfirmation()) {
221
+ return 'confirmation';
222
+ } else {
223
+ return $this->_getModuleName();
224
+ }
225
  }
226
 
 
 
 
227
  public function _setPage() {
228
  $this->_page = array();
229
+ $this->_page['category'] = $this->_getPage();
230
+ }
231
+
232
+ // Set the user info
233
+ public function _setUser() {
234
+ $user = $this->_getCustomer();
235
+ $this->_user = array();
236
+ $email = $user->getEmail();
237
+ if ($email) $this->_user['email'] = $email;
238
+ $user_id = $user->getEntityId();
239
+ if ($user_id) $this->_user['user_id'] = $user_id;
240
+ $this->_user['returning'] = $this->_user['id'] ? true : false;
241
+ // Buggy - doesn't update
242
+ //$this->_user['language'] = Mage::app()->getLocale()->getLocaleCode();
243
  }
244
 
245
  public function _getAddress($address) {
255
  return $billing;
256
  }
257
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
258
  public function _getProuctStock($product) {
259
  return (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getQty();
260
  }
272
  $product_model['unit_price'] = (float) $product->getPrice();
273
  $product_model['unit_sale_price'] = (float) $product->getFinalPrice();
274
  $product_model['currency'] = $this->_getCurrency();
275
+ $product_model['description'] = $product->getShortDescription();
276
  $product_model['stock'] = $this->_getProuctStock($product);
277
+ $product_model['category'] = $this->_getProductCategories($product);
278
  return $product_model;
279
  }
280
 
281
+ public function _getProductCategories($product) {
282
+ $cats = $product->getCategoryIds();
283
+ if ($cats) {
284
+ $category_names = array();
285
+ foreach ($cats as $category_id) {
286
+ $_cat = $this->_getCategory($category_id);
287
+ $category_names[] = $_cat->getName();
288
+ }
289
+ if (is_array($category_names) and !empty($category_names)) {
290
+ return implode(', ', $category_names);
291
+ } else {
292
+ return false;
 
 
293
  }
294
+ } else {
295
+ return false;
296
  }
 
297
  }
298
 
299
+
300
+ public function _getLineItems($items) {
301
  $line_items = array();
302
  foreach($items as $item) {
 
303
  $productId = $item->getProductId();
304
+ $product = $this->_getProduct($productId);
305
+ // product needs to be visible
306
+ if ($product->isVisibleInSiteVisibility()) {
307
+ $litem_model = array();
308
+ $litem_model['product'] = $this->_getProductModel($product);
309
+ $litem_model['quantity'] = (float) $item->getQtyOrdered();
310
+ $litem_model['subtotal'] = (float) $item->getRowTotalInclTax();
311
  $litem_model['total_discount'] = (float) $item->getDiscountAmount();
312
  array_push($line_items, $litem_model);
313
  }
316
  }
317
 
318
  public function _setListing() {
319
+ $this->_listing = array();
320
+ if ($this->_isCategory()) {
321
+ $category = $this->_getCurrentCategory();
322
+
323
+ } elseif ($this->_isSearch()) {
324
+ $category = $this->_getCatalogSearch();
325
+ if (isset($_GET['q'])) {
326
+ $this->_listing['query'] = $_GET['q'];
327
+ }
328
+ }
329
+ $collection = $category->getProductCollection();
330
+ $products = array();
331
+ foreach ($collection as $item) {
332
+ $productId = $item->getId();
333
+ $product = $this->_getProduct($productId);
334
+ // only expose visible product
335
+ if ($product->isVisibleInSiteVisibility()) {
336
+ array_push($products, $this->_getProductModel($product));
337
+ }
338
+ }
339
+ $this->_listing['items'] = $products;
340
+ }
341
+
342
+ public function _setProduct() {
343
+ $product = $this->_getCurrentProduct();
344
+ if (!$product) return false;
345
+ $this->_product = $this->_getProductModel($product);
346
  }
347
 
 
 
 
348
  public function _setBasket() {
349
+ // Get from different model depending on page
350
+ if ($this->_isBasket()) {
351
+ $cart = $this->_getCheckoutCart();
352
+ } elseif ($this->_isCheckout()) {
353
+ $cart = $this->_getCheckoutSession();
354
+ }
355
+
356
  $basket = array();
357
+ $quote = $cart->getQuote();
358
+
359
+ // Set normal params
360
+ $basket_id = $this->_getCheckoutSession()->getQuoteId();
361
+ if ($basket_id) {
362
+ $basket['id'] = $basket_id;
363
+ }
364
+ $basket['currency'] = $this->_getCurrency();
365
+ $basket['subtotal'] = (float) $quote->getSubtotal();
366
+ $basket['subtotal_include_tax'] = $this->_doesSubtotalIncludeTax($quote);
367
+ $basket['tax'] = (float) $quote->getTax();
368
+ $basket['shipping_cost'] = (float) $quote->getShippingAmount();
369
+ $basket['shipping_method'] = $quote->getShippingMethod();
370
+ $basket['total'] = (float) $quote->getGrandTotal();
371
+
372
+ // Line items
373
  $items = $quote->getAllItems();
374
+ $basket['line_items'] = $this->_getLineItems($items);
375
+
 
 
 
 
 
 
 
 
 
 
 
376
  $this->_basket = $basket;
377
  }
378
 
379
+ public function _doesSubtotalIncludeTax($order) {
380
+ /* Conditions:
381
+ - if tax is zero, then set to false
382
+ - Assume that if grand total is bigger than total after subtracting shipping, then subtotal does NOT include tax
383
+ */
384
+ $grandTotalWithoutShipping = $order->getGrandTotal() - $order->getShippingAmount();
385
+ if ($order->getTax() == 0 || $grandTotalWithoutShipping > $order->getSubtotal()) {
386
+ return false;
387
+ } {
388
+ return true;
389
+ }
390
  }
391
 
392
+ public function _setTranscation() {
393
+ $orderId = $this->_getCheckoutSession()->getLastOrderId();
394
+ if ($orderId) {
395
+ $transaction = array();
396
+ $order = $this->_getSalesOrder()->load($orderId);
397
+
398
+ // Get general details
399
+ $transaction['order_id'] = $order->getIncrementId();
400
+ $transaction['currency'] = $this->_getCurrency();
401
+ $transaction['subtotal'] = (float) $order->getSubtotal();
402
+ $transaction['subtotal_include_tax'] = $this->_doesSubtotalIncludeTax($order);
403
+ $transaction['payment_type'] = $order->getPayment()->getMethodInstance()->getTitle();
404
+ $transaction['total'] = (float) $order->getGrandTotal();
405
+ $transaction['voucher'] = $order->getCouponCode();
406
+ // TODO: voucher_discount
407
+ $transaction['tax'] = (float) $order->getTax();
408
+ $transaction['shipping_cost'] = (float) $order->getShippingAmount();
409
+ $transaction['shipping_method'] = $order->getShippingMethod();
410
+
411
+ // Get addresses
412
+ $shippingId = $order->getShippingAddress()->getId();
413
+ $address = $this->_getOrderAddress()->load($shippingId);
414
+ $billingAddress = $order->getBillingAddress();
415
+ $shippingAddress = $order->getShippingAddress();
416
+ $transaction['billing'] = $this->_getAddress($billingAddress);
417
+ $transaction['delivery'] = $this->_getAddress($shippingAddress);
418
+
419
+ // Get items
420
+ $items = $order->getAllItems();
421
+ $line_items = $this->_getLineItems($items);
422
+ $transaction['line_items'] = $line_items;
423
+
424
+ $this->_transaction = $transaction;
425
+ }
426
  }
427
 
428
+ public function setUniversalVariable($observer) {
429
+ $this->_setUser();
430
+ $this->_setPage();
431
 
432
+ if ($this->_isProduct()) {
433
+ $this->_setProduct();
434
+ }
435
 
436
+ if ($this->_isCategory()) {
437
+ $this->_setListing();
438
+ }
439
 
440
+ if ($this->_isCategory() || $this->_isSearch()) {
441
+ $this->_setListing();
442
+ }
443
 
444
+ if ($this->_isBasket() || $this->_isCheckout()) {
445
+ $this->_setBasket();
446
+ }
447
 
448
+ if ($this->_isConfirmation()) {
449
+ $this->_setTranscation();
450
+ }
451
 
452
+ $this->_createBlock();
453
+ return $this;
454
  }
455
+
456
  }
457
  ?>
app/design/frontend/default/default/template/qubit/universal_variable.phtml CHANGED
@@ -14,7 +14,7 @@
14
  };
15
  ?>
16
 
17
- <?php if ($qubit_universal_variable_enabled == 1):?>
18
  <?php
19
  // extract variable only when universal variable is enabled
20
  $version = $mage->getVersion();
@@ -29,27 +29,27 @@
29
  <!-- Universal Variable Start -->
30
  <script type="text/javascript">
31
  window.universal_variable = window.universal_variable || {};
32
- window.universal_variable.version = <?php echo json_encode($version) ?>;
33
- window.universal_variable.magento_version = <?php echo json_encode($magento_version) ?>;
34
- window.universal_variable.page = <?php echo json_encode($page) ?>;
35
- window.universal_variable.user = <?php echo json_encode($user) ?>;
36
- <?php if ($product) : ?>
37
- window.universal_variable.product = <?php echo json_encode($product) ?>;
38
- <?php endif?>
39
- <?php if ($basket) : ?>
40
- window.universal_variable.basket = <?php echo json_encode($basket) ?>;
41
- <?php endif ?>
42
- <?php if ($listing) : ?>
43
- window.universal_variable.listing = <?php echo json_encode($listing) ?>;
44
- <?php endif ?>
45
- <?php if ($transaction) : ?>
46
- window.universal_variable.transaction = <?php echo json_encode($transaction) ?>;
47
- <?php endif ?>
48
  </script>
49
  <!-- Universal Variable End -->
50
  <?php endif;?>
51
 
52
- <?php if ($qubit_opentag_container_id && $qubit_opentag_enabled == 1):?>
53
  <!-- QuBit OpenTag Start -->
54
  <script type="text/javascript" src='//d3c3cq33003psk.cloudfront.net/opentag-<?php echo $qubit_opentag_container_id;?>.js' <?php echo $qubit_opentag_async;?>></script>
55
  <!-- QuBit OpenTag End -->
14
  };
15
  ?>
16
 
17
+ <?php if ($qubit_universal_variable_enabled == 1) :?>
18
  <?php
19
  // extract variable only when universal variable is enabled
20
  $version = $mage->getVersion();
29
  <!-- Universal Variable Start -->
30
  <script type="text/javascript">
31
  window.universal_variable = window.universal_variable || {};
32
+ window.universal_variable.version = <?php echo json_encode($version); ?>;
33
+ window.universal_variable.magento_version = <?php echo json_encode($magento_version) ?>;
34
+ window.universal_variable.page = <?php echo json_encode($page); ?>;
35
+ window.universal_variable.user = <?php echo json_encode($user); ?>;
36
+ <?php if ($product) :?>
37
+ window.universal_variable.product = <?php echo json_encode($product) ?>;
38
+ <?php endif; ?>
39
+ <?php if ($basket) :?>
40
+ window.universal_variable.basket = <?php echo json_encode($basket) ?>;
41
+ <?php endif; ?>
42
+ <?php if ($listing) :?>
43
+ window.universal_variable.listing = <?php echo json_encode($listing) ?>;
44
+ <?php endif; ?>
45
+ <?php if ($transaction) :?>
46
+ window.universal_variable.transaction = <?php echo json_encode($transaction) ?>;
47
+ <?php endif; ?>
48
  </script>
49
  <!-- Universal Variable End -->
50
  <?php endif;?>
51
 
52
+ <?php if ($qubit_opentag_container_id && $qubit_opentag_enabled == 1) :?>
53
  <!-- QuBit OpenTag Start -->
54
  <script type="text/javascript" src='//d3c3cq33003psk.cloudfront.net/opentag-<?php echo $qubit_opentag_container_id;?>.js' <?php echo $qubit_opentag_async;?>></script>
55
  <!-- QuBit OpenTag End -->
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>QuBit_UniversalVariable</name>
4
- <version>1.0.7</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/osl-3.0.php">Extension license name (OSL v3.0)</license>
7
  <channel>community</channel>
@@ -12,11 +12,11 @@
12
  <description>QuBit OpenTag recommends creating the releavant JavaScript object on your page prior to the OpenTag container script. This will assure the values are present on the page when a script tries to access them.&#xD;
13
  &#xD;
14
  If a page does not have the variables of an object that are mentioned below, simply do not even declare them. For example, if your pages only have category and no subcategory, just declare your category. Likewise, if you feel the need to extend the objects below or feel like renaming them, please do so. However, please take a note of the new variable names or the edited ones, because in order to access them from your scripts in your OpenTag container, you will need to use the new variable names.</description>
15
- <notes>Added total_discount for a line item in basket and transaction; it's useful to calculate average product cost if any complicated sales discount rule applied.</notes>
16
  <authors><author><name>Jing Dong</name><user>qubitproducts</user><email>jing@qubitdigital.com</email></author></authors>
17
- <date>2013-01-16</date>
18
- <time>15:54:27</time>
19
- <contents><target name="magelocal"><dir name="QuBit"><dir name="UniversalVariable"><dir name="Block"><file name="Uv.php" hash="9b5cd71bebc9576b5d0714b3fe5c13bb"/></dir><dir name="Helper"><file name="Data.php" hash="b05ea847c16520d5e6eec91e9f604886"/></dir><dir name="Model"><dir name="Page"><file name="Observer.php" hash="a7a8fe071729d81e87c24ac4a580d1f5"/></dir><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><dir name="etc"><file name="config.xml" hash="fd936ed3360902482e81d86b6747543c"/><file name="system.xml" hash="944a9a1ca7984eae63f1e2e0800404f9"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><dir name="qubit"><file name="universal_variable.xml" hash="f568ad884f941850720324d35868c45c"/><file name=".DS_Store" hash="2632898af4a7dd21eb81072ff8eb1f04"/></dir></dir><dir name="template"><dir name="qubit"><file name="universal_variable.phtml" hash="f0d43cc0642c05a7a647042e244fe7e8"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="QuBit_all.xml" hash="549545c1cf35f87658a129ad5093d13f"/></dir></target></contents>
20
  <compatible/>
21
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
22
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>QuBit_UniversalVariable</name>
4
+ <version>1.0.8</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/osl-3.0.php">Extension license name (OSL v3.0)</license>
7
  <channel>community</channel>
12
  <description>QuBit OpenTag recommends creating the releavant JavaScript object on your page prior to the OpenTag container script. This will assure the values are present on the page when a script tries to access them.&#xD;
13
  &#xD;
14
  If a page does not have the variables of an object that are mentioned below, simply do not even declare them. For example, if your pages only have category and no subcategory, just declare your category. Likewise, if you feel the need to extend the objects below or feel like renaming them, please do so. However, please take a note of the new variable names or the edited ones, because in order to access them from your scripts in your OpenTag container, you will need to use the new variable names.</description>
15
+ <notes>Rename page categroy from controller/view naming to correct page category inclueding home, checkout, basket, confirmation, product, category pages; Added listing variable for category pages</notes>
16
  <authors><author><name>Jing Dong</name><user>qubitproducts</user><email>jing@qubitdigital.com</email></author></authors>
17
+ <date>2013-01-21</date>
18
+ <time>11:55:03</time>
19
+ <contents><target name="magelocal"><dir name="QuBit"><dir name="UniversalVariable"><dir name="Block"><file name="Uv.php" hash="9b5cd71bebc9576b5d0714b3fe5c13bb"/></dir><dir name="Helper"><file name="Data.php" hash="b05ea847c16520d5e6eec91e9f604886"/></dir><dir name="Model"><dir name="Page"><file name="Observer.php" hash="2bf5aea3119698a5b7382d894b3e3a6a"/></dir><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><dir name="etc"><file name="config.xml" hash="fd936ed3360902482e81d86b6747543c"/><file name="system.xml" hash="944a9a1ca7984eae63f1e2e0800404f9"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><dir name="qubit"><file name="universal_variable.xml" hash="f568ad884f941850720324d35868c45c"/><file name=".DS_Store" hash="2632898af4a7dd21eb81072ff8eb1f04"/></dir></dir><dir name="template"><dir name="qubit"><file name="universal_variable.phtml" hash="a335515fd0cf17010f281246ae884821"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="QuBit_all.xml" hash="549545c1cf35f87658a129ad5093d13f"/></dir></target></contents>
20
  <compatible/>
21
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
22
  </package>