Woo - Version 1.0.9

Version Notes

Support details statistic

Download this release

Release Info

Developer Woomio
Extension Woo
Version 1.0.9
Comparing to
See all releases


Code changes from version 1.0.8 to 1.0.9

app/code/local/Woomio/Tracker/Block/Tracking.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ class Woomio_Tracker_Block_Tracking extends Mage_Core_Block_Template{
3
+
4
+
5
+
6
+ }
app/code/local/Woomio/Tracker/Model/Observer.php CHANGED
@@ -1,27 +1,57 @@
1
  <?php
2
  class Woomio_Tracker_Model_Observer
3
  {
 
 
 
 
4
 
5
  public function setWascid(Varien_Event_Observer $observer)
6
  {
7
  $Order = $observer->getEvent()->getOrder();
8
  $OrderId = $Order->getId();
9
-
10
  $WascID = Mage::getModel('core/cookie')->get('wacsid');
11
  if(!$WascID){ $WascID = 0; }
12
-
13
  $Resource = Mage::getSingleton('core/resource');
14
  $Connection = Mage::getSingleton('core/resource')->getConnection('core_write');
15
  $WoomioTable = Mage::getSingleton("core/resource")->getTableName('woomio');
16
-
17
  $InsertSQL = "INSERT INTO `".$WoomioTable."` (`orderid`,`wacsid`) VALUES ('".$OrderId."','".$WascID."')";
18
  $Connection = Mage::getSingleton('core/resource')->getConnection('core_write');
19
  $Connection->query($InsertSQL);
20
-
21
- $CallRegisterHitUrl ="http://www.woomio.com/api/analyticsr/RegisterHit?esid=".$WascID."&url="."http://$_SERVER[HTTP_HOST]/checkout/onepage/success/"."&r=1&ct=&ur=";
22
- $CallbackRegisterHit = file_get_contents($CallRegisterHitUrl);
23
-
24
- $CallbackUrl = "https://www.woomio.com/endpoints/purchase?sid=".$WascID."&oid=".$OrderId."&ot=".$Order->getGrandTotal()."&url=0&oc=".$Order->getBaseCurrencyCode()."&email=".$Order->getCustomerEmail();
25
- $Callback = file_get_contents($CallbackUrl);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  }
27
  }
1
  <?php
2
  class Woomio_Tracker_Model_Observer
3
  {
4
+ public static function w_error_handler($errno, $errstr, $errfile, $errline, $errcontext) {
5
+ error_log('An error occurred sending purchase to woomio, and was bypassed. ' . $errno . ': ' . $errstr);
6
+ return true;
7
+ }
8
 
9
  public function setWascid(Varien_Event_Observer $observer)
10
  {
11
  $Order = $observer->getEvent()->getOrder();
12
  $OrderId = $Order->getId();
13
+
14
  $WascID = Mage::getModel('core/cookie')->get('wacsid');
15
  if(!$WascID){ $WascID = 0; }
16
+
17
  $Resource = Mage::getSingleton('core/resource');
18
  $Connection = Mage::getSingleton('core/resource')->getConnection('core_write');
19
  $WoomioTable = Mage::getSingleton("core/resource")->getTableName('woomio');
20
+
21
  $InsertSQL = "INSERT INTO `".$WoomioTable."` (`orderid`,`wacsid`) VALUES ('".$OrderId."','".$WascID."')";
22
  $Connection = Mage::getSingleton('core/resource')->getConnection('core_write');
23
  $Connection->query($InsertSQL);
24
+
25
+ $CallbackUrl = "https://www.woomio.com/endpoints/purchase?sid=" . urlencode($WascID) . "&oid=" . urlencode($OrderId) . "&ot=" . urlencode($Order->getGrandTotal()) . "&url=0&oc=" . urlencode($Order->getBaseCurrencyCode()) . "&email=" . urlencode($Order->getCustomerEmail());
26
+
27
+ $parts = parse_url($CallbackUrl);
28
+
29
+ $host = $parts['host'];
30
+
31
+ $path = $parts['path'];
32
+ if($parts['query'] != "") {
33
+ $path .= "?" . $parts['query'];
34
+ }
35
+
36
+ set_error_handler(array('Woomio_Tracker_Model_Observer', 'w_error_handler'));
37
+ $file_pointer = fsockopen("ssl://" . $host, 443, $errno, $errstr, 10);
38
+ restore_error_handler();
39
+
40
+ if(!$file_pointer) {
41
+ error_log("Error opening socket to woomio server: " . $errstr . "(" . $errno . ").", 0);
42
+ }
43
+ else {
44
+ $out = "GET " . $path . " HTTP/1.1\r\n";
45
+ $out .= "Host: " . $host . "\r\n";
46
+ $out .= "Content-Type: application/x-www-form-urlencoded\r\n";
47
+ $out .= "Connection: Close\r\n\r\n";
48
+ $fwrite = fwrite($file_pointer, $out);
49
+ stream_set_timeout($file_pointer, 2);
50
+
51
+ if($fwrite === false) {
52
+ error_log("Error sending request to woomio server: Error writing to socket.", 0);
53
+ }
54
+ fclose($file_pointer);
55
+ }
56
  }
57
  }
app/code/local/Woomio/Tracker/etc/adminhtml.xml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <admin>
6
+ <children>
7
+ <system>
8
+ <children>
9
+ <config>
10
+ <children>
11
+ <tracker translate="title" module="tracker">
12
+ <title>Woomio Tracker</title>
13
+ <sort_order>1</sort_order>
14
+ </tracker>
15
+ </children>
16
+ </config>
17
+ </children>
18
+ </system>
19
+ </children>
20
+ </admin>
21
+ </resources>
22
+ </acl>
23
+ </config>
app/code/local/Woomio/Tracker/etc/config.xml CHANGED
@@ -1,69 +1,69 @@
1
- <?xml version="1.0"?>
2
  <config>
3
- <modules>
4
- <Woomio_Tracker>
5
- <version>1.0.6</version>
6
- </Woomio_Tracker>
7
- </modules>
8
- <frontend>
9
- <routers>
10
- <tracker>
11
- <use>standard</use>
12
- <args>
13
- <module>Woomio_Tracker</module>
14
- <frontName>woomio</frontName>
15
- </args>
16
- </tracker>
17
- </routers>
18
- <layout>
19
- <updates>
20
- <tracker>
21
- <file>tracker.xml</file>
22
- </tracker>
23
- </updates>
24
- </layout>
25
- </frontend>
26
- <global>
27
- <helpers>
28
- <tracker>
29
- <class>Woomio_Tracker_Helper</class>
30
- </tracker>
31
- </helpers>
32
- <blocks>
33
- <tracker>
34
- <class>Woomio_Tracker_Block</class>
35
- </tracker>
36
- </blocks>
37
- <resources>
38
- <tracker_setup>
39
- <setup>
40
- <module>Woomio_Tracker</module>
41
- </setup>
42
- <connection>
43
- <use>core_setup</use>
44
- </connection>
45
- </tracker_setup>
46
- <tracker_write>
47
- <connection>
48
- <use>core_write</use>
49
- </connection>
50
- </tracker_write>
51
- <tracker_read>
52
- <connection>
53
- <use>core_read</use>
54
- </connection>
55
- </tracker_read>
56
- </resources>
57
- <events>
58
- <sales_order_place_after>
59
- <observers>
60
- <ds_order_event>
61
- <type>singleton</type>
62
- <class>Woomio_Tracker_Model_Observer</class>
63
- <method>setWascid</method>
64
- </ds_order_event>
65
- </observers>
66
- </sales_order_place_after>
67
- </events>
68
- </global>
69
- </config>
1
+ <?xml version="1.0" ?>
2
  <config>
3
+ <modules>
4
+ <Woomio_Tracker>
5
+ <version>1.0.9</version>
6
+ </Woomio_Tracker>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <tracker>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>Woomio_Tracker</module>
14
+ <frontName>woomio</frontName>
15
+ </args>
16
+ </tracker>
17
+ </routers>
18
+ <layout>
19
+ <updates>
20
+ <tracker>
21
+ <file>tracker.xml</file>
22
+ </tracker>
23
+ </updates>
24
+ </layout>
25
+ </frontend>
26
+ <global>
27
+ <helpers>
28
+ <tracker>
29
+ <class>Woomio_Tracker_Helper</class>
30
+ </tracker>
31
+ </helpers>
32
+ <blocks>
33
+ <tracker>
34
+ <class>Woomio_Tracker_Block</class>
35
+ </tracker>
36
+ </blocks>
37
+ <resources>
38
+ <tracker_setup>
39
+ <setup>
40
+ <module>Woomio_Tracker</module>
41
+ </setup>
42
+ <connection>
43
+ <use>core_setup</use>
44
+ </connection>
45
+ </tracker_setup>
46
+ <tracker_write>
47
+ <connection>
48
+ <use>core_write</use>
49
+ </connection>
50
+ </tracker_write>
51
+ <tracker_read>
52
+ <connection>
53
+ <use>core_read</use>
54
+ </connection>
55
+ </tracker_read>
56
+ </resources>
57
+ <events>
58
+ <sales_order_place_after>
59
+ <observers>
60
+ <ds_order_event>
61
+ <type>singleton</type>
62
+ <class>Woomio_Tracker_Model_Observer</class>
63
+ <method>setWascid</method>
64
+ </ds_order_event>
65
+ </observers>
66
+ </sales_order_place_after>
67
+ </events>
68
+ </global>
69
+ </config>
app/code/local/Woomio/Tracker/sql/tracker_setup/mysql4-install-1.0.6.php CHANGED
@@ -1,22 +1,36 @@
1
  <?php
 
 
 
 
 
2
  $installer = $this;
3
  $installer->startSetup();
4
- $sql ='create table '.$this->getTable('woomio').'(orderid int not null auto_increment, wacsid varchar(100), primary key(orderid));';
 
 
5
 
6
  $Email = Mage::getStoreConfig('trans_email/ident_general/email');
7
  $Domain = Mage::getStoreConfig('web/unsecure/base_url');
8
  $Lang = substr(Mage::getStoreConfig('general/locale/code'),0,2);
9
  $Name = Mage::getStoreConfig('trans_email/ident_general/name');
10
 
11
- $SetupCallbackUrl = 'https://www.woomio.com/umbraco/api/Endpoints/RetailerSignup?name='.$Name.'&domain='.$Domain.'&country='.$Lang.'&email='.$Email.'&platform=1';
12
- $Response = file_get_contents($SetupCallbackUrl);
 
 
 
 
 
 
 
 
13
 
14
- $FilePath = $_SERVER['DOCUMENT_ROOT'] . '/app/design/frontend/base/default/layout/tracker.xml';
15
- $Xml = file_get_contents($FilePath);
16
- $ConfigFile = fopen($FilePath, 'w');
17
- fwrite($ConfigFile, str_replace('.js"', '.js" data-r=' . $Response, $Xml));
18
- fclose($ConfigFile);
19
 
20
  $installer->run($sql);
21
  $installer->endSetup();
22
-
1
  <?php
2
+ function w_error_handler($errno, $errstr, $errfile, $errline, $errcontext) {
3
+ error_log('An error occurred registering with woomio backend, and was bypassed. ' . $errno . ': ' . $errstr);
4
+ return true;
5
+ }
6
+
7
  $installer = $this;
8
  $installer->startSetup();
9
+
10
+ $sql = 'DROP TABLE IF EXISTS `'.$this->getTable('woomio').'`;';
11
+ $sql .= 'CREATE TABLE '.$this->getTable('woomio').'(orderid int not null auto_increment, wacsid varchar(100), primary key(orderid));';
12
 
13
  $Email = Mage::getStoreConfig('trans_email/ident_general/email');
14
  $Domain = Mage::getStoreConfig('web/unsecure/base_url');
15
  $Lang = substr(Mage::getStoreConfig('general/locale/code'),0,2);
16
  $Name = Mage::getStoreConfig('trans_email/ident_general/name');
17
 
18
+ $SetupCallbackUrl = 'https://www.woomio.com/endpoints/RetailerSignup?name=' . urlencode($Name) . '&domain=' . urlencode($Domain) . '&country=' . urlencode($Lang) . '&email=' . urlencode($Email) . '&platform=1';
19
+
20
+ //Ignore errors returned by the server
21
+ $context = stream_context_create(array(
22
+ 'http' => array('ignore_errors' => true)
23
+ ));
24
+
25
+ set_error_handler('w_error_handler');
26
+ $Response = @file_get_contents($SetupCallbackUrl, false, $context);
27
+ restore_error_handler();
28
 
29
+ if($Response !== false) {
30
+ $configModel = new Mage_Core_Model_Config();
31
+ //We save to default since the plugin can only be one in a multistore setup anyhow
32
+ $configModel->saveConfig('tracker/general/data_key', $Response, 'default', 0);
33
+ }
34
 
35
  $installer->run($sql);
36
  $installer->endSetup();
 
app/design/frontend/base/default/layout/tracker.xml CHANGED
@@ -1,15 +1,9 @@
1
  <?xml version="1.0"?>
2
- <layout version="1.0.6">
3
  <default>
4
  <reference name="head">
5
- <block type="core/text" name="woomio.com">
6
- <action method="setText">
7
- <text>
8
- <![CDATA[<script src="https://woomio.com/assets/js/analytics/ro.js"></script>]]>
9
- </text>
10
- </action>
11
- </block>
12
  </reference>
13
  </default>
14
  </layout>
15
-
1
  <?xml version="1.0"?>
2
+ <layout version="1.0.9">
3
  <default>
4
  <reference name="head">
5
+ <block type="tracker/tracking" name="tracking" as="tracker_tracking_head" template="woomio_tracker/tracking.phtml" />
 
 
 
 
 
 
6
  </reference>
7
  </default>
8
  </layout>
9
+
app/design/frontend/base/default/template/woomio_tracker/tracking.phtml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $DATAR = Mage::getStoreConfig('tracker/general/data_key');
3
+ ?>
4
+ <?php if($DATAR):?>
5
+ <script src="https://woomio.com/assets/js/analytics/ro.js" data-r="<?php echo $DATAR;?>"></script>
6
+ <?php else: ?>
7
+ <script src="https://woomio.com/assets/js/analytics/ro.js"></script>
8
+ <?php endif; ?>
app/etc/modules/Woomio_Tracker.xml CHANGED
@@ -4,7 +4,7 @@
4
  <Woomio_Tracker>
5
  <active>true</active>
6
  <codePool>local</codePool>
7
- <version>1.0.6</version>
8
  </Woomio_Tracker>
9
  </modules>
10
- </config>
4
  <Woomio_Tracker>
5
  <active>true</active>
6
  <codePool>local</codePool>
7
+ <version>1.0.9</version>
8
  </Woomio_Tracker>
9
  </modules>
10
+ </config>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Woo</name>
4
- <version>1.0.8</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.woomio.com">Open Software License (OSL)</license>
7
  <channel>community</channel>
@@ -23,9 +23,9 @@ Compatibility&#xD;
23
  Woomio is fully compatible with all Magento versions and modules.</description>
24
  <notes>Support details statistic </notes>
25
  <authors><author><name>Woomio</name><user>Woomio</user><email>developer@woomio.com</email></author></authors>
26
- <date>2015-06-08</date>
27
- <time>09:33:55</time>
28
- <contents><target name="magelocal"><dir name="Woomio"><dir name="Tracker"><dir name="Block"><file name="Index.php" hash="949b7c689724a7eeeba5168a9cf03507"/></dir><dir name="Helper"><file name="Data.php" hash="53a3a643e1eea3a72e02b5c64daa9edd"/></dir><dir name="Model"><file name="Observer.php" hash="855bd53491c9c6b37178d7565d7e2e1a"/></dir><dir name="controllers"><file name="IndexController.php" hash="23096ef9a4af36032fe9098f87b057db"/></dir><dir name="etc"><file name="config.xml" hash="4fcc52e3528c8181f23681ec9b67d6ad"/></dir><dir name="sql"><dir name="tracker_setup"><file name="mysql4-install-1.0.6.php" hash="75203067f58f87ebf862dcb4c03e791e"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="tracker.xml" hash="4afe1bc76fffccef1c7ceff6fd70e9f4"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Woomio_Tracker.xml" hash="204c92230750c0d53ac835bf8e790330"/></dir></target></contents>
29
  <compatible/>
30
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
31
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Woo</name>
4
+ <version>1.0.9</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.woomio.com">Open Software License (OSL)</license>
7
  <channel>community</channel>
23
  Woomio is fully compatible with all Magento versions and modules.</description>
24
  <notes>Support details statistic </notes>
25
  <authors><author><name>Woomio</name><user>Woomio</user><email>developer@woomio.com</email></author></authors>
26
+ <date>2015-06-23</date>
27
+ <time>13:01:33</time>
28
+ <contents><target name="magelocal"><dir name="Woomio"><dir name="Tracker"><dir name="Block"><file name="Index.php" hash="949b7c689724a7eeeba5168a9cf03507"/><file name="Tracking.php" hash="1e3cb6eb08e18f13913b3a172571603d"/></dir><dir name="Helper"><file name="Data.php" hash="53a3a643e1eea3a72e02b5c64daa9edd"/></dir><dir name="Model"><file name="Observer.php" hash="3fd0599f7dae4eb723364fef9a26d16b"/></dir><dir name="controllers"><file name="IndexController.php" hash="23096ef9a4af36032fe9098f87b057db"/></dir><dir name="etc"><file name="adminhtml.xml" hash="f4f46675a9901fece5c8b74bb44f7d27"/><file name="config.xml" hash="649076c7464a5fd05f79593a416beacf"/></dir><dir name="sql"><dir name="tracker_setup"><file name="mysql4-install-1.0.6.php" hash="d2962e2e16a5f24e8854cb7bc36a792a"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="tracker.xml" hash="8f82770be01872ddbc9d6376d844144a"/></dir><dir name="template"><dir name="woomio_tracker"><file name="tracking.phtml" hash="0e015827b7beea57e8254f25e6ec1f5e"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Woomio_Tracker.xml" hash="f914fd42517f4b93ebeacf64d7d032d0"/></dir></target></contents>
29
  <compatible/>
30
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
31
  </package>