Version Notes
All basic features included.
- It can handle full page caching.
- Exception handling has been added.
- Removed empty objects and arrays; Removed duplicated subcategories.
- Added product data for products on category and search pages.
- Fixed issue where configurable products have multiple product entries, and incorrect prices, in the cart object.
- Added more data into digitalData object so websites can be debugged.
- Configurable products have each of their configurations listed under 'linkedProduct'.
- Fixed bug that was breaking some styling.
- Added 'pageName' attribute and fixed type of 'returningStatus' object.
- Tweaks to configuration panel and default values.
- List of all installed non-Magento extensions are exposed (for debug purposes)
- Products associated with a Grouped Product have been included.
- Minimum prices of grouped and bundled products can be extracted.
- Output of debug data can now be controlled through admin configuration panel.
Release Info
| Developer | Muhammed Miah |
| Extension | W3CDigitalDataLayerByTriggeredMessaging |
| Version | 0.3.13 |
| Comparing to | |
| See all releases | |
Code changes from version 0.3.10 to 0.3.13
- app/code/community/TriggeredMessaging/DigitalDataLayer/Block/Ddl.php +2 -1
- app/code/community/TriggeredMessaging/DigitalDataLayer/Helper/Data.php +2 -1
- app/code/community/TriggeredMessaging/DigitalDataLayer/Model/Container/Ddl.php +1 -0
- app/code/community/TriggeredMessaging/DigitalDataLayer/Model/Observer.php +4 -2
- app/code/community/TriggeredMessaging/DigitalDataLayer/Model/Page/Observer.php +50 -33
- app/code/community/TriggeredMessaging/DigitalDataLayer/Model/System/Config/Source/Stockexposure.php +18 -0
- app/code/community/TriggeredMessaging/DigitalDataLayer/etc/config.xml +3 -1
- app/code/community/TriggeredMessaging/DigitalDataLayer/etc/system.xml +27 -0
- app/design/frontend/base/default/layout/triggeredmessaging/digital_data_layer.xml +8 -6
- app/design/frontend/base/default/template/triggeredmessaging/digital_data_layer.phtml +88 -84
- app/design/frontend/base/default/template/triggeredmessaging/digital_data_layer_after_content.phtml +83 -55
- package.xml +4 -4
|
@@ -1,6 +1,7 @@
|
|
| 1 |
<?php
|
| 2 |
|
| 3 |
-
class TriggeredMessaging_DigitalDataLayer_Block_Ddl extends Mage_Core_Block_Template
|
|
|
|
| 4 |
|
| 5 |
}
|
| 6 |
|
| 1 |
<?php
|
| 2 |
|
| 3 |
+
class TriggeredMessaging_DigitalDataLayer_Block_Ddl extends Mage_Core_Block_Template
|
| 4 |
+
{
|
| 5 |
|
| 6 |
}
|
| 7 |
|
|
@@ -1,6 +1,7 @@
|
|
| 1 |
<?php
|
| 2 |
|
| 3 |
-
class TriggeredMessaging_DigitalDataLayer_Helper_Data extends Mage_Core_Helper_Abstract
|
|
|
|
| 4 |
|
| 5 |
}
|
| 6 |
|
| 1 |
<?php
|
| 2 |
|
| 3 |
+
class TriggeredMessaging_DigitalDataLayer_Helper_Data extends Mage_Core_Helper_Abstract
|
| 4 |
+
{
|
| 5 |
|
| 6 |
}
|
| 7 |
|
|
@@ -1,4 +1,5 @@
|
|
| 1 |
<?php
|
|
|
|
| 2 |
class TriggeredMessaging_DigitalDataLayer_Model_Container_Ddl extends Enterprise_PageCache_Model_Container_Advanced_Quote
|
| 3 |
{
|
| 4 |
/**
|
| 1 |
<?php
|
| 2 |
+
|
| 3 |
class TriggeredMessaging_DigitalDataLayer_Model_Container_Ddl extends Enterprise_PageCache_Model_Container_Advanced_Quote
|
| 4 |
{
|
| 5 |
/**
|
|
@@ -1,4 +1,5 @@
|
|
| 1 |
<?php
|
|
|
|
| 2 |
class TriggeredMessaging_DigitalDataLayer_Model_Observer
|
| 3 |
{
|
| 4 |
/**
|
|
@@ -7,7 +8,7 @@ class TriggeredMessaging_DigitalDataLayer_Model_Observer
|
|
| 7 |
* @var bool
|
| 8 |
*/
|
| 9 |
protected $_isEnabled;
|
| 10 |
-
|
| 11 |
/**
|
| 12 |
* Class constructor
|
| 13 |
*/
|
|
@@ -18,7 +19,7 @@ class TriggeredMessaging_DigitalDataLayer_Model_Observer
|
|
| 18 |
} catch (Exception $e) {
|
| 19 |
}
|
| 20 |
}
|
| 21 |
-
|
| 22 |
/**
|
| 23 |
* Check if full page cache is enabled
|
| 24 |
*
|
|
@@ -28,6 +29,7 @@ class TriggeredMessaging_DigitalDataLayer_Model_Observer
|
|
| 28 |
{
|
| 29 |
return $this->_isEnabled;
|
| 30 |
}
|
|
|
|
| 31 |
/**
|
| 32 |
* Set cart hash in cookie on quote change
|
| 33 |
*
|
| 1 |
<?php
|
| 2 |
+
|
| 3 |
class TriggeredMessaging_DigitalDataLayer_Model_Observer
|
| 4 |
{
|
| 5 |
/**
|
| 8 |
* @var bool
|
| 9 |
*/
|
| 10 |
protected $_isEnabled;
|
| 11 |
+
|
| 12 |
/**
|
| 13 |
* Class constructor
|
| 14 |
*/
|
| 19 |
} catch (Exception $e) {
|
| 20 |
}
|
| 21 |
}
|
| 22 |
+
|
| 23 |
/**
|
| 24 |
* Check if full page cache is enabled
|
| 25 |
*
|
| 29 |
{
|
| 30 |
return $this->_isEnabled;
|
| 31 |
}
|
| 32 |
+
|
| 33 |
/**
|
| 34 |
* Set cart hash in cookie on quote change
|
| 35 |
*
|
|
@@ -194,7 +194,16 @@ class TriggeredMessaging_DigitalDataLayer_Model_Page_Observer
|
|
| 194 |
return floatval(number_format(Mage::helper('core')->currency((float)$_price, $p1, $p2), 2, '.', ''));
|
| 195 |
}
|
| 196 |
}
|
| 197 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 198 |
public function getVersion()
|
| 199 |
{
|
| 200 |
return $this->_version;
|
|
@@ -529,6 +538,16 @@ class TriggeredMessaging_DigitalDataLayer_Model_Page_Observer
|
|
| 529 |
$product_model['productInfo']['productName'] = $product->getName();
|
| 530 |
$product_model['productInfo']['description'] = strip_tags($product->getShortDescription());
|
| 531 |
$product_model['productInfo']['productURL'] = $product->getProductUrl();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 532 |
|
| 533 |
//Check if images contain placeholders
|
| 534 |
if ($product->getImage() && $product->getImage() !== "no_selection") {
|
|
@@ -544,7 +563,6 @@ class TriggeredMessaging_DigitalDataLayer_Model_Page_Observer
|
|
| 544 |
try {
|
| 545 |
$attributes = Mage::getSingleton('eav/config')->getEntityType(Mage_Catalog_Model_Product::ENTITY)->getAttributeCollection();
|
| 546 |
foreach ($attributes as $attr) {
|
| 547 |
-
$infoLocation = 'none';
|
| 548 |
$attrCode = $attr->getAttributecode();
|
| 549 |
if ($attrCode === 'color' || $attrCode === 'manufacturer' || $attrCode === 'size') {
|
| 550 |
if ($product->getAttributeText($attrCode) && in_array($attrCode, $this->_expAttr)) {
|
|
@@ -600,14 +618,16 @@ class TriggeredMessaging_DigitalDataLayer_Model_Page_Observer
|
|
| 600 |
|
| 601 |
// Price
|
| 602 |
$product_model['price'] = array();
|
| 603 |
-
if (!$product->getSpecialPrice() || $product->getSpecialPrice() !== $product->getFinalPrice()) {
|
| 604 |
-
$product_model['price']['basePrice'] = $this->
|
|
|
|
| 605 |
} else {
|
| 606 |
-
$product_model['price']['basePrice'] = $this->
|
| 607 |
-
|
|
|
|
|
|
|
| 608 |
}
|
| 609 |
$product_model['price']['currency'] = $this->_getCurrency();
|
| 610 |
-
$product_model['price']['priceWithTax'] = $this->getCurrentPrice(floatval($product->getFinalPrice()), false, false);
|
| 611 |
|
| 612 |
if (!$product_model['price']['priceWithTax']) {
|
| 613 |
unset($product_model['price']['priceWithTax']);
|
|
@@ -615,13 +635,13 @@ class TriggeredMessaging_DigitalDataLayer_Model_Page_Observer
|
|
| 615 |
|
| 616 |
// In case 'basePrice' did not exist
|
| 617 |
if (!$product_model['price']['basePrice']) {
|
| 618 |
-
$product_model['price']['basePrice'] = $this->
|
| 619 |
}
|
| 620 |
if (!$product_model['price']['basePrice']) {
|
| 621 |
-
$product_model['price']['basePrice'] = $this->
|
| 622 |
}
|
| 623 |
if (!$product_model['price']['basePrice']) {
|
| 624 |
-
$product_model['price']['basePrice'] = $this->
|
| 625 |
}
|
| 626 |
if (!$product_model['price']['basePrice']) {
|
| 627 |
// Extract price for bundle products
|
|
@@ -635,7 +655,7 @@ class TriggeredMessaging_DigitalDataLayer_Model_Page_Observer
|
|
| 635 |
}
|
| 636 |
$_selection = $_option->getDefaultSelection();
|
| 637 |
if ($_selection === null) continue;
|
| 638 |
-
$normal_price += $this->
|
| 639 |
}
|
| 640 |
$product_model['price']['basePrice'] = $normal_price;
|
| 641 |
}
|
|
@@ -643,17 +663,17 @@ class TriggeredMessaging_DigitalDataLayer_Model_Page_Observer
|
|
| 643 |
|
| 644 |
if ($this->_debug) {
|
| 645 |
$product_model['price']['all'] = array();
|
| 646 |
-
$product_model['price']['all']['getPrice'] = $this->
|
| 647 |
-
$product_model['price']['all']['getMinimalPrice'] = $this->
|
| 648 |
$product_model['price']['all']['getPriceModel'] = $product->getPriceModel();
|
| 649 |
-
$product_model['price']['all']['getGroupPrice'] = $this->
|
| 650 |
$product_model['price']['all']['getTierPrice'] = $product->getTierPrice();
|
| 651 |
$product_model['price']['all']['getTierPriceCount'] = $product->getTierPriceCount();
|
| 652 |
$product_model['price']['all']['getFormatedTierPrice'] = $product->getFormatedTierPrice();
|
| 653 |
$product_model['price']['all']['getFormatedPrice'] = $product->getFormatedPrice();
|
| 654 |
-
$product_model['price']['all']['getFinalPrice'] = $this->
|
| 655 |
$product_model['price']['all']['getCalculatedFinalPrice'] = $product->getCalculatedFinalPrice();
|
| 656 |
-
$product_model['price']['all']['getSpecialPrice'] = $this->
|
| 657 |
}
|
| 658 |
|
| 659 |
// Calculate Tax Rate
|
|
@@ -726,13 +746,6 @@ class TriggeredMessaging_DigitalDataLayer_Model_Page_Observer
|
|
| 726 |
$product_model['more']['getThumbnail'] = $product->getThumbnail();
|
| 727 |
$product_model['more']['getThumbnailURL'] = $product->getThumbnailUrl();
|
| 728 |
}
|
| 729 |
-
|
| 730 |
-
// Other
|
| 731 |
-
// $product_model['attributes'] = array();
|
| 732 |
-
|
| 733 |
-
// The following are not used in W3C DDL but exist in Universal Variable:
|
| 734 |
-
// $product_model['sku_code'] = $product->getSku();
|
| 735 |
-
// $product_model['stock'] = (int) $this->_getProductStock($product);
|
| 736 |
} catch (Exception $e) {
|
| 737 |
}
|
| 738 |
|
|
@@ -799,14 +812,13 @@ class TriggeredMessaging_DigitalDataLayer_Model_Page_Observer
|
|
| 799 |
$product = $this->_getProduct($productId);
|
| 800 |
|
| 801 |
$parentIds = Mage::getModel('catalog/product_type_grouped')->getParentIdsByChild($productId);
|
| 802 |
-
if (
|
| 803 |
$litem_model = $this->_getProductModel($product, 'linked');
|
| 804 |
$litem_model['linkedProduct'] = array();
|
| 805 |
array_push($litem_model['linkedProduct'], $this->_getProductModel($this->_getProduct($parentIds[0]), 'linked'));
|
| 806 |
} else {
|
| 807 |
$litem_model = $this->_getProductModel($item, 'cart');
|
| 808 |
}
|
| 809 |
-
|
| 810 |
if ($page_type === 'cart') {
|
| 811 |
$litem_model['quantity'] = floatval($item->getQty());
|
| 812 |
} else {
|
|
@@ -824,8 +836,8 @@ class TriggeredMessaging_DigitalDataLayer_Model_Page_Observer
|
|
| 824 |
}
|
| 825 |
// $litem_model['price']['shipping'];
|
| 826 |
// $litem_model['price']['shippingMethod'] = $this->_extractShippingMethod($item->getQuote());
|
| 827 |
-
|
| 828 |
-
$litem_model['price']['cartTotal'] = floatval($item->getRowTotalInclTax());
|
| 829 |
|
| 830 |
if ($this->_debug) {
|
| 831 |
$litem_model['price']['all']['_getCalculationPrice'] = $this->getCurrentPrice($product->getCalculationPrice(), false, false);
|
|
@@ -936,6 +948,9 @@ class TriggeredMessaging_DigitalDataLayer_Model_Page_Observer
|
|
| 936 |
$cart['cartID'] = (string)$cart_id;
|
| 937 |
}
|
| 938 |
$cart['price'] = array();
|
|
|
|
|
|
|
|
|
|
| 939 |
if ($quote->getBaseSubtotal()) {
|
| 940 |
$cart['price']['basePrice'] = $this->getCurrentPrice(floatval($quote->getBaseSubtotal()), false, false);
|
| 941 |
} else {
|
|
@@ -949,7 +964,7 @@ class TriggeredMessaging_DigitalDataLayer_Model_Page_Observer
|
|
| 949 |
}
|
| 950 |
$cart['price']['currency'] = $this->_getCurrency();
|
| 951 |
if ($cart['price']['basePrice'] > 0.0) {
|
| 952 |
-
$taxRate = (float)$quote->getShippingAddress()->getTaxAmount() / $
|
| 953 |
$cart['price']['taxRate'] = round($taxRate, 3); // TODO: Find a better way
|
| 954 |
}
|
| 955 |
if ($quote->getShippingAmount()) {
|
|
@@ -958,13 +973,13 @@ class TriggeredMessaging_DigitalDataLayer_Model_Page_Observer
|
|
| 958 |
if ($this->_extractShippingMethod($quote)) {
|
| 959 |
$cart['price']['shippingMethod'] = $this->_extractShippingMethod($quote);
|
| 960 |
}
|
| 961 |
-
if ($quote->getShippingAddress()->getTaxAmount() && $quote->
|
| 962 |
-
$cart['price']['priceWithTax'] = (float)$quote->getShippingAddress()->getTaxAmount() + $this->getCurrentPrice($quote->
|
| 963 |
} else {
|
| 964 |
$cart['price']['priceWithTax'] = $cart['price']['basePrice'];
|
| 965 |
}
|
| 966 |
-
if ($quote->
|
| 967 |
-
$cart['price']['cartTotal'] = (float)$quote->
|
| 968 |
} else {
|
| 969 |
$cart['price']['cartTotal'] = $cart['price']['priceWithTax'];
|
| 970 |
}
|
|
@@ -1149,7 +1164,9 @@ class TriggeredMessaging_DigitalDataLayer_Model_Page_Observer
|
|
| 1149 |
$this->_debug = (boolean)Mage::getStoreConfig('triggered_messaging/triggered_messaging_digital_data_layer_debug_enabled');
|
| 1150 |
$this->_userGroupExp = (boolean)Mage::getStoreConfig('triggered_messaging/triggered_messaging_digital_data_layer_user_group_enabled');
|
| 1151 |
$this->_expAttr = explode(',', Mage::getStoreConfig('triggered_messaging/triggered_messaging_digital_data_layer_attributes_enabled'));
|
| 1152 |
-
|
|
|
|
|
|
|
| 1153 |
$this->_setUser();
|
| 1154 |
$this->_setPage();
|
| 1155 |
|
| 194 |
return floatval(number_format(Mage::helper('core')->currency((float)$_price, $p1, $p2), 2, '.', ''));
|
| 195 |
}
|
| 196 |
}
|
| 197 |
+
|
| 198 |
+
/*
|
| 199 |
+
* Get information on pages to pass to front end
|
| 200 |
+
*/
|
| 201 |
+
public function getProductPrice($_product, $_price, $IncTax)
|
| 202 |
+
{
|
| 203 |
+
$tax_helper = Mage::helper('tax');
|
| 204 |
+
return round(Mage::helper('core')->currency($tax_helper->getPrice($_product,$_price, $IncTax),false,false),2);
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
public function getVersion()
|
| 208 |
{
|
| 209 |
return $this->_version;
|
| 538 |
$product_model['productInfo']['productName'] = $product->getName();
|
| 539 |
$product_model['productInfo']['description'] = strip_tags($product->getShortDescription());
|
| 540 |
$product_model['productInfo']['productURL'] = $product->getProductUrl();
|
| 541 |
+
$stock = $this->_getProductStock($product);
|
| 542 |
+
if($this->_stockExp==2){
|
| 543 |
+
$product_model['productInfo']['stock'] = $stock;
|
| 544 |
+
} else if($this->_stockExp==1){
|
| 545 |
+
if($stock>0){
|
| 546 |
+
$product_model['productInfo']['stock'] = 'In Stock';
|
| 547 |
+
} else {
|
| 548 |
+
$product_model['productInfo']['stock'] = 'Out of Stock';
|
| 549 |
+
}
|
| 550 |
+
}
|
| 551 |
|
| 552 |
//Check if images contain placeholders
|
| 553 |
if ($product->getImage() && $product->getImage() !== "no_selection") {
|
| 563 |
try {
|
| 564 |
$attributes = Mage::getSingleton('eav/config')->getEntityType(Mage_Catalog_Model_Product::ENTITY)->getAttributeCollection();
|
| 565 |
foreach ($attributes as $attr) {
|
|
|
|
| 566 |
$attrCode = $attr->getAttributecode();
|
| 567 |
if ($attrCode === 'color' || $attrCode === 'manufacturer' || $attrCode === 'size') {
|
| 568 |
if ($product->getAttributeText($attrCode) && in_array($attrCode, $this->_expAttr)) {
|
| 618 |
|
| 619 |
// Price
|
| 620 |
$product_model['price'] = array();
|
| 621 |
+
if (!$this->getProductPrice($product,$product->getSpecialPrice(),false) || $this->getProductPrice($product,$product->getSpecialPrice(),false) !== $this->getProductPrice($product,$product->getFinalPrice(),false)) {
|
| 622 |
+
$product_model['price']['basePrice'] = $this->getProductPrice($product,$product->getPrice(),false);
|
| 623 |
+
$product_model['price']['priceWithTax'] = $this->getProductPrice($product,$product->getPrice(),true);
|
| 624 |
} else {
|
| 625 |
+
$product_model['price']['basePrice'] = $this->getProductPrice($product,$product->getSpecialPrice(),false);
|
| 626 |
+
$product_model['price']['priceWithTax'] = $this->getProductPrice($product,$product->getSpecialPrice(),true);
|
| 627 |
+
$product_model['price']['regularPrice'] = $this->getProductPrice($product,$product->getPrice(),false);
|
| 628 |
+
$product_model['price']['regularPriceWithTax'] = $this->getProductPrice($product,$product->getPrice(),true);
|
| 629 |
}
|
| 630 |
$product_model['price']['currency'] = $this->_getCurrency();
|
|
|
|
| 631 |
|
| 632 |
if (!$product_model['price']['priceWithTax']) {
|
| 633 |
unset($product_model['price']['priceWithTax']);
|
| 635 |
|
| 636 |
// In case 'basePrice' did not exist
|
| 637 |
if (!$product_model['price']['basePrice']) {
|
| 638 |
+
$product_model['price']['basePrice'] = $this->getProductPrice($product,$product->getGroupPrice(), false);
|
| 639 |
}
|
| 640 |
if (!$product_model['price']['basePrice']) {
|
| 641 |
+
$product_model['price']['basePrice'] = $this->getProductPrice($product,$product->getMinimalPrice(), false);
|
| 642 |
}
|
| 643 |
if (!$product_model['price']['basePrice']) {
|
| 644 |
+
$product_model['price']['basePrice'] = $this->getProductPrice($product,$product->getSpecialPrice(), false);
|
| 645 |
}
|
| 646 |
if (!$product_model['price']['basePrice']) {
|
| 647 |
// Extract price for bundle products
|
| 655 |
}
|
| 656 |
$_selection = $_option->getDefaultSelection();
|
| 657 |
if ($_selection === null) continue;
|
| 658 |
+
$normal_price += $this->getProductPrice($product,$_selection->getPrice(), false);
|
| 659 |
}
|
| 660 |
$product_model['price']['basePrice'] = $normal_price;
|
| 661 |
}
|
| 663 |
|
| 664 |
if ($this->_debug) {
|
| 665 |
$product_model['price']['all'] = array();
|
| 666 |
+
$product_model['price']['all']['getPrice'] = $this->getProductPrice($product,$product->getPrice(), false);
|
| 667 |
+
$product_model['price']['all']['getMinimalPrice'] = $this->getProductPrice($product,$product->getMinimalPrice(), false);
|
| 668 |
$product_model['price']['all']['getPriceModel'] = $product->getPriceModel();
|
| 669 |
+
$product_model['price']['all']['getGroupPrice'] = $this->getProductPrice($product,$product->getGroupPrice(), false);
|
| 670 |
$product_model['price']['all']['getTierPrice'] = $product->getTierPrice();
|
| 671 |
$product_model['price']['all']['getTierPriceCount'] = $product->getTierPriceCount();
|
| 672 |
$product_model['price']['all']['getFormatedTierPrice'] = $product->getFormatedTierPrice();
|
| 673 |
$product_model['price']['all']['getFormatedPrice'] = $product->getFormatedPrice();
|
| 674 |
+
$product_model['price']['all']['getFinalPrice'] = $this->getProductPrice($product,$product->getFinalPrice(), false);
|
| 675 |
$product_model['price']['all']['getCalculatedFinalPrice'] = $product->getCalculatedFinalPrice();
|
| 676 |
+
$product_model['price']['all']['getSpecialPrice'] = $this->getProductPrice($product,$product->getSpecialPrice(), false);
|
| 677 |
}
|
| 678 |
|
| 679 |
// Calculate Tax Rate
|
| 746 |
$product_model['more']['getThumbnail'] = $product->getThumbnail();
|
| 747 |
$product_model['more']['getThumbnailURL'] = $product->getThumbnailUrl();
|
| 748 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 749 |
} catch (Exception $e) {
|
| 750 |
}
|
| 751 |
|
| 812 |
$product = $this->_getProduct($productId);
|
| 813 |
|
| 814 |
$parentIds = Mage::getModel('catalog/product_type_grouped')->getParentIdsByChild($productId);
|
| 815 |
+
if (!empty($parentIds)) {
|
| 816 |
$litem_model = $this->_getProductModel($product, 'linked');
|
| 817 |
$litem_model['linkedProduct'] = array();
|
| 818 |
array_push($litem_model['linkedProduct'], $this->_getProductModel($this->_getProduct($parentIds[0]), 'linked'));
|
| 819 |
} else {
|
| 820 |
$litem_model = $this->_getProductModel($item, 'cart');
|
| 821 |
}
|
|
|
|
| 822 |
if ($page_type === 'cart') {
|
| 823 |
$litem_model['quantity'] = floatval($item->getQty());
|
| 824 |
} else {
|
| 836 |
}
|
| 837 |
// $litem_model['price']['shipping'];
|
| 838 |
// $litem_model['price']['shippingMethod'] = $this->_extractShippingMethod($item->getQuote());
|
| 839 |
+
//$litem_model['price']['priceWithTax'] = $this->getCurrentPrice(floatval($item->getBasePriceInclTax()), false, false); No longer needed with better tax calculation
|
| 840 |
+
$litem_model['price']['cartTotal'] = floatval($item->getRowTotalInclTax()); //cart Total still useful for products that might have add-ons etc.
|
| 841 |
|
| 842 |
if ($this->_debug) {
|
| 843 |
$litem_model['price']['all']['_getCalculationPrice'] = $this->getCurrentPrice($product->getCalculationPrice(), false, false);
|
| 948 |
$cart['cartID'] = (string)$cart_id;
|
| 949 |
}
|
| 950 |
$cart['price'] = array();
|
| 951 |
+
if ($quote->getSubtotal()) {
|
| 952 |
+
$cart['price']['basePrice'] = $quote->getSubtotal();
|
| 953 |
+
}
|
| 954 |
if ($quote->getBaseSubtotal()) {
|
| 955 |
$cart['price']['basePrice'] = $this->getCurrentPrice(floatval($quote->getBaseSubtotal()), false, false);
|
| 956 |
} else {
|
| 964 |
}
|
| 965 |
$cart['price']['currency'] = $this->_getCurrency();
|
| 966 |
if ($cart['price']['basePrice'] > 0.0) {
|
| 967 |
+
$taxRate = (float)$quote->getShippingAddress()->getTaxAmount() / $quote->getSubtotal();
|
| 968 |
$cart['price']['taxRate'] = round($taxRate, 3); // TODO: Find a better way
|
| 969 |
}
|
| 970 |
if ($quote->getShippingAmount()) {
|
| 973 |
if ($this->_extractShippingMethod($quote)) {
|
| 974 |
$cart['price']['shippingMethod'] = $this->_extractShippingMethod($quote);
|
| 975 |
}
|
| 976 |
+
if ($quote->getShippingAddress()->getTaxAmount() && $quote->getSubtotal()) {
|
| 977 |
+
$cart['price']['priceWithTax'] = (float)$quote->getShippingAddress()->getTaxAmount() + $this->getCurrentPrice($quote->getSubtotal(), false, false);
|
| 978 |
} else {
|
| 979 |
$cart['price']['priceWithTax'] = $cart['price']['basePrice'];
|
| 980 |
}
|
| 981 |
+
if ($quote->getGetData()['grand_total']) {
|
| 982 |
+
$cart['price']['cartTotal'] = (float)$quote->getGetData()['grand_total'];
|
| 983 |
} else {
|
| 984 |
$cart['price']['cartTotal'] = $cart['price']['priceWithTax'];
|
| 985 |
}
|
| 1164 |
$this->_debug = (boolean)Mage::getStoreConfig('triggered_messaging/triggered_messaging_digital_data_layer_debug_enabled');
|
| 1165 |
$this->_userGroupExp = (boolean)Mage::getStoreConfig('triggered_messaging/triggered_messaging_digital_data_layer_user_group_enabled');
|
| 1166 |
$this->_expAttr = explode(',', Mage::getStoreConfig('triggered_messaging/triggered_messaging_digital_data_layer_attributes_enabled'));
|
| 1167 |
+
$this->_stockExp = (int)Mage::getStoreConfig('triggered_messaging/triggered_messaging_digital_data_layer_stock_exposure');
|
| 1168 |
+
$this->_listLimit = Mage::getStoreConfig('triggered_messaging/triggered_messaging_digital_data_layer_prod_list_exposure');
|
| 1169 |
+
|
| 1170 |
$this->_setUser();
|
| 1171 |
$this->_setPage();
|
| 1172 |
|
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class TriggeredMessaging_DigitalDataLayer_Model_System_Config_Source_Stockexposure
|
| 4 |
+
{
|
| 5 |
+
/**
|
| 6 |
+
* Options getter
|
| 7 |
+
*
|
| 8 |
+
* @return array
|
| 9 |
+
*/
|
| 10 |
+
public function toOptionArray()
|
| 11 |
+
{
|
| 12 |
+
return array(array('label' => 'Don\'t expose stock', 'value' => '0'),
|
| 13 |
+
array('label' => 'Only Expose In or Out of stock', 'value' => '1'),
|
| 14 |
+
array('label' => 'Expose actual stock level', 'value' => '2'));
|
| 15 |
+
}
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
?>
|
|
@@ -2,7 +2,7 @@
|
|
| 2 |
<config>
|
| 3 |
<modules>
|
| 4 |
<TriggeredMessaging_DigitalDataLayer>
|
| 5 |
-
<version>0.3.
|
| 6 |
</TriggeredMessaging_DigitalDataLayer>
|
| 7 |
</modules>
|
| 8 |
|
|
@@ -61,6 +61,8 @@
|
|
| 61 |
<triggered_messaging_digital_data_layer_debug_enabled>0</triggered_messaging_digital_data_layer_debug_enabled>
|
| 62 |
<triggered_messaging_digital_data_layer_user_group_enabled>0</triggered_messaging_digital_data_layer_user_group_enabled>
|
| 63 |
<triggered_messaging_digital_data_layer_attributes_enabled></triggered_messaging_digital_data_layer_attributes_enabled>
|
|
|
|
|
|
|
| 64 |
<triggered_messaging_script_enabled>1</triggered_messaging_script_enabled>
|
| 65 |
<triggered_messaging_website_id></triggered_messaging_website_id>
|
| 66 |
</triggered_messaging>
|
| 2 |
<config>
|
| 3 |
<modules>
|
| 4 |
<TriggeredMessaging_DigitalDataLayer>
|
| 5 |
+
<version>0.3.13</version>
|
| 6 |
</TriggeredMessaging_DigitalDataLayer>
|
| 7 |
</modules>
|
| 8 |
|
| 61 |
<triggered_messaging_digital_data_layer_debug_enabled>0</triggered_messaging_digital_data_layer_debug_enabled>
|
| 62 |
<triggered_messaging_digital_data_layer_user_group_enabled>0</triggered_messaging_digital_data_layer_user_group_enabled>
|
| 63 |
<triggered_messaging_digital_data_layer_attributes_enabled></triggered_messaging_digital_data_layer_attributes_enabled>
|
| 64 |
+
<triggered_messaging_digital_data_layer_stock_exposure>0</triggered_messaging_digital_data_layer_stock_exposure>
|
| 65 |
+
<triggered_messaging_digital_data_layer_prod_list_exposure></triggered_messaging_digital_data_layer_prod_list_exposure>
|
| 66 |
<triggered_messaging_script_enabled>1</triggered_messaging_script_enabled>
|
| 67 |
<triggered_messaging_website_id></triggered_messaging_website_id>
|
| 68 |
</triggered_messaging>
|
|
@@ -78,6 +78,33 @@
|
|
| 78 |
<TriggeredMessaging_DigitalDataLayer_Enabled>1</TriggeredMessaging_DigitalDataLayer_Enabled>
|
| 79 |
</depends>
|
| 80 |
</TriggeredMessaging_DigitalDataLayer_Attributes_Enabled>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
</fields>
|
| 82 |
<expanded>1</expanded>
|
| 83 |
</TriggeredMessaging_DigitalDataLayer_Settings>
|
| 78 |
<TriggeredMessaging_DigitalDataLayer_Enabled>1</TriggeredMessaging_DigitalDataLayer_Enabled>
|
| 79 |
</depends>
|
| 80 |
</TriggeredMessaging_DigitalDataLayer_Attributes_Enabled>
|
| 81 |
+
<TriggeredMessaging_DigitalDataLayer_Stock_Enabled translate="label">
|
| 82 |
+
<label>Enable Stock Exposure</label>
|
| 83 |
+
<frontend_type>select</frontend_type>
|
| 84 |
+
<source_model>TriggeredMessaging_DigitalDataLayer_Model_System_Config_Source_Stockexposure</source_model>
|
| 85 |
+
<config_path>triggered_messaging/triggered_messaging_digital_data_layer_stock_exposure</config_path>
|
| 86 |
+
<comment><![CDATA[ Optionally expose stock level in the Dgitial Data Layer. ]]></comment>
|
| 87 |
+
<sort_order>5</sort_order>
|
| 88 |
+
<show_in_default>1</show_in_default>
|
| 89 |
+
<show_in_website>1</show_in_website>
|
| 90 |
+
<show_in_store>1</show_in_store>
|
| 91 |
+
<depends>
|
| 92 |
+
<TriggeredMessaging_DigitalDataLayer_Enabled>1</TriggeredMessaging_DigitalDataLayer_Enabled>
|
| 93 |
+
</depends>
|
| 94 |
+
</TriggeredMessaging_DigitalDataLayer_Stock_Enabled>
|
| 95 |
+
<TriggeredMessaging_DigitalDataLayer_Prod_List_Enabled translate="label">
|
| 96 |
+
<label>Limit Products Exposed On Product List</label>
|
| 97 |
+
<frontend_type>text</frontend_type>
|
| 98 |
+
<config_path>triggered_messaging/triggered_messaging_digital_data_layer_prod_list_exposure</config_path>
|
| 99 |
+
<comment><![CDATA[ Set an optional limit for products exposed on a product list page. Leave blank to expose all products on a product list, or set to 0 to disable Product exposure on list pages. ]]></comment>
|
| 100 |
+
<sort_order>6</sort_order>
|
| 101 |
+
<show_in_default>1</show_in_default>
|
| 102 |
+
<show_in_website>1</show_in_website>
|
| 103 |
+
<show_in_store>1</show_in_store>
|
| 104 |
+
<depends>
|
| 105 |
+
<TriggeredMessaging_DigitalDataLayer_Enabled>1</TriggeredMessaging_DigitalDataLayer_Enabled>
|
| 106 |
+
</depends>
|
| 107 |
+
</TriggeredMessaging_DigitalDataLayer_Prod_List_Enabled>
|
| 108 |
</fields>
|
| 109 |
<expanded>1</expanded>
|
| 110 |
</TriggeredMessaging_DigitalDataLayer_Settings>
|
|
@@ -1,13 +1,15 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<layout version="1.0.0">
|
| 3 |
<default>
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
|
|
|
| 7 |
</default>
|
| 8 |
<tms_block_after_content>
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
| 12 |
</tms_block_after_content>
|
| 13 |
</layout>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<layout version="1.0.0">
|
| 3 |
<default>
|
| 4 |
+
<reference name="head">
|
| 5 |
+
<block type="digital_data_layer_main/ddl" name="digital_data_layer" as="digital_data_layer"
|
| 6 |
+
template="triggeredmessaging/digital_data_layer.phtml"/>
|
| 7 |
+
</reference>
|
| 8 |
</default>
|
| 9 |
<tms_block_after_content>
|
| 10 |
+
<reference name="content">
|
| 11 |
+
<block type="digital_data_layer_main/ddl" name="digital_data_layer" as="digital_data_layer"
|
| 12 |
+
template="triggeredmessaging/digital_data_layer_after_content.phtml"/>
|
| 13 |
+
</reference>
|
| 14 |
</tms_block_after_content>
|
| 15 |
</layout>
|
|
@@ -1,88 +1,92 @@
|
|
| 1 |
<?php try { ?>
|
| 2 |
-
<?php
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
?>
|
| 11 |
-
<?php if ($triggered_messaging_digital_data_layer_enabled == 1)
|
| 12 |
-
<?php
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
?>
|
| 25 |
-
<?php
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
}
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
|
|
|
| 71 |
|
| 72 |
-
<?php if ($triggered_messaging_script_enabled)
|
| 73 |
-
<!-- Fresh Relevance Script Start -->
|
| 74 |
-
<?php if ($triggered_messaging_website_id)
|
| 75 |
-
<script defer="defer" async="async"
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
<?php endif
|
|
|
|
|
|
|
| 87 |
|
| 88 |
-
<?php } catch (Exception $e) {
|
|
|
| 1 |
<?php try { ?>
|
| 2 |
+
<?php
|
| 3 |
+
/* @var $this TriggeredMessaging_DigitalDataLayer_Block_Ddl */
|
| 4 |
+
$triggered_messaging_website_id = Mage::getStoreConfig('triggered_messaging/triggered_messaging_website_id');
|
| 5 |
+
$triggered_messaging_script_enabled = Mage::getStoreConfig('triggered_messaging/triggered_messaging_script_enabled');
|
| 6 |
+
$triggered_messaging_digital_data_layer_enabled = Mage::getStoreConfig('triggered_messaging/triggered_messaging_digital_data_layer_enabled');
|
| 7 |
|
| 8 |
+
$observer = 'digital_data_layer_main/page_observer';
|
| 9 |
+
$mage = Mage::getSingleton($observer);
|
| 10 |
+
?>
|
| 11 |
+
<?php if ($triggered_messaging_digital_data_layer_enabled == 1) : ?>
|
| 12 |
+
<?php
|
| 13 |
+
// extract variable only when digital data layer is enabled
|
| 14 |
+
$version = $mage->getVersion();
|
| 15 |
+
$page = $mage->getPage();
|
| 16 |
+
$user = $mage->getUser();
|
| 17 |
+
$product = $mage->getProduct();
|
| 18 |
+
$cart = $mage->getCart();
|
| 19 |
+
$listing = $mage->getListing();
|
| 20 |
+
$transaction = $mage->getTransaction();
|
| 21 |
+
$events = $mage->getEvents();
|
| 22 |
+
$pluginVersion = (string)Mage::getConfig()->getNode()->modules->TriggeredMessaging_DigitalDataLayer->version;
|
| 23 |
+
$timeStamp = time() * 1000;
|
| 24 |
+
?>
|
| 25 |
+
<?php
|
| 26 |
+
try {
|
| 27 |
+
// Extract things only available within template (and not model)
|
| 28 |
+
if (!$page['pageInfo']) {
|
| 29 |
+
$page['pageInfo'] = array();
|
| 30 |
+
}
|
| 31 |
+
if (!$page['pageInfo']['pageName'] || $page['pageInfo']['pageName'] === '') {
|
| 32 |
+
$page['pageInfo']['pageName'] = $this->getLayout()->getBlock('head')->getTitle();
|
| 33 |
+
} else {
|
| 34 |
+
unset($page['pageInfo']['pageName']);
|
| 35 |
+
}
|
| 36 |
+
} catch (Exception $e) {
|
| 37 |
+
}
|
| 38 |
+
?>
|
| 39 |
+
<!-- W3C Digital Data Layer Start -->
|
| 40 |
+
<script type="text/javascript">
|
| 41 |
+
try {
|
| 42 |
+
window.digitalData = window.digitalData || {};
|
| 43 |
+
window.digitalData.version = <?php echo json_encode($version); ?>;
|
| 44 |
+
window.digitalData.page = <?php echo json_encode($page); ?>;
|
| 45 |
+
window.digitalData.user = <?php echo json_encode($user); ?>;
|
| 46 |
+
<?php if ($product) : ?>
|
| 47 |
+
window.digitalData.product = <?php echo json_encode($product) ?>;
|
| 48 |
+
<?php endif; ?>
|
| 49 |
+
<?php if ($cart) : ?>
|
| 50 |
+
window.digitalData.cart = <?php echo json_encode($cart) ?>;
|
| 51 |
+
<?php endif; ?>
|
| 52 |
+
<?php if ($listing): ?>
|
| 53 |
+
window.digitalData.listing = <?php echo json_encode($listing) ?>;
|
| 54 |
+
<?php endif; ?>
|
| 55 |
+
<?php if ($transaction): ?>
|
| 56 |
+
window.digitalData.transaction = <?php echo json_encode($transaction) ?>;
|
| 57 |
+
<?php endif; ?>
|
| 58 |
+
<?php if ($events): ?>
|
| 59 |
+
window.digitalData.events = <?php echo json_encode($events); ?>;
|
| 60 |
+
<?php endif; ?>
|
| 61 |
+
<?php if ($pluginVersion): ?>
|
| 62 |
+
window.digitalData.pluginVersion = <?php echo json_encode($pluginVersion); ?>;
|
| 63 |
+
<?php endif; ?>
|
| 64 |
+
<?php if ($timeStamp): ?>
|
| 65 |
+
window.digitalData.generatedDate = <?php echo json_encode($timeStamp); ?>;
|
| 66 |
+
<?php endif; ?>
|
| 67 |
+
} catch (e) {
|
| 68 |
+
}
|
| 69 |
+
</script>
|
| 70 |
+
<!-- W3C Digital Data Layer End -->
|
| 71 |
+
<?php endif; ?>
|
| 72 |
|
| 73 |
+
<?php if ($triggered_messaging_script_enabled) : ?>
|
| 74 |
+
<!-- Fresh Relevance Script Start -->
|
| 75 |
+
<?php if ($triggered_messaging_website_id) : ?>
|
| 76 |
+
<script defer="defer" async="async"
|
| 77 |
+
src='//d81mfvml8p5ml.cloudfront.net/<?php echo $triggered_messaging_website_id; ?>.js'></script>
|
| 78 |
+
<?php if ($mage->_isConfirmation()) : ?>
|
| 79 |
+
<?php $pcqs = $mage->getPurchaseCompleteQs(); ?>
|
| 80 |
+
<img
|
| 81 |
+
src="//d1f0tbk1v3e25u.cloudfront.net/pc/<?php echo $triggered_messaging_website_id; ?>/?<?php echo $pcqs; ?>"/>
|
| 82 |
+
<?php endif; ?>
|
| 83 |
+
<?php else: ?>
|
| 84 |
+
<script type="text/javascript">
|
| 85 |
+
console.log("You have enabled the Fresh Relevance script from the Magento Admin Configuration Panel, but have not supplied a website ID. Please go to http://www.freshrelevance.com/contact for support on this.");
|
| 86 |
+
</script>
|
| 87 |
+
<?php endif; ?>
|
| 88 |
+
<!-- Fresh Relevance Script End -->
|
| 89 |
+
<?php endif; ?>
|
| 90 |
|
| 91 |
+
<?php } catch (Exception $e) {
|
| 92 |
+
} ?>
|
|
@@ -1,58 +1,86 @@
|
|
| 1 |
<?php try {
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
}
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
<?php if (!$preloaded_product) : ?>
|
| 46 |
-
window.digitalData.product = <?php echo json_encode($products) ?>;
|
| 47 |
-
<?php else : ?>
|
| 48 |
-
window.digitalData.product.push.apply(window.digitalData.product, <?php echo json_encode($products) ?>);
|
| 49 |
-
<?php endif; ?>
|
| 50 |
-
<?php endif; ?>
|
| 51 |
-
} catch(e) {
|
| 52 |
-
}
|
| 53 |
-
</script>
|
| 54 |
-
<!-- W3C Digital Data Layer Extra Info End -->
|
| 55 |
-
<?php
|
| 56 |
-
endif;
|
| 57 |
-
|
| 58 |
-
} catch (Exception $e) {} ?>
|
| 1 |
<?php try {
|
| 2 |
|
| 3 |
+
/* @var $this TriggeredMessaging_DigitalDataLayer_Block_Ddl */
|
| 4 |
+
$triggered_messaging_digital_data_layer_enabled = Mage::getStoreConfig('triggered_messaging/triggered_messaging_digital_data_layer_enabled');
|
| 5 |
+
$triggered_messaging_digital_data_layer_prod_list_limit = Mage::getStoreConfig('triggered_messaging/triggered_messaging_digital_data_layer_prod_list_exposure');
|
| 6 |
+
if($triggered_messaging_digital_data_layer_prod_list_limit===''){
|
| 7 |
+
//If blank we want to expose all products, so set to a number the counter won't ever get to
|
| 8 |
+
$triggered_messaging_digital_data_layer_prod_list_limit = -1;
|
| 9 |
+
} else {
|
| 10 |
+
//Else make sure it's an integer value so counter will hit the value
|
| 11 |
+
$triggered_messaging_digital_data_layer_prod_list_limit = (int)$triggered_messaging_digital_data_layer_prod_list_limit;
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
// extract variable only when digital data layer is enabled
|
| 15 |
+
if ($triggered_messaging_digital_data_layer_enabled == 1) :
|
| 16 |
+
|
| 17 |
+
$observer = 'digital_data_layer_main/page_observer';
|
| 18 |
+
$mage = Mage::getSingleton($observer);
|
| 19 |
+
|
| 20 |
+
$page = $mage->getPage();
|
| 21 |
+
if (isset($page['category']) &&
|
| 22 |
+
isset($page['category']['pageType'])
|
| 23 |
+
) {
|
| 24 |
+
switch ($page['category']['pageType']) {
|
| 25 |
+
case 'category':
|
| 26 |
+
case 'search':
|
| 27 |
+
case 'tag':
|
| 28 |
+
break;
|
| 29 |
+
default:
|
| 30 |
+
return;
|
| 31 |
+
}
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
// Grab product list data (from category and search pages)
|
| 35 |
+
$that = Mage::getBlockSingleton('catalog/product_list');
|
| 36 |
+
if (!$that) return;
|
| 37 |
+
// Check to see if we are on the advanced search page
|
| 38 |
+
if ($this->getRequest()->getControllerName()=='advanced') {
|
| 39 |
+
// If we are on the advanced search index page, don't build item collection
|
| 40 |
+
if(strrpos(Mage::app()->getRequest()->getActionName(), 'result') === false){
|
| 41 |
+
return;
|
| 42 |
+
}
|
| 43 |
+
// If were not on the index, assume we are on the result page, build collection from results
|
| 44 |
+
$_productCollection = Mage::getSingleton('catalogsearch/advanced')->getProductCollection();
|
| 45 |
+
} else {
|
| 46 |
+
// If were not on the advanced search page, get loaded products
|
| 47 |
+
$_productCollection = $that->getLoadedProductCollection();
|
| 48 |
+
}
|
| 49 |
+
if (!$_productCollection) return;
|
| 50 |
+
if ($_productCollection->count() === 0) return;
|
| 51 |
+
|
| 52 |
+
// Extract products displayed on category page
|
| 53 |
+
// Need to do it after content block as the specified products are loaded then
|
| 54 |
+
$products = array();
|
| 55 |
+
$counter = 0;
|
| 56 |
+
foreach ($_productCollection as $_product) {
|
| 57 |
+
if($counter===$triggered_messaging_digital_data_layer_prod_list_limit){
|
| 58 |
+
//Once limit has been hit, break out of the loop
|
| 59 |
+
break;
|
| 60 |
+
} else {
|
| 61 |
+
$counter++;
|
| 62 |
+
}
|
| 63 |
+
array_push($products, $mage->_getProductModel($_product, 'list'));
|
| 64 |
}
|
| 65 |
+
|
| 66 |
+
$preloaded_product = $mage->getProduct();
|
| 67 |
+
?>
|
| 68 |
+
<!-- W3C Digital Data Layer Extra Info Start -->
|
| 69 |
+
<script type="text/javascript">
|
| 70 |
+
try {
|
| 71 |
+
<?php if ($products) : ?>
|
| 72 |
+
<?php if (!$preloaded_product) : ?>
|
| 73 |
+
window.digitalData.product = <?php echo json_encode($products) ?>;
|
| 74 |
+
<?php else : ?>
|
| 75 |
+
window.digitalData.product.push.apply(window.digitalData.product, <?php echo json_encode($products) ?>);
|
| 76 |
+
<?php endif; ?>
|
| 77 |
+
<?php endif; ?>
|
| 78 |
+
} catch (e) {
|
| 79 |
+
}
|
| 80 |
+
</script>
|
| 81 |
+
<!-- W3C Digital Data Layer Extra Info End -->
|
| 82 |
+
<?php
|
| 83 |
+
endif;
|
| 84 |
+
|
| 85 |
+
} catch (Exception $e) {
|
| 86 |
+
} ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1,7 +1,7 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>W3CDigitalDataLayerByTriggeredMessaging</name>
|
| 4 |
-
<version>0.3.
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://opensource.org/licenses/apachepl.php">Apache Software License v2</license>
|
| 7 |
<channel>community</channel>
|
|
@@ -29,9 +29,9 @@ https://github.com/TriggeredMessaging/digitalDataMagentoExtension/issues</descri
|
|
| 29 |
- Minimum prices of grouped and bundled products can be extracted.
|
| 30 |
- Output of debug data can now be controlled through admin configuration panel.</notes>
|
| 31 |
<authors><author><name>Muhammed Miah</name><user>momiah1234</user><email>muhammed.miah@triggeredmessaging.com</email></author><author><name>Triggered Messaging</name><user>tmsdemo</user><email>demostore@triggeredmessaging.com</email></author><author><name>Mike Austin</name><user>tmsdemo</user><email>dev@triggeredmessaging.com</email></author></authors>
|
| 32 |
-
<date>2015-
|
| 33 |
-
<time>
|
| 34 |
-
<contents><target name="magecommunity"><dir name="TriggeredMessaging"><dir name="DigitalDataLayer"><dir name="Block"><file name="Ddl.php" hash="
|
| 35 |
<compatible/>
|
| 36 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
| 37 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>W3CDigitalDataLayerByTriggeredMessaging</name>
|
| 4 |
+
<version>0.3.13</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://opensource.org/licenses/apachepl.php">Apache Software License v2</license>
|
| 7 |
<channel>community</channel>
|
| 29 |
- Minimum prices of grouped and bundled products can be extracted.
|
| 30 |
- Output of debug data can now be controlled through admin configuration panel.</notes>
|
| 31 |
<authors><author><name>Muhammed Miah</name><user>momiah1234</user><email>muhammed.miah@triggeredmessaging.com</email></author><author><name>Triggered Messaging</name><user>tmsdemo</user><email>demostore@triggeredmessaging.com</email></author><author><name>Mike Austin</name><user>tmsdemo</user><email>dev@triggeredmessaging.com</email></author></authors>
|
| 32 |
+
<date>2015-11-03</date>
|
| 33 |
+
<time>10:57:44</time>
|
| 34 |
+
<contents><target name="magecommunity"><dir name="TriggeredMessaging"><dir name="DigitalDataLayer"><dir name="Block"><file name="Ddl.php" hash="6984c9b437d69814e51b1b2258239b01"/></dir><dir name="Helper"><file name="Data.php" hash="43a068106264bffb881f7428de3b6c8f"/></dir><dir name="Model"><dir name="Container"><file name="Ddl.php" hash="c17548db4692e419e413031fcc1043e1"/></dir><file name="Observer.php" hash="e700c98596060292286877ee0b2cf02e"/><dir name="Page"><file name="Observer.php" hash="543e5c2e7d6aa01e48285b4ad4856db4"/></dir><dir name="System"><dir name="Config"><dir name="Source"><file name="Productattributes.php" hash="93312ce69f938cab2abffa7e993b531a"/><file name="Stockexposure.php" hash="d7a5471997b50e82da81152ce50f48d8"/></dir></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="c611a06d1b306829bdd4b162fab70a8b"/><file name="cache.xml" hash="1b6658073a8126cd655cb18109559f49"/><file name="config.xml" hash="7b9f0636f0847b73793340b2da91d286"/><file name="system.xml" hash="8ea62e7c51f93338f7f8a867fbe6fb33"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="triggeredmessaging"><file name="digital_data_layer.phtml" hash="18c5ea8d7c1c879c6ad7adb95b3cd9bc"/><file name="digital_data_layer_after_content.phtml" hash="5e49412626a8d8f65b0ac6de4761db60"/></dir></dir><dir name="layout"><dir name="triggeredmessaging"><file name="digital_data_layer.xml" hash="96163fc1757cc99cc7bf958eb8e315b9"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="TriggeredMessaging_DigitalDataLayer.xml" hash="cfc3b1bff54f3e1f224f120e536bc411"/></dir></target></contents>
|
| 35 |
<compatible/>
|
| 36 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
| 37 |
</package>
|
