From ed6d6f7a9c779e6bfcf4e25bc36321b35941c74b Mon Sep 17 00:00:00 2001 From: Alex Koepke Date: Mon, 22 Aug 2016 09:46:22 -0400 Subject: [PATCH 1/9] remove extra trailing comma --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 07616b0..66e17e8 100644 --- a/composer.json +++ b/composer.json @@ -14,5 +14,5 @@ "version": "1.0.1", "require": { "php": ">=5.3.0" - }, + } } From 64a740780ac059ae38bab180d0bd2392fb45e923 Mon Sep 17 00:00:00 2001 From: Alex Koepke Date: Mon, 22 Aug 2016 16:46:32 -0400 Subject: [PATCH 2/9] add auto appened to .gitignore --- composer.json | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/composer.json b/composer.json index 66e17e8..2b196ce 100644 --- a/composer.json +++ b/composer.json @@ -14,5 +14,14 @@ "version": "1.0.1", "require": { "php": ">=5.3.0" + }, + "extra": { + "map": [ + ["app/code/local/MagePal/GoogleTagManager",""app/code/local/MagePal/GoogleTagManager"], + ["app/design/frontend/base/default/layout/magepal_googletagmanager.xml",""app/design/frontend/base/default/layout/magepal_googletagmanager.xml"], + ["app/design/frontend/base/default/template/magepal/googletagmanager",""app/design/frontend/base/default/template/magepal/googletagmanager"], + ["app/etc/modules/MagePal_GoogleTagManager.xml",""app/etc/modules/MagePal_GoogleTagManager.xml"] + ], + "auto-append-gitignore": true } } From e4bf0a8e35c60d2ad4f2de6cccbb3d21631983d8 Mon Sep 17 00:00:00 2001 From: Alex Koepke Date: Mon, 22 Aug 2016 16:48:38 -0400 Subject: [PATCH 3/9] remove extra " --- composer.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 2b196ce..99ef48a 100644 --- a/composer.json +++ b/composer.json @@ -17,10 +17,10 @@ }, "extra": { "map": [ - ["app/code/local/MagePal/GoogleTagManager",""app/code/local/MagePal/GoogleTagManager"], - ["app/design/frontend/base/default/layout/magepal_googletagmanager.xml",""app/design/frontend/base/default/layout/magepal_googletagmanager.xml"], - ["app/design/frontend/base/default/template/magepal/googletagmanager",""app/design/frontend/base/default/template/magepal/googletagmanager"], - ["app/etc/modules/MagePal_GoogleTagManager.xml",""app/etc/modules/MagePal_GoogleTagManager.xml"] + ["app/code/local/MagePal/GoogleTagManager","app/code/local/MagePal/GoogleTagManager"], + ["app/design/frontend/base/default/layout/magepal_googletagmanager.xml","app/design/frontend/base/default/layout/magepal_googletagmanager.xml"], + ["app/design/frontend/base/default/template/magepal/googletagmanager","app/design/frontend/base/default/template/magepal/googletagmanager"], + ["app/etc/modules/MagePal_GoogleTagManager.xml","app/etc/modules/MagePal_GoogleTagManager.xml"] ], "auto-append-gitignore": true } From 1a4c5ba4f63c19b4d6b2ec869f007bffa8e65be4 Mon Sep 17 00:00:00 2001 From: Alex Koepke Date: Mon, 22 Aug 2016 16:56:09 -0400 Subject: [PATCH 4/9] remove modman (not sure this will work) --- modman | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 modman diff --git a/modman b/modman deleted file mode 100644 index 3340c11..0000000 --- a/modman +++ /dev/null @@ -1,5 +0,0 @@ -# Modman file -app/code/local/MagePal/GoogleTagManager app/code/local/MagePal/GoogleTagManager -app/design/frontend/base/default/layout/magepal_googletagmanager.xml app/design/frontend/base/default/layout/magepal_googletagmanager.xml -app/design/frontend/base/default/template/magepal/googletagmanager app/design/frontend/base/default/template/magepal/googletagmanager -app/etc/modules/MagePal_GoogleTagManager.xml app/etc/modules/MagePal_GoogleTagManager.xml From f9c95d605fb2b04c30e848913c858071045629c6 Mon Sep 17 00:00:00 2001 From: Alex Koepke Date: Mon, 22 Aug 2016 17:02:50 -0400 Subject: [PATCH 5/9] add modman back --- modman | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 modman diff --git a/modman b/modman new file mode 100644 index 0000000..3340c11 --- /dev/null +++ b/modman @@ -0,0 +1,5 @@ +# Modman file +app/code/local/MagePal/GoogleTagManager app/code/local/MagePal/GoogleTagManager +app/design/frontend/base/default/layout/magepal_googletagmanager.xml app/design/frontend/base/default/layout/magepal_googletagmanager.xml +app/design/frontend/base/default/template/magepal/googletagmanager app/design/frontend/base/default/template/magepal/googletagmanager +app/etc/modules/MagePal_GoogleTagManager.xml app/etc/modules/MagePal_GoogleTagManager.xml From ce28c0c632375e1717c037d45c11d67764765cee Mon Sep 17 00:00:00 2001 From: Alex Koepke Date: Mon, 22 Aug 2016 17:08:17 -0400 Subject: [PATCH 6/9] remove map --- composer.json | 6 ------ 1 file changed, 6 deletions(-) diff --git a/composer.json b/composer.json index 99ef48a..89e2d77 100644 --- a/composer.json +++ b/composer.json @@ -16,12 +16,6 @@ "php": ">=5.3.0" }, "extra": { - "map": [ - ["app/code/local/MagePal/GoogleTagManager","app/code/local/MagePal/GoogleTagManager"], - ["app/design/frontend/base/default/layout/magepal_googletagmanager.xml","app/design/frontend/base/default/layout/magepal_googletagmanager.xml"], - ["app/design/frontend/base/default/template/magepal/googletagmanager","app/design/frontend/base/default/template/magepal/googletagmanager"], - ["app/etc/modules/MagePal_GoogleTagManager.xml","app/etc/modules/MagePal_GoogleTagManager.xml"] - ], "auto-append-gitignore": true } } From 68b2a1f9d722cb4ab777c5a071510dfedc87b6a9 Mon Sep 17 00:00:00 2001 From: Alex Koepke Date: Thu, 29 Sep 2016 16:09:04 -0400 Subject: [PATCH 7/9] add discount code --- .../MagePal/GoogleTagManager/Block/Tm.php | 57 ++++++++++--------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/app/code/local/MagePal/GoogleTagManager/Block/Tm.php b/app/code/local/MagePal/GoogleTagManager/Block/Tm.php index 467b79b..dc1d714 100755 --- a/app/code/local/MagePal/GoogleTagManager/Block/Tm.php +++ b/app/code/local/MagePal/GoogleTagManager/Block/Tm.php @@ -5,8 +5,8 @@ * See COPYING.txt for license details. */ class MagePal_GoogleTagManager_Block_Tm extends Mage_Core_Block_Template -{ - +{ + /** * Google Tag Manager Helper * @@ -27,39 +27,39 @@ class MagePal_GoogleTagManager_Block_Tm extends Mage_Core_Block_Template * @var MagePal_TagManager_Model_DataLayer */ protected $_dataLayerModel = null; - - + + protected $_customVariables = array(); - + protected $_orderCollection = null; public function __construct() { - + $this->_cookieHelper = Mage::helper('core/cookie'); $this->_gtmHelper = Mage::helper('googletagmanager'); $this->_dataLayerModel = Mage::getModel('googletagmanager/dataLayer'); $this->addVariable('ecommerce', array('currencyCode' => Mage::app()->getStore()->getCurrentCurrencyCode())); } - + /** * Render information about specified orders and their items - * + * * @return void|string */ protected function getOrdersTrackingCode() { $collection = $this->getOrderCollection(); - + if(!$collection){ return; } - + $result = array(); - + foreach ($collection as $order) { - + foreach ($order->getAllVisibleItems() as $item) { $product[] = array( 'sku' => $item->getSku(), @@ -68,19 +68,20 @@ protected function getOrdersTrackingCode() 'quantity' => $item->getQtyOrdered() ); } - + $transaction = array( 'transactionId' => $order->getIncrementId(), 'transactionAffiliation' => Mage::app()->getStore()->getFrontendName(), 'transactionTotal' => $order->getBaseGrandTotal(), 'transactionShipping' => $order->getBaseShippingAmount(), + 'discountCode' = $order->getCouponCode(), 'transactionProducts' => $product ); - - + + $result[] = sprintf("dataLayer.push(%s);", json_encode($transaction)); } - + return implode("\n", $result) . "\n"; } @@ -103,32 +104,32 @@ protected function _toHtml() { * @return json */ public function getGtmTrackingCode() { - + Mage::dispatchEvent('magepal_data_layer', array('data_layer' => $this)); $result = array(); $result[] = sprintf("dataLayer.push(%s);\n", json_encode($this->_dataLayerModel->getVariables())); - + if(!empty($this->_customVariables) && is_array($this->_customVariables)){ - + foreach($this->_customVariables as $custom){ $result[] = sprintf("dataLayer.push(%s);\n", json_encode($custom)); } } - + return implode("\n", $result) . "\n"; } - + public function getQuote(){ return $this->_dataLayerModel->getQuote(); } public function addVariable($name, $value) { $this->_dataLayerModel->addVariable($name, $value); - + return $this; } - + public function addCustomVariable($name, $value = null) { if(is_array($name)){ $this->_customVariables[] = $name; @@ -136,14 +137,14 @@ public function addCustomVariable($name, $value = null) { else{ $this->_customVariables[] = array($name => $value); } - + return $this; } - + public function formatPrice($price){ return $this->_dataLayerModel->formatPrice($price); } - + public function getOrderCollection(){ $orderIds = $this->getOrderIds(); if (empty($orderIds) || !is_array($orderIds)) { @@ -155,8 +156,8 @@ public function getOrderCollection(){ ->addFieldToFilter('entity_id', array('in' => $orderIds)) ; } - + return $this->_orderCollection; } - + } From 2ce2c9480a2b9e2c3b169466855bfed47247b592 Mon Sep 17 00:00:00 2001 From: Alex Koepke Date: Thu, 29 Sep 2016 16:16:55 -0400 Subject: [PATCH 8/9] fix typo --- app/code/local/MagePal/GoogleTagManager/Block/Tm.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/local/MagePal/GoogleTagManager/Block/Tm.php b/app/code/local/MagePal/GoogleTagManager/Block/Tm.php index dc1d714..670dc51 100755 --- a/app/code/local/MagePal/GoogleTagManager/Block/Tm.php +++ b/app/code/local/MagePal/GoogleTagManager/Block/Tm.php @@ -74,7 +74,7 @@ protected function getOrdersTrackingCode() 'transactionAffiliation' => Mage::app()->getStore()->getFrontendName(), 'transactionTotal' => $order->getBaseGrandTotal(), 'transactionShipping' => $order->getBaseShippingAmount(), - 'discountCode' = $order->getCouponCode(), + 'discountCode' => $order->getCouponCode(), 'transactionProducts' => $product ); From 369c19d9d105253dca56ffc180a93bae507c3c4c Mon Sep 17 00:00:00 2001 From: Alex Koepke Date: Thu, 29 Sep 2016 16:39:01 -0400 Subject: [PATCH 9/9] add discount amount --- app/code/local/MagePal/GoogleTagManager/Block/Tm.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/local/MagePal/GoogleTagManager/Block/Tm.php b/app/code/local/MagePal/GoogleTagManager/Block/Tm.php index 670dc51..6dcf1c8 100755 --- a/app/code/local/MagePal/GoogleTagManager/Block/Tm.php +++ b/app/code/local/MagePal/GoogleTagManager/Block/Tm.php @@ -75,6 +75,7 @@ protected function getOrdersTrackingCode() 'transactionTotal' => $order->getBaseGrandTotal(), 'transactionShipping' => $order->getBaseShippingAmount(), 'discountCode' => $order->getCouponCode(), + 'discountPrice' => $order->getDiscountAmount(), 'transactionProducts' => $product );