Woo - Version 1.0.3

Version Notes

Initial version of Woomio

Download this release

Release Info

Developer Woomio
Extension Woo
Version 1.0.3
Comparing to
See all releases


Version 1.0.3

app/code/local/Woomio/Tracker/Block/Index.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Woomio_Tracker_Block_Index extends Mage_Core_Block_Template{
3
+
4
+
5
+
6
+
7
+
8
+ }
app/code/local/Woomio/Tracker/Helper/Data.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ class Woomio_Tracker_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+ }
5
+
app/code/local/Woomio/Tracker/Model/Observer.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ }
app/code/local/Woomio/Tracker/controllers/IndexController.php ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Woomio_Tracker_IndexController extends Mage_Core_Controller_Front_Action{
3
+ public function IndexAction() {
4
+
5
+ $AllowedIP = gethostbyname('ping.woomio.com');
6
+ $GetParams = Mage::app()->getRequest()->getParams();
7
+ $woomioTable = Mage::getSingleton("core/resource")->getTableName('woomio');
8
+ $response = array();
9
+ // == $AllowedIP
10
+ if($_SERVER['REMOTE_ADDR'] == $AllowedIP){
11
+ $response['status'] = "success";
12
+ $response['status_message'] = "IP allowed";
13
+ if(!$GetParams['hrs']){
14
+ $HRS = 1;
15
+ }else{
16
+ $HRS = $GetParams['hrs'];
17
+ }
18
+ if(!$GetParams['wacs']){
19
+ $WACSID = 0;
20
+ }else{
21
+ $WACSID = $GetParams['wacs'];
22
+ }
23
+ if(!$GetParams['id']){
24
+ $_ID = 0;
25
+ }else{
26
+ $_ID = $GetParams['id'];
27
+ }
28
+ switch($GetParams['type']){
29
+ case 'orders':
30
+
31
+ $_conn = Mage::getSingleton('core/resource')->getConnection('core_read');
32
+ $fromDate = date('Y-m-d H:i:s', strtotime('now -'.$HRS.' hours'));
33
+ $toDate = date('Y-m-d H:i:s', strtotime('now'));
34
+ if($_ID){
35
+ $Order = Mage::getModel('sales/order')->load($_ID);
36
+
37
+ $response['orders'][$Order->getId()]['order'] = $Order->getData();
38
+ $response['orders'][$Order->getId()]['customer'] = $Order->getBillingAddress()->getData();
39
+ $response['orders'][$Order->getId()]['customer']['fullname'] = $Order->getCustomerName();
40
+ $response['orders'][$Order->getId()]['customer']['fullstreet'] = $Order->getBillingAddress()->getStreetFull();
41
+ $response['orders'][$Order->getId()]['wacsid'] = $woomioRow['wacsid'];
42
+ }else{
43
+ $Orders = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('created_at', array('from'=>$fromDate, 'to'=>$toDate));
44
+ foreach($Orders as $Order){
45
+ if($WACSID){
46
+ $woomioRow = $_conn->fetchRow('SELECT wacsid FROM '.$woomioTable.' WHERE orderid = '.$Order->getId());
47
+ if($woomioRow['wacsid']){
48
+ $response['orders'][$Order->getId()] = $Order->getData();
49
+ foreach($Order->getAllItems() as $Item):
50
+ $response['orders'][$Order->getId()]['items'][] = array('id' => $Item->getProductId(), 'sku' => $Item->getSku(), 'name' => $Item->getName());
51
+ endforeach;
52
+ $response['orders'][$Order->getId()]['customer'] = $Order->getBillingAddress()->getData();
53
+ $response['orders'][$Order->getId()]['customer']['fullname'] = $Order->getCustomerName();
54
+ $response['orders'][$Order->getId()]['customer']['fullstreet'] = $Order->getBillingAddress()->getStreetFull();
55
+ $response['orders'][$Order->getId()]['wacsid'] = $woomioRow['wacsid'];
56
+ }
57
+ }else{
58
+ $woomioRow = $_conn->fetchRow('SELECT wacsid FROM '.$woomioTable.' WHERE orderid = '.$Order->getId());
59
+ $response['orders'][$Order->getId()] = $Order->getData();
60
+ foreach($Order->getAllItems() as $Item):
61
+ $response['orders'][$Order->getId()]['items'][] = array('id' => $Item->getProductId(), 'sku' => $Item->getSku(), 'name' => $Item->getName());
62
+ endforeach;
63
+ $response['orders'][$Order->getId()]['customer'] = $Order->getBillingAddress()->getData();
64
+ $response['orders'][$Order->getId()]['customer']['fullname'] = $Order->getCustomerName();
65
+ $response['orders'][$Order->getId()]['customer']['fullstreet'] = $Order->getBillingAddress()->getStreetFull();
66
+ if($woomioRow['wacsid']){
67
+ $response['orders'][$Order->getId()]['wacsid'] = $woomioRow['wacsid'];
68
+ }else{
69
+ $response['orders'][$Order->getId()]['wacsid'] = 0;
70
+ }
71
+ }
72
+ }
73
+ }
74
+
75
+ break;
76
+ // #2
77
+ case 'customers':
78
+ if($_ID){
79
+ $Address = Mage::getModel('sales/order_address')->load($_ID);
80
+ $response['customers'][] = $Address->getData();
81
+ }else{
82
+ $Addresses = Mage::getModel('sales/order_address')->getCollection()->addFieldToSelect('*')->addFieldToFilter('address_type', 'billing');
83
+ foreach($Addresses as $Address){
84
+ $response['customers'][$Address->getId()] = $Address->getData();
85
+ }
86
+ }
87
+ break;
88
+ case 'products':
89
+ if($_ID){
90
+ $Products = Mage::getModel('catalog/product')->load($_ID);
91
+ $response['products'][] = $Products->getData();
92
+ }else{
93
+ $Products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*');
94
+ if($HRS == 'all'){
95
+
96
+ }else{
97
+ $startDate = date('Y-m-d', strtotime('now -'.$HRS.' hours'));
98
+ $finishDate = date('Y-m-d', strtotime('now'));
99
+ $Products->addAttributeToFilter(array(array('attribute' => 'created_at','from' => $startDate,'to' => $finishDate)));
100
+ }
101
+
102
+ foreach($Products as $Product){
103
+ $response['products'][] = $Product->getData();
104
+ }
105
+
106
+ }
107
+ break;
108
+ }
109
+ }else{
110
+ $response['status'] = "error";
111
+ $response['status_message'] = "IP NOT allowed";
112
+ }
113
+
114
+ if($GetParams['debug'] == 'true'){
115
+ echo "<pre>";
116
+ var_dump($response);
117
+ echo "</pre>";
118
+ Mage::getModel('core/cookie')->set('wacsid', '999');
119
+ }else{
120
+ echo json_encode($response);
121
+ }
122
+
123
+ }
124
+ }
app/code/local/Woomio/Tracker/etc/config.xml ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Woomio_Tracker>
5
+ <version>1.0.3</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-0.1.0.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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('general/store_information/name');
10
+
11
+ $SetupCallbackUrl = "https://www.woomio.com/api/Endpoints/RetailerSignup?name=".$Name."&domain=".$Domain."&country=".$Lang."&email=".$Email."&platform=1";
12
+ $Response = file_get_contents($$SetupCallbackUrl);
13
+
14
+ $installer->run($sql);
15
+ $installer->endSetup();
16
+
app/design/frontend/base/default/layout/tracker.xml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
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
+
app/etc/modules/Woomio_Tracker.xml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Woomio_Tracker>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ <version>1.0.3</version>
8
+ </Woomio_Tracker>
9
+ </modules>
10
+ </config>
package.xml ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Woo</name>
4
+ <version>1.0.3</version>
5
+ <stability>stable</stability>
6
+ <license>Open Software License (OSL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Woomio provides increased exposure for retailers through enabling customers to share their purchases on social media.&#xD;
10
+ &#xD;
11
+ Utilise the power of your customers' recommendations</summary>
12
+ <description>Woomio enables your customers to share their purchases - your products - on social media, in return of a discrete commission for every purchase generated. This gives your stores and your products an authentic presence on social media, along with valuable insights on your customers' buying behavior.&#xD;
13
+ &#xD;
14
+ &#xD;
15
+ How does it work?&#xD;
16
+ &#xD;
17
+ 1) When a purchase is being made in your store, an email is sent to the buyer with information about how to share the purchased item on Woomio&#xD;
18
+ &#xD;
19
+ 2) When the item has been shared on Woomio, inspired peers of your customer will visit your shop for more details about similar items&#xD;
20
+ &#xD;
21
+ 3) If a purchase is being made in your store as a result of your customer's post, your customer will be eligible for a 15% commission&#xD;
22
+ &#xD;
23
+ &#xD;
24
+ Compatibility&#xD;
25
+ &#xD;
26
+ Woomio is fully compatible with all Magento versions and modules.</description>
27
+ <notes>Initial version of Woomio</notes>
28
+ <authors><author><name>Woomio</name><user>Woomio</user><email>developer@woomio.com</email></author></authors>
29
+ <date>2015-04-13</date>
30
+ <time>11:08:20</time>
31
+ <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="f18df080c87ae5361658056a9ea81240"/></dir><dir name="etc"><file name="config.xml" hash="0da67848c98a646d966e8eede9291b25"/></dir><dir name="sql"><dir name="tracker_setup"><file name="mysql4-install-0.1.0.php" hash="b7ff9e8463ef8abb150d20f26e56d8f7"/></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="07379cce1ea1287e2b20b8a430016729"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Woomio_Tracker.xml" hash="1b783bbe83a1689af0988765156f0a48"/></dir></target></contents>
32
+ <compatible/>
33
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
34
+ </package>