Anaraky_GDRT_1 - Version 1.0.6

Version Notes

Update:
* added the ability to include or exclude taxes for 'ecomm_totalvalue'.

Download this release

Release Info

Developer Vladas Tomkevicius
Extension Anaraky_GDRT_1
Version 1.0.6
Comparing to
See all releases


Code changes from version 1.0.5 to 1.0.6

app/code/community/Anaraky/Gdrt/Block/Script.php CHANGED
@@ -4,7 +4,13 @@ class Anaraky_Gdrt_Block_Script extends Mage_Core_Block_Abstract {
4
  private function getParams()
5
  {
6
  $storeId = Mage::app()->getStore()->getId();
7
- $gdrt_pid = Mage::getStoreConfig('gdrt/general/gdrt_product_id', $storeId);
 
 
 
 
 
 
8
 
9
  $type = $this->getData('pageType');
10
  $params = array('ecomm_pagetype' => 'siteview');
@@ -28,10 +34,12 @@ class Anaraky_Gdrt_Block_Script extends Mage_Core_Block_Abstract {
28
 
29
  case 'product':
30
  $product = Mage::registry('current_product');
 
 
31
  $params = array(
32
- 'ecomm_prodid' => (string)($gdrt_pid == 0 ? $product->getId() : $product->getSku()),
33
  'ecomm_pagetype' => 'product',
34
- 'ecomm_totalvalue' => (float)number_format($product->getFinalPrice(), '2', '.', '')
35
  );
36
  unset($product);
37
  break;
@@ -39,20 +47,22 @@ class Anaraky_Gdrt_Block_Script extends Mage_Core_Block_Abstract {
39
  case 'cart':
40
  $cart = Mage::getSingleton('checkout/session')->getQuote();
41
  $items = $cart->getAllVisibleItems();
 
42
  if (count($items) > 0) {
43
  $data = array();
44
-
45
  foreach ($items as $item)
46
  {
47
- $data[0][] = (string)($gdrt_pid == 0 ? $item->getProductId() : $item->getSku());
48
  $data[1][] = (int)$item->getQty();
 
49
  }
50
-
51
  $params = array(
52
  'ecomm_prodid' => $data[0],
53
  'ecomm_pagetype' => 'cart',
54
  'ecomm_quantity' => $data[1],
55
- 'ecomm_totalvalue' => (float)number_format($cart->getGrandTotal(), '2', '.', '')
56
  );
57
  }
58
  else
@@ -62,27 +72,28 @@ class Anaraky_Gdrt_Block_Script extends Mage_Core_Block_Abstract {
62
  break;
63
 
64
  case 'purchase':
65
- //$cart = Mage::getSingleton('checkout/session')->getQuote();
66
- //$items = $cart->getAllVisibleItems();
67
-
68
  $order = Mage::getModel('sales/order')->loadByIncrementId(
69
  Mage::getSingleton('checkout/session')
70
  ->getLastRealOrderId());
71
- $items = $order->getAllItems();
72
- $data = array();
73
 
 
 
 
 
74
  foreach ($items as $item)
75
  {
76
- $data[0][] = (string)($gdrt_pid == 0 ? $item->getProductId() : $item->getSku());
77
  $data[1][] = (int)$item->getQtyToInvoice();
 
78
  }
79
-
80
  $params = array(
81
  'ecomm_prodid' => $data[0],
82
  'ecomm_pagetype' => 'purchase',
83
  'ecomm_quantity' => $data[1],
84
- 'ecomm_totalvalue' => (float)number_format($order->getSubtotal(), '2', '.', '')
85
  );
 
86
  break;
87
 
88
  default:
4
  private function getParams()
5
  {
6
  $storeId = Mage::app()->getStore()->getId();
7
+ $gdrt_pid = false;
8
+ if ((int)Mage::getStoreConfig('gdrt/general/gdrt_product_id', $storeId) === 0)
9
+ $gdrt_pid = true;
10
+
11
+ $inclTax = false;
12
+ if ((int)Mage::getStoreConfig('gdrt/general/gdrt_tax', $storeId) === 1)
13
+ $inclTax = true;
14
 
15
  $type = $this->getData('pageType');
16
  $params = array('ecomm_pagetype' => 'siteview');
34
 
35
  case 'product':
36
  $product = Mage::registry('current_product');
37
+ $totalvalue = Mage::helper('tax')->getPrice($product, $product->getFinalPrice(), $inclTax);
38
+
39
  $params = array(
40
+ 'ecomm_prodid' => (string)($gdrt_pid ? $product->getId() : $product->getSku()),
41
  'ecomm_pagetype' => 'product',
42
+ 'ecomm_totalvalue' => (float)number_format($totalvalue, '2', '.', '')
43
  );
44
  unset($product);
45
  break;
47
  case 'cart':
48
  $cart = Mage::getSingleton('checkout/session')->getQuote();
49
  $items = $cart->getAllVisibleItems();
50
+
51
  if (count($items) > 0) {
52
  $data = array();
53
+ $totalvalue = 0;
54
  foreach ($items as $item)
55
  {
56
+ $data[0][] = (string)($gdrt_pid ? $item->getProductId() : $item->getSku());
57
  $data[1][] = (int)$item->getQty();
58
+ $totalvalue += $inclTax ? $item->getRowTotalInclTax() : $item->getRowTotal();
59
  }
60
+
61
  $params = array(
62
  'ecomm_prodid' => $data[0],
63
  'ecomm_pagetype' => 'cart',
64
  'ecomm_quantity' => $data[1],
65
+ 'ecomm_totalvalue' => (float)number_format($totalvalue, '2', '.', '')
66
  );
67
  }
68
  else
72
  break;
73
 
74
  case 'purchase':
 
 
 
75
  $order = Mage::getModel('sales/order')->loadByIncrementId(
76
  Mage::getSingleton('checkout/session')
77
  ->getLastRealOrderId());
 
 
78
 
79
+ $data = array();
80
+ $totalvalue = 0;
81
+ $items = $order->getAllItems();
82
+
83
  foreach ($items as $item)
84
  {
85
+ $data[0][] = (string)($gdrt_pid ? $item->getProductId() : $item->getSku());
86
  $data[1][] = (int)$item->getQtyToInvoice();
87
+ $totalvalue += $inclTax ? $item->getRowTotalInclTax() : $item->getRowTotal();
88
  }
89
+
90
  $params = array(
91
  'ecomm_prodid' => $data[0],
92
  'ecomm_pagetype' => 'purchase',
93
  'ecomm_quantity' => $data[1],
94
+ 'ecomm_totalvalue' => (float)number_format($totalvalue, '2', '.', '')
95
  );
96
+ unset($order, $items, $item);
97
  break;
98
 
99
  default:
app/code/community/Anaraky/Gdrt/Helper/Data.php CHANGED
@@ -1,4 +1,4 @@
1
  <?php
2
  class Anaraky_Gdrt_Helper_Data extends Mage_Core_Helper_Abstract {
3
-
4
  }
1
  <?php
2
  class Anaraky_Gdrt_Helper_Data extends Mage_Core_Helper_Abstract {
3
+
4
  }
app/code/community/Anaraky/Gdrt/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Anaraky_Gdrt>
5
- <version>1.0.5</version>
6
  </Anaraky_Gdrt>
7
  </modules>
8
 
@@ -27,8 +27,9 @@
27
  <default>
28
  <gdrt>
29
  <general>
30
- <gdrt_enable>0</gdrt_enable>
31
  <gdrt_product_id>1</gdrt_product_id>
 
32
  </general>
33
  <pages>
34
  <home>cms/index/index</home>
2
  <config>
3
  <modules>
4
  <Anaraky_Gdrt>
5
+ <version>1.0.6</version>
6
  </Anaraky_Gdrt>
7
  </modules>
8
 
27
  <default>
28
  <gdrt>
29
  <general>
30
+ <gdrt_enable>1</gdrt_enable>
31
  <gdrt_product_id>1</gdrt_product_id>
32
+ <gdrt_tax>0</gdrt_tax>
33
  </general>
34
  <pages>
35
  <home>cms/index/index</home>
app/code/community/Anaraky/Gdrt/etc/system.xml CHANGED
@@ -34,7 +34,7 @@
34
  <show_in_website>1</show_in_website>
35
  <show_in_store>1</show_in_store>
36
  </gdrt_enable>
37
- <gc_id>
38
  <label>google_conversion_id</label>
39
  <frontend_type>text</frontend_type>
40
  <depends>
@@ -45,7 +45,7 @@
45
  <show_in_website>1</show_in_website>
46
  <show_in_store>1</show_in_store>
47
  </gc_id>
48
- <gc_label>
49
  <label>google_conversion_label</label>
50
  <frontend_type>text</frontend_type>
51
  <comment>
@@ -59,7 +59,7 @@
59
  <show_in_website>1</show_in_website>
60
  <show_in_store>1</show_in_store>
61
  </gc_label>
62
- <gdrt_product_id>
63
  <label>Use for product id</label>
64
  <frontend_type>select</frontend_type>
65
  <source_model>gdrt/adminhtml_system_config_source_useasid</source_model>
@@ -74,6 +74,21 @@
74
  <show_in_website>1</show_in_website>
75
  <show_in_store>1</show_in_store>
76
  </gdrt_product_id>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  </fields>
78
  </general>
79
 
34
  <show_in_website>1</show_in_website>
35
  <show_in_store>1</show_in_store>
36
  </gdrt_enable>
37
+ <gc_id translate="label">
38
  <label>google_conversion_id</label>
39
  <frontend_type>text</frontend_type>
40
  <depends>
45
  <show_in_website>1</show_in_website>
46
  <show_in_store>1</show_in_store>
47
  </gc_id>
48
+ <gc_label translate="label">
49
  <label>google_conversion_label</label>
50
  <frontend_type>text</frontend_type>
51
  <comment>
59
  <show_in_website>1</show_in_website>
60
  <show_in_store>1</show_in_store>
61
  </gc_label>
62
+ <gdrt_product_id translate="label">
63
  <label>Use for product id</label>
64
  <frontend_type>select</frontend_type>
65
  <source_model>gdrt/adminhtml_system_config_source_useasid</source_model>
74
  <show_in_website>1</show_in_website>
75
  <show_in_store>1</show_in_store>
76
  </gdrt_product_id>
77
+ <gdrt_tax translate="label">
78
+ <label>Total value</label>
79
+ <frontend_type>select</frontend_type>
80
+ <source_model>tax/system_config_source_priceType</source_model>
81
+ <comment>
82
+ The value of 'ecomm_totalvalue' with or without taxes?
83
+ </comment>
84
+ <depends>
85
+ <gdrt_enable>1</gdrt_enable>
86
+ </depends>
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
+ </gdrt_tax>
92
  </fields>
93
  </general>
94
 
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Anaraky_GDRT_1</name>
4
- <version>1.0.5</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.gnu.org/licenses/gpl.html">GNU General Public License</license>
7
  <channel>community</channel>
@@ -9,11 +9,11 @@
9
  <summary>Google Dynamic Remarketing Tag extension for Magento</summary>
10
  <description>With this extension is simply and easy to integrate the Google Dynamic Remarketing Tag into Magento.</description>
11
  <notes>Update:&#xD;
12
- * added debugging feature.</notes>
13
  <authors><author><name>Vladas Tomkevicius</name><user>Neodan</user><email>neodann@gmail.com</email></author></authors>
14
- <date>2013-09-22</date>
15
- <time>15:03:21</time>
16
- <contents><target name="magecommunity"><dir name="Anaraky"><dir name="Gdrt"><dir name="Block"><file name="Script.php" hash="dedb97fde54a96f4d9a6bf5ec3830d83"/></dir><dir name="Helper"><file name="Data.php" hash="e1dfad9d739c7c3bc6094abae0af01e7"/></dir><dir name="Model"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Source"><file name="Useasid.php" hash="d0f1371d883f6dd3af422e907770ee87"/></dir></dir></dir></dir><file name="Observer.php" hash="4182860b2afe88fc3f5f83dbef6adc0f"/></dir><dir name="etc"><file name="adminhtml.xml" hash="03a29217c242534e2f13fe79e5fb43c7"/><file name="config.xml" hash="28d5dc5d95d27c68c846606fad5b2b49"/><file name="system.xml" hash="d531ca0e511be24d6769256fb0846bed"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Anaraky_Gdrt.xml" hash="43fa98d76721559c9ca20636dcb6af61"/></dir></target></contents>
17
  <compatible/>
18
- <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.5.1.0</min><max>1.7.0.2</max></package></required></dependencies>
19
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Anaraky_GDRT_1</name>
4
+ <version>1.0.6</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.gnu.org/licenses/gpl.html">GNU General Public License</license>
7
  <channel>community</channel>
9
  <summary>Google Dynamic Remarketing Tag extension for Magento</summary>
10
  <description>With this extension is simply and easy to integrate the Google Dynamic Remarketing Tag into Magento.</description>
11
  <notes>Update:&#xD;
12
+ * added the ability to include or exclude taxes for 'ecomm_totalvalue'.</notes>
13
  <authors><author><name>Vladas Tomkevicius</name><user>Neodan</user><email>neodann@gmail.com</email></author></authors>
14
+ <date>2013-10-26</date>
15
+ <time>11:05:37</time>
16
+ <contents><target name="magecommunity"><dir name="Anaraky"><dir name="Gdrt"><dir name="Block"><file name="Script.php" hash="093ee9343d25d2d4c7a2a1ee0227d4ca"/></dir><dir name="Helper"><file name="Data.php" hash="64bf0f7fd706e48775562dd65f84ea7d"/></dir><dir name="Model"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Source"><file name="Useasid.php" hash="d0f1371d883f6dd3af422e907770ee87"/></dir></dir></dir></dir><file name="Observer.php" hash="4182860b2afe88fc3f5f83dbef6adc0f"/></dir><dir name="etc"><file name="adminhtml.xml" hash="03a29217c242534e2f13fe79e5fb43c7"/><file name="config.xml" hash="6c5f6da09a428a49694c04632af96279"/><file name="system.xml" hash="56bd1de34b96f284d33f9b536f5e456f"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Anaraky_Gdrt.xml" hash="43fa98d76721559c9ca20636dcb6af61"/></dir></target></contents>
17
  <compatible/>
18
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.5.1.0</min><max>1.8.0.0</max></package></required></dependencies>
19
  </package>