Version Notes
* Added basket on every page except confirmation page
* Added breadcrumb variables under universal_variable.page.breadcrumb whenenver this information is available
* DEPRECATION: We started deprecating page.category, moving to page.type. We current keep both to give times for frontend JavaScript migration. We recommand to use page.type to describe type of page from an ecommerce funnel perspective. Reference: http://tools.qubitproducts.com/uv/developers/specification/#toc_7
* DEPRECATION: page.category and page.subcategory will soon be deprecated in the next release
Download this release
Release Info
Developer | Jing Dong |
Extension | QuBit_UniversalVariable |
Version | 1.0.18 |
Comparing to | |
See all releases |
Code changes from version 1.0.17 to 1.0.18
app/code/community/QuBit/UniversalVariable/Model/Page/Observer.php
CHANGED
@@ -2,7 +2,9 @@
|
|
2 |
|
3 |
class QuBit_UniversalVariable_Model_Page_Observer {
|
4 |
|
5 |
-
|
|
|
|
|
6 |
protected $_user = null;
|
7 |
protected $_page = null;
|
8 |
protected $_basket = null;
|
@@ -10,6 +12,7 @@ class QuBit_UniversalVariable_Model_Page_Observer {
|
|
10 |
protected $_search = null;
|
11 |
protected $_transaction = null;
|
12 |
protected $_listing = null;
|
|
|
13 |
|
14 |
protected function _getRequest() {
|
15 |
return Mage::app()->getFrontController()->getRequest();
|
@@ -38,6 +41,10 @@ class QuBit_UniversalVariable_Model_Page_Observer {
|
|
38 |
return Mage::helper('customer')->getCustomer();
|
39 |
}
|
40 |
|
|
|
|
|
|
|
|
|
41 |
protected function _getCategory($category_id) {
|
42 |
return Mage::getModel('catalog/category')->load($category_id);
|
43 |
}
|
@@ -58,10 +65,6 @@ class QuBit_UniversalVariable_Model_Page_Observer {
|
|
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 |
}
|
@@ -197,12 +200,16 @@ class QuBit_UniversalVariable_Model_Page_Observer {
|
|
197 |
return Mage::getVersion();
|
198 |
}
|
199 |
|
|
|
|
|
|
|
|
|
200 |
|
201 |
/*
|
202 |
* Set the model attributes to be passed front end
|
203 |
*/
|
204 |
|
205 |
-
public function
|
206 |
if ($this->_isHome()) {
|
207 |
return 'home';
|
208 |
} elseif ($this->_isContent()) {
|
@@ -224,9 +231,23 @@ class QuBit_UniversalVariable_Model_Page_Observer {
|
|
224 |
}
|
225 |
}
|
226 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
227 |
public function _setPage() {
|
228 |
$this->_page = array();
|
229 |
-
$this->_page['
|
|
|
|
|
|
|
|
|
|
|
230 |
}
|
231 |
|
232 |
// Set the user info
|
@@ -250,7 +271,7 @@ class QuBit_UniversalVariable_Model_Page_Observer {
|
|
250 |
}
|
251 |
|
252 |
if ($user_id) {
|
253 |
-
$this->_user['user_id'] = $user_id;
|
254 |
}
|
255 |
$this->_user['returning'] = $user_id ? true : false;
|
256 |
$this->_user['language'] = Mage::getStoreConfig('general/locale/code', Mage::app()->getStore()->getId());;
|
@@ -287,9 +308,17 @@ class QuBit_UniversalVariable_Model_Page_Observer {
|
|
287 |
$product_model['unit_price'] = (float) $product->getPrice();
|
288 |
$product_model['unit_sale_price'] = (float) $product->getFinalPrice();
|
289 |
$product_model['currency'] = $this->_getCurrency();
|
290 |
-
$product_model['description'] = $product->getShortDescription();
|
291 |
-
$product_model['stock'] = $this->_getProuctStock($product);
|
292 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
293 |
return $product_model;
|
294 |
}
|
295 |
|
@@ -301,17 +330,12 @@ class QuBit_UniversalVariable_Model_Page_Observer {
|
|
301 |
$_cat = $this->_getCategory($category_id);
|
302 |
$category_names[] = $_cat->getName();
|
303 |
}
|
304 |
-
|
305 |
-
return implode(', ', $category_names);
|
306 |
-
} else {
|
307 |
-
return false;
|
308 |
-
}
|
309 |
} else {
|
310 |
return false;
|
311 |
}
|
312 |
}
|
313 |
|
314 |
-
|
315 |
public function _getLineItems($items, $page_type) {
|
316 |
$line_items = array();
|
317 |
foreach($items as $item) {
|
@@ -357,11 +381,10 @@ class QuBit_UniversalVariable_Model_Page_Observer {
|
|
357 |
}
|
358 |
|
359 |
public function _setBasket() {
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
$cart = $this->_getCheckoutSession();
|
365 |
}
|
366 |
|
367 |
$basket = array();
|
@@ -370,12 +393,12 @@ class QuBit_UniversalVariable_Model_Page_Observer {
|
|
370 |
// Set normal params
|
371 |
$basket_id = $this->_getCheckoutSession()->getQuoteId();
|
372 |
if ($basket_id) {
|
373 |
-
$basket['id'] = $basket_id;
|
374 |
}
|
375 |
$basket['currency'] = $this->_getCurrency();
|
376 |
$basket['subtotal'] = (float) $quote->getSubtotal();
|
377 |
-
$basket['tax'] = $quote->getShippingAddress()->getTaxAmount();
|
378 |
-
$basket['subtotal_include_tax'] = $this->_doesSubtotalIncludeTax($quote, $basket['tax']);
|
379 |
$basket['shipping_cost'] = (float) $quote->getShippingAmount();
|
380 |
$basket['shipping_method'] = $quote->getShippingMethod();
|
381 |
$basket['total'] = (float) $quote->getGrandTotal();
|
@@ -457,7 +480,7 @@ class QuBit_UniversalVariable_Model_Page_Observer {
|
|
457 |
$this->_setListing();
|
458 |
}
|
459 |
|
460 |
-
if (
|
461 |
$this->_setBasket();
|
462 |
}
|
463 |
|
2 |
|
3 |
class QuBit_UniversalVariable_Model_Page_Observer {
|
4 |
|
5 |
+
// This is the UV specification Version
|
6 |
+
// http://tools.qubitproducts.com/uv/developers/specification
|
7 |
+
protected $_version = "1.2";
|
8 |
protected $_user = null;
|
9 |
protected $_page = null;
|
10 |
protected $_basket = null;
|
12 |
protected $_search = null;
|
13 |
protected $_transaction = null;
|
14 |
protected $_listing = null;
|
15 |
+
protected $_events = array();
|
16 |
|
17 |
protected function _getRequest() {
|
18 |
return Mage::app()->getFrontController()->getRequest();
|
41 |
return Mage::helper('customer')->getCustomer();
|
42 |
}
|
43 |
|
44 |
+
protected function _getBreadcrumb() {
|
45 |
+
return Mage::helper('catalog')->getBreadcrumbPath();
|
46 |
+
}
|
47 |
+
|
48 |
protected function _getCategory($category_id) {
|
49 |
return Mage::getModel('catalog/category')->load($category_id);
|
50 |
}
|
65 |
return Mage::getSingleton('catalogsearch/advanced');
|
66 |
}
|
67 |
|
|
|
|
|
|
|
|
|
68 |
protected function _getCheckoutSession() {
|
69 |
return Mage::getSingleton('checkout/session');
|
70 |
}
|
200 |
return Mage::getVersion();
|
201 |
}
|
202 |
|
203 |
+
public function getEvents() {
|
204 |
+
return array();
|
205 |
+
}
|
206 |
+
|
207 |
|
208 |
/*
|
209 |
* Set the model attributes to be passed front end
|
210 |
*/
|
211 |
|
212 |
+
public function _getPageType() {
|
213 |
if ($this->_isHome()) {
|
214 |
return 'home';
|
215 |
} elseif ($this->_isContent()) {
|
231 |
}
|
232 |
}
|
233 |
|
234 |
+
public function _getPageBreadcrumb() {
|
235 |
+
$arr = $this->_getBreadcrumb();
|
236 |
+
$breadcrumb = array();
|
237 |
+
foreach ($arr as $category) {
|
238 |
+
$breadcrumb[] = $category['label'];
|
239 |
+
}
|
240 |
+
return $breadcrumb;
|
241 |
+
}
|
242 |
+
|
243 |
public function _setPage() {
|
244 |
$this->_page = array();
|
245 |
+
$this->_page['type'] = $this->_getPageType();
|
246 |
+
// WARNING: `page.category` will be deprecated in the next release
|
247 |
+
// We will follow the specification that uses `page.type`
|
248 |
+
// Please migrate any frontend JavaScripts using this `universal_variable.page.category` variable
|
249 |
+
$this->_page['category'] = $this->_page['type'];
|
250 |
+
$this->_page['breadcrumb'] = $this->_getPageBreadcrumb();
|
251 |
}
|
252 |
|
253 |
// Set the user info
|
271 |
}
|
272 |
|
273 |
if ($user_id) {
|
274 |
+
$this->_user['user_id'] = (string) $user_id;
|
275 |
}
|
276 |
$this->_user['returning'] = $user_id ? true : false;
|
277 |
$this->_user['language'] = Mage::getStoreConfig('general/locale/code', Mage::app()->getStore()->getId());;
|
308 |
$product_model['unit_price'] = (float) $product->getPrice();
|
309 |
$product_model['unit_sale_price'] = (float) $product->getFinalPrice();
|
310 |
$product_model['currency'] = $this->_getCurrency();
|
311 |
+
$product_model['description'] = strip_tags($product->getShortDescription());
|
312 |
+
$product_model['stock'] = (int) $this->_getProuctStock($product);
|
313 |
+
|
314 |
+
$categories = $this->_getProductCategories($product);
|
315 |
+
if (isset($categories[0])) {
|
316 |
+
$product_model['category'] = $categories[0];
|
317 |
+
}
|
318 |
+
if (isset($categories[1])) {
|
319 |
+
$product_model['subcategory'] = $categories[1];
|
320 |
+
}
|
321 |
+
|
322 |
return $product_model;
|
323 |
}
|
324 |
|
330 |
$_cat = $this->_getCategory($category_id);
|
331 |
$category_names[] = $_cat->getName();
|
332 |
}
|
333 |
+
return $category_names;
|
|
|
|
|
|
|
|
|
334 |
} else {
|
335 |
return false;
|
336 |
}
|
337 |
}
|
338 |
|
|
|
339 |
public function _getLineItems($items, $page_type) {
|
340 |
$line_items = array();
|
341 |
foreach($items as $item) {
|
381 |
}
|
382 |
|
383 |
public function _setBasket() {
|
384 |
+
$cart = $this->_getCheckoutSession();
|
385 |
+
|
386 |
+
if (!isset($cart)) {
|
387 |
+
return;
|
|
|
388 |
}
|
389 |
|
390 |
$basket = array();
|
393 |
// Set normal params
|
394 |
$basket_id = $this->_getCheckoutSession()->getQuoteId();
|
395 |
if ($basket_id) {
|
396 |
+
$basket['id'] = (string) $basket_id;
|
397 |
}
|
398 |
$basket['currency'] = $this->_getCurrency();
|
399 |
$basket['subtotal'] = (float) $quote->getSubtotal();
|
400 |
+
$basket['tax'] = (float) $quote->getShippingAddress()->getTaxAmount();
|
401 |
+
$basket['subtotal_include_tax'] = (boolean) $this->_doesSubtotalIncludeTax($quote, $basket['tax']);
|
402 |
$basket['shipping_cost'] = (float) $quote->getShippingAmount();
|
403 |
$basket['shipping_method'] = $quote->getShippingMethod();
|
404 |
$basket['total'] = (float) $quote->getGrandTotal();
|
480 |
$this->_setListing();
|
481 |
}
|
482 |
|
483 |
+
if (!$this->_isConfirmation()) {
|
484 |
$this->_setBasket();
|
485 |
}
|
486 |
|
app/design/frontend/base/default/template/qubit/universal_variable.phtml
CHANGED
@@ -8,9 +8,9 @@
|
|
8 |
$mage = Mage::getSingleton($observer);
|
9 |
|
10 |
if ($qubit_opentag_async == 1) {
|
11 |
-
|
12 |
} else {
|
13 |
-
|
14 |
};
|
15 |
?>
|
16 |
|
@@ -25,6 +25,7 @@
|
|
25 |
$listing = $mage->getListing();
|
26 |
$transaction = $mage->getTransaction();
|
27 |
$magento_version = $mage->getMageVersion();
|
|
|
28 |
?>
|
29 |
<!-- Universal Variable Start -->
|
30 |
<script type="text/javascript">
|
@@ -45,6 +46,7 @@
|
|
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;?>
|
8 |
$mage = Mage::getSingleton($observer);
|
9 |
|
10 |
if ($qubit_opentag_async == 1) {
|
11 |
+
$qubit_opentag_async = 'async defer';
|
12 |
} else {
|
13 |
+
$qubit_opentag_async = '';
|
14 |
};
|
15 |
?>
|
16 |
|
25 |
$listing = $mage->getListing();
|
26 |
$transaction = $mage->getTransaction();
|
27 |
$magento_version = $mage->getMageVersion();
|
28 |
+
$events = $mage->getEvents();
|
29 |
?>
|
30 |
<!-- Universal Variable Start -->
|
31 |
<script type="text/javascript">
|
46 |
<?php if ($transaction): ?>
|
47 |
window.universal_variable.transaction = <?php echo json_encode($transaction) ?>;
|
48 |
<?php endif; ?>
|
49 |
+
window.universal_variable.events = <?php echo json_encode($events); ?>;
|
50 |
</script>
|
51 |
<!-- Universal Variable End -->
|
52 |
<?php endif;?>
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>QuBit_UniversalVariable</name>
|
4 |
-
<version>1.0.
|
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,14 @@
|
|
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.
|
13 |

|
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
|
|
|
|
|
|
|
16 |
<authors><author><name>Jing Dong</name><user>qubitproducts</user><email>jing@qubitdigital.com</email></author></authors>
|
17 |
-
<date>2013-
|
18 |
-
<time>
|
19 |
-
<contents><target name="magecommunity"><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="
|
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.18</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.
|
13 |

|
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 basket on every page except confirmation page
|
16 |
+
* Added breadcrumb variables under universal_variable.page.breadcrumb whenenver this information is available
|
17 |
+
* DEPRECATION: We started deprecating page.category, moving to page.type. We current keep both to give times for frontend JavaScript migration. We recommand to use page.type to describe type of page from an ecommerce funnel perspective. Reference: http://tools.qubitproducts.com/uv/developers/specification/#toc_7
|
18 |
+
* DEPRECATION: page.category and page.subcategory will soon be deprecated in the next release</notes>
|
19 |
<authors><author><name>Jing Dong</name><user>qubitproducts</user><email>jing@qubitdigital.com</email></author></authors>
|
20 |
+
<date>2013-12-04</date>
|
21 |
+
<time>11:38:32</time>
|
22 |
+
<contents><target name="magecommunity"><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="67cd976d12d3d8195043ff6e619e9328"/></dir></dir><dir name="etc"><file name="config.xml" hash="fd936ed3360902482e81d86b6747543c"/><file name="system.xml" hash="944a9a1ca7984eae63f1e2e0800404f9"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="qubit"><file name="universal_variable.xml" hash="f568ad884f941850720324d35868c45c"/></dir></dir><dir name="template"><dir name="qubit"><file name="universal_variable.phtml" hash="bdc45ae2c08e7bd18c1433a25f6003df"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="QuBit_all.xml" hash="2fb177af411fe4b32940867a9448a38b"/></dir></target></contents>
|
23 |
<compatible/>
|
24 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
25 |
</package>
|