Wigzo_AutoCode - Version 0.2.2

Version Notes

Wigzo Push is a plugin that allows you to Send and Track Web Push Notification through your Magento Store. It allows you to take Browser Opt in from people visiting your store and then Send and Track browser notifications to bring people back to your store, even when they are not browsing the site. It allows your store to re-engage your most loyal customers with targeted push notifications

Download this release

Release Info

Developer wigzo
Extension Wigzo_AutoCode
Version 0.2.2
Comparing to
See all releases


Code changes from version 0.2.1 to 0.2.2

app/code/local/Wigzo/AutoCode/CodeBlock/Myblock.php CHANGED
@@ -4,14 +4,14 @@ class Wigzo_AutoCode_CodeBlock_Myblock extends Mage_Core_Block_Template
4
  public function getWigzoData()
5
  {
6
  $product = Mage::registry('current_product');
7
- $wigzodata = array ();
8
  $wigzodata["standardhost"] = true;
9
  $wigzodata["host"] = "https://app.wigzo.com";
10
  $wigzodata["tracker"] = "https://tracker.wigzopush.com";
11
- if (file_exists ("/tmp/wigzomode")) {
12
  $wigzodata["standardhost"] = false;
13
- $wigzodata["host"] = trim (file_get_contents ("/tmp/wigzomode"));
14
- $wigzodata["tracker"] = trim (file_get_contents ("/tmp/wigzomode"));
15
  }
16
  $wigzodata["enabled"] = true;
17
  $wigzodata["suppression"] = "";
@@ -20,7 +20,7 @@ class Wigzo_AutoCode_CodeBlock_Myblock extends Mage_Core_Block_Template
20
  $wigzodata["browserpush"] = true;
21
  $wigzodata["viahttps"] = true; // Need user input
22
  $wigzodata["subpath"] = "/index.php";
23
- $wigzodata["currency"] = Mage::helper('core')->currency($product!=null?$product->getFinalPrice():"", true, false);
24
 
25
  $is_rewriting = Mage::getStoreConfig('web/seo/use_rewrites');
26
  if ($is_rewriting) {
@@ -36,9 +36,9 @@ class Wigzo_AutoCode_CodeBlock_Myblock extends Mage_Core_Block_Template
36
  $suppression = Mage::getStoreConfig('admin/wigzo/suppression');
37
  if (NULL != $suppression) {
38
  $currentServerName = Mage::app()->getFrontController()->getRequest()->getServer('SERVER_NAME');
39
- $blocked = explode (",", $suppression);
40
 
41
- for ($i = 0 ; $i < count ($blocked) ; $i++) {
42
  if ($blocked[$i] == $currentServerName) {
43
  $wigzodata["enabled"] = false;
44
  return $wigzodata;
@@ -65,7 +65,7 @@ class Wigzo_AutoCode_CodeBlock_Myblock extends Mage_Core_Block_Template
65
  if (Mage::getSingleton('customer/session')->isLoggedIn()) {
66
  $customer = Mage::getSingleton('customer/session')->getCustomer();
67
  $customerData = Mage::getModel('customer/customer')->load($customer->getId())->getData();
68
- $wigzodata["userIdentifier"]= $customerData["email"];
69
  }
70
 
71
  $orgId = Mage::getStoreConfig('admin/wigzo/orgId');
@@ -74,7 +74,7 @@ class Wigzo_AutoCode_CodeBlock_Myblock extends Mage_Core_Block_Template
74
  $wigzodata["product"] = $product;
75
 
76
  //var_dump ($wigzodata);
77
-
78
  return $wigzodata;
79
  }
80
  }
4
  public function getWigzoData()
5
  {
6
  $product = Mage::registry('current_product');
7
+ $wigzodata = array();
8
  $wigzodata["standardhost"] = true;
9
  $wigzodata["host"] = "https://app.wigzo.com";
10
  $wigzodata["tracker"] = "https://tracker.wigzopush.com";
11
+ if (file_exists("/tmp/wigzomode")) {
12
  $wigzodata["standardhost"] = false;
13
+ $wigzodata["host"] = trim(file_get_contents("/tmp/wigzomode"));
14
+ $wigzodata["tracker"] = trim(file_get_contents("/tmp/wigzomode"));
15
  }
16
  $wigzodata["enabled"] = true;
17
  $wigzodata["suppression"] = "";
20
  $wigzodata["browserpush"] = true;
21
  $wigzodata["viahttps"] = true; // Need user input
22
  $wigzodata["subpath"] = "/index.php";
23
+ $wigzodata["currency"] = Mage::helper('core')->currency($product != null ? $product->getFinalPrice() : "", true, false);
24
 
25
  $is_rewriting = Mage::getStoreConfig('web/seo/use_rewrites');
26
  if ($is_rewriting) {
36
  $suppression = Mage::getStoreConfig('admin/wigzo/suppression');
37
  if (NULL != $suppression) {
38
  $currentServerName = Mage::app()->getFrontController()->getRequest()->getServer('SERVER_NAME');
39
+ $blocked = explode(",", $suppression);
40
 
41
+ for ($i = 0; $i < count($blocked); $i++) {
42
  if ($blocked[$i] == $currentServerName) {
43
  $wigzodata["enabled"] = false;
44
  return $wigzodata;
65
  if (Mage::getSingleton('customer/session')->isLoggedIn()) {
66
  $customer = Mage::getSingleton('customer/session')->getCustomer();
67
  $customerData = Mage::getModel('customer/customer')->load($customer->getId())->getData();
68
+ $wigzodata["userIdentifier"] = $customerData["email"];
69
  }
70
 
71
  $orgId = Mage::getStoreConfig('admin/wigzo/orgId');
74
  $wigzodata["product"] = $product;
75
 
76
  //var_dump ($wigzodata);
77
+
78
  return $wigzodata;
79
  }
80
  }
app/code/local/Wigzo/AutoCode/Model/Observer.php CHANGED
@@ -1,46 +1,42 @@
1
  <?php
 
2
  class Wigzo_AutoCode_Model_Observer
3
  {
4
 
5
  public function productUpdated(Varien_Event_Observer $observer)
6
  {
7
- //Mage::dispatchEvent('admin_session_user_login_success', array('user'=>$user));
8
- //$user = $observer->getEvent()->getUser();
9
- //$user->doSomething();
10
 
11
  $enabled = Mage::getStoreConfig('admin/wigzo/enabled');
12
  if ($enabled == NULL || $enabled == "false") {
13
- Mage::log ("Wigzo Plugin is not Enabled! not writing updated.", null, "wigzo-updates.log");
14
  return;
15
  }
16
 
17
  $wigzo_host = "https://app.wigzo.com";
18
- if (file_exists ("/tmp/wigzomode")) {
19
- $wigzo_host = trim (file_get_contents ("/tmp/wigzomode"));
20
  }
21
 
22
- //$currency = str_replace ("100.00", "", Mage::helper('core')->currency("100", true, false));
23
  $orgToken = Mage::getStoreConfig('admin/wigzo/orgId');
24
 
25
  $product = $observer->getEvent()->getProduct();
26
 
27
- $postdata = array ();
28
 
29
- //$postdata["canonical"] = $product->getSku();
30
  $postdata["name"] = $product->getName();
31
  $postdata["productId"] = $product->getSku();
32
  $postdata["title"] = $product->getTitle();
33
  $postdata["image"] = $product->getImageUrl();
34
- $postdata["price"] = Mage::helper('core')->currency($product!=null?$product->getFinalPrice():"", true, false);
35
 
36
- $ch = curl_init ();
37
- curl_setopt ($ch, CURLOPT_URL,"$wigzo_host/api/v1/product/" . $orgToken);
38
- curl_setopt ($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
39
- curl_setopt ($ch, CURLOPT_POST, 1);
40
- curl_setopt ($ch, CURLOPT_POSTFIELDS, json_encode ($postdata));
41
- curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
42
- $server_output = curl_exec ($ch);
43
- curl_close ($ch);
44
 
45
  // Write a new line to var/log/product-updates.log
46
  Mage::log(
@@ -51,17 +47,18 @@ class Wigzo_AutoCode_Model_Observer
51
 
52
  }
53
 
54
- public function productAddedToCart($observer){
 
55
 
56
  $enabled = Mage::getStoreConfig('admin/wigzo/enabled');
57
  if ($enabled == NULL || $enabled == "false") {
58
- Mage::log ("Wigzo Plugin is not Enabled! not writing updated.", null, "wigzo-updates.log");
59
  return;
60
  }
61
 
62
  $wigzo_host = "https://app.wigzo.com";
63
- if (file_exists ("/tmp/wigzomode")) {
64
- $wigzo_host = trim (file_get_contents ("/tmp/wigzomode"));
65
  }
66
 
67
  $cookieID = Mage::getSingleton('core/cookie')->get()['WIGZO_LEARNER_ID'];
@@ -79,7 +76,7 @@ class Wigzo_AutoCode_Model_Observer
79
  $product = $observer->getEvent()->getProduct();
80
 
81
  //Post data to be sent in the request.
82
- $postdata = array ();
83
  $postdata["canonical"] = $product->getProductUrl();
84
  $postdata["name"] = $product->getName();
85
  $postdata["productId"] = $product->getSku();
@@ -88,20 +85,20 @@ class Wigzo_AutoCode_Model_Observer
88
  $postdata['lang'] = $lang;
89
  $postdata['eventCategory'] = $eventCategory;
90
  $postdata['_'] = $timestamp;
91
- $postdata['e'] ="";
92
  $postdata['pageuuid'] = $pageUuid;
93
- $postdata['eventval']= $product->getProductUrl();
94
  $postdata['source'] = $source;
95
- $postdata["price"] = Mage::helper('core')->currency($product!=null?$product->getFinalPrice():"", true, false);
96
 
97
- $ch = curl_init ();
98
- curl_setopt ($ch, CURLOPT_URL,"$wigzo_host/learn/" . $orgToken ."/addtocart/".$cookieID );
99
- curl_setopt ($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
100
- curl_setopt ($ch, CURLOPT_POST, 1);
101
- curl_setopt ($ch, CURLOPT_POSTFIELDS, json_encode ($postdata));
102
- curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
103
- $server_output = curl_exec ($ch);
104
- curl_close ($ch);
105
 
106
  // Write a new line to var/log/product-updates.log
107
  Mage::log(
@@ -113,17 +110,18 @@ class Wigzo_AutoCode_Model_Observer
113
  }
114
 
115
 
116
- public function productBuy($observer){
 
117
 
118
  $enabled = Mage::getStoreConfig('admin/wigzo/enabled');
119
  if ($enabled == NULL || $enabled == "false") {
120
- Mage::log ("Wigzo Plugin is not Enabled! not writing updated.", null, "wigzo-updates.log");
121
  return;
122
  }
123
 
124
  $wigzo_host = "https://app.wigzo.com";
125
- if (file_exists ("/tmp/wigzomode")) {
126
- $wigzo_host = trim (file_get_contents ("/tmp/wigzomode"));
127
  }
128
 
129
  $cookieID = Mage::getSingleton('core/cookie')->get()['WIGZO_LEARNER_ID'];
@@ -139,11 +137,11 @@ class Wigzo_AutoCode_Model_Observer
139
 
140
  $product_id = $readConnection->fetchAll($query);
141
  $eventVal = array();
142
- $i=0;
143
- foreach($product_id as $temp){
144
- $product = $temp=Mage::getModel('catalog/product')->load($temp);
145
- $eventVal[$i]= $product->getProductUrl();
146
- $i++;
147
  }
148
 
149
  //$currency = str_replace ("100.00", "", Mage::helper('core')->currency("100", true, false));
@@ -155,23 +153,23 @@ class Wigzo_AutoCode_Model_Observer
155
  $source = "web";
156
 
157
  //Post data to be sent in the request.
158
- $postdata = array ();
159
  $postdata['lang'] = $lang;
160
  $postdata['eventCategory'] = $eventCategory;
161
  $postdata['_'] = $timestamp;
162
- $postdata['e'] ="";
163
  $postdata['pageuuid'] = $pageUuid;
164
- $postdata['eventval']= $eventVal;
165
  $postdata['source'] = $source;
166
 
167
- $ch = curl_init ();
168
- curl_setopt ($ch, CURLOPT_URL,"$wigzo_host/learn/" . $orgToken ."/buy/".$cookieID );
169
- curl_setopt ($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
170
- curl_setopt ($ch, CURLOPT_POST, 1);
171
- curl_setopt ($ch, CURLOPT_POSTFIELDS, json_encode ($postdata));
172
- curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
173
- $server_output = curl_exec ($ch);
174
- curl_close ($ch);
175
 
176
 
177
  // Write a new line to var/log/product-updates.log
1
  <?php
2
+
3
  class Wigzo_AutoCode_Model_Observer
4
  {
5
 
6
  public function productUpdated(Varien_Event_Observer $observer)
7
  {
 
 
 
8
 
9
  $enabled = Mage::getStoreConfig('admin/wigzo/enabled');
10
  if ($enabled == NULL || $enabled == "false") {
11
+ Mage::log("Wigzo Plugin is not Enabled! not writing updated.", null, "wigzo-updates.log");
12
  return;
13
  }
14
 
15
  $wigzo_host = "https://app.wigzo.com";
16
+ if (file_exists("/tmp/wigzomode")) {
17
+ $wigzo_host = trim(file_get_contents("/tmp/wigzomode"));
18
  }
19
 
 
20
  $orgToken = Mage::getStoreConfig('admin/wigzo/orgId');
21
 
22
  $product = $observer->getEvent()->getProduct();
23
 
24
+ $postdata = array();
25
 
 
26
  $postdata["name"] = $product->getName();
27
  $postdata["productId"] = $product->getSku();
28
  $postdata["title"] = $product->getTitle();
29
  $postdata["image"] = $product->getImageUrl();
30
+ $postdata["price"] = Mage::helper('core')->currency($product != null ? $product->getFinalPrice() : "", true, false);
31
 
32
+ $ch = curl_init();
33
+ curl_setopt($ch, CURLOPT_URL, "$wigzo_host/api/v1/product/" . $orgToken);
34
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
35
+ curl_setopt($ch, CURLOPT_POST, 1);
36
+ curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($postdata));
37
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
38
+ $server_output = curl_exec($ch);
39
+ curl_close($ch);
40
 
41
  // Write a new line to var/log/product-updates.log
42
  Mage::log(
47
 
48
  }
49
 
50
+ public function productAddedToCart($observer)
51
+ {
52
 
53
  $enabled = Mage::getStoreConfig('admin/wigzo/enabled');
54
  if ($enabled == NULL || $enabled == "false") {
55
+ Mage::log("Wigzo Plugin is not Enabled! not writing updated.", null, "wigzo-updates.log");
56
  return;
57
  }
58
 
59
  $wigzo_host = "https://app.wigzo.com";
60
+ if (file_exists("/tmp/wigzomode")) {
61
+ $wigzo_host = trim(file_get_contents("/tmp/wigzomode"));
62
  }
63
 
64
  $cookieID = Mage::getSingleton('core/cookie')->get()['WIGZO_LEARNER_ID'];
76
  $product = $observer->getEvent()->getProduct();
77
 
78
  //Post data to be sent in the request.
79
+ $postdata = array();
80
  $postdata["canonical"] = $product->getProductUrl();
81
  $postdata["name"] = $product->getName();
82
  $postdata["productId"] = $product->getSku();
85
  $postdata['lang'] = $lang;
86
  $postdata['eventCategory'] = $eventCategory;
87
  $postdata['_'] = $timestamp;
88
+ $postdata['e'] = "";
89
  $postdata['pageuuid'] = $pageUuid;
90
+ $postdata['eventval'] = $product->getProductUrl();
91
  $postdata['source'] = $source;
92
+ $postdata["price"] = Mage::helper('core')->currency($product != null ? $product->getFinalPrice() : "", true, false);
93
 
94
+ $ch = curl_init();
95
+ curl_setopt($ch, CURLOPT_URL, "$wigzo_host/learn/" . $orgToken . "/addtocart/" . $cookieID);
96
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
97
+ curl_setopt($ch, CURLOPT_POST, 1);
98
+ curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($postdata));
99
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
100
+ $server_output = curl_exec($ch);
101
+ curl_close($ch);
102
 
103
  // Write a new line to var/log/product-updates.log
104
  Mage::log(
110
  }
111
 
112
 
113
+ public function productBuy($observer)
114
+ {
115
 
116
  $enabled = Mage::getStoreConfig('admin/wigzo/enabled');
117
  if ($enabled == NULL || $enabled == "false") {
118
+ Mage::log("Wigzo Plugin is not Enabled! not writing updated.", null, "wigzo-updates.log");
119
  return;
120
  }
121
 
122
  $wigzo_host = "https://app.wigzo.com";
123
+ if (file_exists("/tmp/wigzomode")) {
124
+ $wigzo_host = trim(file_get_contents("/tmp/wigzomode"));
125
  }
126
 
127
  $cookieID = Mage::getSingleton('core/cookie')->get()['WIGZO_LEARNER_ID'];
137
 
138
  $product_id = $readConnection->fetchAll($query);
139
  $eventVal = array();
140
+ $i = 0;
141
+ foreach ($product_id as $temp) {
142
+ $product = $temp = Mage::getModel('catalog/product')->load($temp);
143
+ $eventVal[$i] = $product->getProductUrl();
144
+ $i++;
145
  }
146
 
147
  //$currency = str_replace ("100.00", "", Mage::helper('core')->currency("100", true, false));
153
  $source = "web";
154
 
155
  //Post data to be sent in the request.
156
+ $postdata = array();
157
  $postdata['lang'] = $lang;
158
  $postdata['eventCategory'] = $eventCategory;
159
  $postdata['_'] = $timestamp;
160
+ $postdata['e'] = "";
161
  $postdata['pageuuid'] = $pageUuid;
162
+ $postdata['eventval'] = $eventVal;
163
  $postdata['source'] = $source;
164
 
165
+ $ch = curl_init();
166
+ curl_setopt($ch, CURLOPT_URL, "$wigzo_host/learn/" . $orgToken . "/buy/" . $cookieID);
167
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
168
+ curl_setopt($ch, CURLOPT_POST, 1);
169
+ curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($postdata));
170
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
171
+ $server_output = curl_exec($ch);
172
+ curl_close($ch);
173
 
174
 
175
  // Write a new line to var/log/product-updates.log
app/code/local/Wigzo/AutoCode/etc/config.xml CHANGED
@@ -133,7 +133,7 @@
133
  <frontName>gcm_manifest.json</frontName>
134
  </args>
135
  </autocode>
136
- </routers>
137
 
138
  </frontend>
139
 
133
  <frontName>gcm_manifest.json</frontName>
134
  </args>
135
  </autocode>
136
+ </routers>
137
 
138
  </frontend>
139
 
app/design/adminhtml/default/default/template/autocode/autocodebackend.phtml CHANGED
@@ -1,98 +1,85 @@
1
  <script type="text/javascript">
2
- window.wigzoHelpers = {};
3
- window.wigzoHelpers.xhr = function (method, path, opts) {
4
- var successFn = opts.success || function () {};
5
- var errorFn = opts.error || function () {};
6
- var data = opts.data || {};
7
-
8
- if (method == "POST") {
9
- data = JSON.stringify (data);
10
- }
11
-
12
- var wxhr = typeof XMLHttpRequest != 'undefined' ? new XMLHttpRequest() : new ActiveXObject ('Microsoft.XMLHTTP');
13
- if (! (method == 'GET' || method == 'POST')) {
14
- errorFn (21, "Only GET or POST is allowed!");
15
- return;
16
- }
17
-
18
- if (method == "GET") {
19
- var out = new Array();
20
- for (key in data) {
21
- out.push (key + '=' + encodeURIComponent(data[key]));
22
  }
23
- params = out.join('&');
24
- path = path + "?" + params;
25
- }
26
-
27
- wxhr.open (method, path, true);
28
- //wxhr.setRequestHeader ("Content-Type", "application/json;charset=UTF-8");
29
-
30
- wxhr.onreadystatechange = function () {
31
- if (wxhr.readyState == 4 && wxhr.status == 200) {
32
- var textResp = wxhr.responseText;
33
- if (opts.hasOwnProperty ('expected') && opts['expected'] == 'json') {
34
- try {
35
- textResp = JSON.parse (textResp);
36
- } catch (err) {
37
- errorFn (20, "Cannot Parse JSON");
38
- return;
 
 
 
 
 
 
 
 
 
39
  }
 
40
  }
41
- successFn (textResp);
42
  }
43
- }
44
-
45
- if (method == "POST") {
46
- wxhr.send (data);
47
- } else {
48
- wxhr.send (null);
49
- }
50
-
51
- };
52
-
53
  </script>
54
  <iframe id="wigzoconfigframe" style="border: 0; width: 100%; height: 500px;" src=""></iframe>
55
-
56
  <script type="text/javascript">
57
- if (window.location.port == "80" || window.location.port == "") {
58
- var iHost = window.location.hostname;
59
- } else {
60
- var iHost = window.location.hostname + ":" + window.location.port;
61
- }
62
- document.getElementById ("wigzoconfigframe").src = "<?php echo $this->getWigzoHost(); ?>/integration/magento/frame/" + iHost + "/" + "<?php echo $this->getAuthtoken(); ?>";
63
-
64
- window.addEventListener ('message', function (event) {
65
- debugger;
66
- var eventData = event.data;
67
- var aquired_token = eventData.key;
68
- if (! aquired_token) {
69
- console.error ("Cannot GET static key from Wigzo!");
70
- return;
71
- }
72
-
73
- var params = {
74
- via: "xmlhttp",
75
- token: aquired_token,
76
- enabled: eventData.enabled,
77
- orgId: eventData.orgIdentifier,
78
- viahttps: eventData.viahttps
79
- };
80
-
81
- for (var k in eventData.features) {
82
- params[k] = eventData.features[k];
83
  }
84
-
85
-
86
- window.wigzoHelpers.xhr ('GET', '.', {
87
- expected: 'json',
88
- data: params,
89
- success: function (resp) {
90
- console.log ("Successfully, Saved Wigzo Configuration!");
91
- },
92
- error: function (code, msg) {
93
- console.error ("Cannot save Wigzo config: " + code + ": " + msg);
 
 
 
 
 
 
 
 
94
  }
 
 
 
 
 
 
 
 
 
 
95
  });
96
- });
97
-
98
- </script>
1
  <script type="text/javascript">
2
+ window.wigzoHelpers = {};
3
+ window.wigzoHelpers.xhr = function (method, path, opts) {
4
+ var successFn = opts.success || function () {
5
+ };
6
+ var errorFn = opts.error || function () {
7
+ };
8
+ var data = opts.data || {};
9
+ if (method == "POST") {
10
+ data = JSON.stringify(data);
 
 
 
 
 
 
 
 
 
 
 
11
  }
12
+ var wxhr = typeof XMLHttpRequest != 'undefined' ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
13
+ if (!(method == 'GET' || method == 'POST')) {
14
+ errorFn(21, "Only GET or POST is allowed!");
15
+ return;
16
+ }
17
+ if (method == "GET") {
18
+ var out = new Array();
19
+ for (key in data) {
20
+ out.push(key + '/' + encodeURIComponent(data[key]));
21
+ }
22
+ params = out.join('/');
23
+ path = path + "/" + params;
24
+ }
25
+ wxhr.open(method, path, true);
26
+ //wxhr.setRequestHeader ("Content-Type", "application/json;charset=UTF-8");
27
+ wxhr.onreadystatechange = function () {
28
+ if (wxhr.readyState == 4 && wxhr.status == 200) {
29
+ var textResp = wxhr.responseText;
30
+ if (opts.hasOwnProperty('expected') && opts['expected'] == 'json') {
31
+ try {
32
+ textResp = JSON.parse(textResp);
33
+ } catch (err) {
34
+ errorFn(20, "Cannot Parse JSON");
35
+ return;
36
+ }
37
  }
38
+ successFn(textResp);
39
  }
 
40
  }
41
+ if (method == "POST") {
42
+ wxhr.send(data);
43
+ } else {
44
+ wxhr.send(null);
45
+ }
46
+ };
 
 
 
 
47
  </script>
48
  <iframe id="wigzoconfigframe" style="border: 0; width: 100%; height: 500px;" src=""></iframe>
 
49
  <script type="text/javascript">
50
+ if (window.location.port == "80" || window.location.port == "") {
51
+ var iHost = window.location.hostname;
52
+ } else {
53
+ var iHost = window.location.hostname + ":" + window.location.port;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  }
55
+ document.getElementById("wigzoconfigframe").src = "<?php echo $this->getWigzoHost(); ?>/integration/magento/frame/" + iHost + "/" + "<?php echo $this->getAuthtoken(); ?>";
56
+ window.addEventListener('message', function (event) {
57
+ debugger;
58
+ var eventData = event.data;
59
+ var aquired_token = eventData.key;
60
+ if (!aquired_token) {
61
+ console.error("Cannot GET static key from Wigzo!");
62
+ return;
63
+ }
64
+ var params = {
65
+ via: "xmlhttp",
66
+ token: aquired_token,
67
+ enabled: eventData.enabled,
68
+ orgId: eventData.orgIdentifier,
69
+ viahttps: eventData.viahttps
70
+ };
71
+ for (var k in eventData.features) {
72
+ params[k] = eventData.features[k];
73
  }
74
+ window.wigzoHelpers.xhr('GET', '.', {
75
+ expected: 'json',
76
+ data: params,
77
+ success: function (resp) {
78
+ console.log("Successfully, Saved Wigzo Configuration!");
79
+ },
80
+ error: function (code, msg) {
81
+ console.error("Cannot save Wigzo config: " + code + ": " + msg);
82
+ }
83
+ });
84
  });
85
+ </script>
 
 
app/design/frontend/base/default/template/scriptblock/head.phtml CHANGED
@@ -1,41 +1,63 @@
1
  <?php $wigzo = $this->getWigzoData(); ?>
2
  <script>
3
- window.wigzo = (function(module){ module.ready = function () { module.searchStartVal = module.$("#search_mini_form input[type=text]").val (); module.$("#search_mini_form").submit (function (e) { var currentval = module.$(e.currentTarget).find ("input[type=text]").val(); if (currentval == module.searchStartVal) { return; } module.track ("search", currentval || ""); }); }; return module; } (window.wigzo || {}));
 
 
 
 
 
 
 
 
 
 
 
 
4
  </script>
5
 
6
  <?php if ($wigzo["enabled"]) { ?>
7
  <?php if ($wigzo["product"] != NULL) { ?>
8
- <meta property="wg:title" content="<?php echo $wigzo["product"]->getName()!=null?$wigzo["product"]->getName():""; ?>" />
9
- <meta property="wg:productId" content="<?php echo $wigzo["product"]->getSku()!=null?$wigzo["product"]->getSku():""; ?>" />
10
- <meta property="wg:description" content="<?php echo $wigzo["product"]->getDescription()!=null?$wigzo["product"]->getDescription():""; ?>" />
11
- <meta property="wg:url" content="<?php echo $wigzo["product"]->getProductUrl()!=null?$wigzo["product"]->getProductUrl():""; ?>" />
12
- <link rel="canonical" href="<?php echo $wigzo["product"]->getProductUrl()!=null?$wigzo["product"]->getProductUrl():""; ?>" />
13
- <meta property="wg:image" content="<?php echo $wigzo["product"]->getImageUrl()!=null?$wigzo["product"]->getImageUrl():""; ?>" />
14
- <meta property="wg:price" content="<?php echo $wigzo["currency"] !=null?$wigzo["currency"]:""; ?>" />
 
 
 
 
 
 
15
  <?php } ?>
16
  <?php if ($wigzo["browserpush"]) { ?>
17
 
18
- <!-- Wigzo Browser Push Support: Added by Magento Extension -->
19
- <?php if ($wigzo["viahttps"]) { ?>
20
- <script type="text/javascript">
21
- window.wigzo = (function (module) {
22
- module.wigzoGcmAutoSubscribe = true;
23
- return module;
24
- } (window.wigzo || {}));
25
- </script>
26
 
27
- <link rel="manifest" href="<?php echo $wigzo["subpath"]; ?>/gcm_manifest.json" />
28
- <script async src="<?php echo $wigzo["tracker"]; ?>/wigzopush_manager.js?orgtoken=<?php echo $wigzo["orgidentifier"]; ?>&subpath=<?php echo urlencode ($wigzo["subpath"]);?>" type="text/javascript"></script>
29
- <?php } else { ?>
30
- <script type="text/javascript">
31
- window.wigzo = (function(module){
32
- module.httpGcmShowDialog = true;
33
- return module;
34
- }(window.wigzo || {}));
35
- </script>
36
- <script async src="<?php echo $wigzo["tracker"]; ?>/gcm_http_subscribe.js?orgtoken=<?php echo $wigzo["orgidentifier"]; ?>" type="text/javascript"></script>
37
- <?php } ?>
38
- <!-- End Wigzo Browser Push Support -->
 
 
 
 
39
 
40
- <?php } ?>
41
  <?php } ?>
1
  <?php $wigzo = $this->getWigzoData(); ?>
2
  <script>
3
+ window.wigzo = (function (module) {
4
+ module.ready = function () {
5
+ module.searchStartVal = module.$("#search_mini_form input[type=text]").val();
6
+ module.$("#search_mini_form").submit(function (e) {
7
+ var currentval = module.$(e.currentTarget).find("input[type=text]").val();
8
+ if (currentval == module.searchStartVal) {
9
+ return;
10
+ }
11
+ module.track("search", currentval || "");
12
+ });
13
+ };
14
+ return module;
15
+ }(window.wigzo || {}));
16
  </script>
17
 
18
  <?php if ($wigzo["enabled"]) { ?>
19
  <?php if ($wigzo["product"] != NULL) { ?>
20
+ <meta property="wg:title"
21
+ content="<?php echo $wigzo["product"]->getName() != null ? $wigzo["product"]->getName() : ""; ?>"/>
22
+ <meta property="wg:productId"
23
+ content="<?php echo $wigzo["product"]->getSku() != null ? $wigzo["product"]->getSku() : ""; ?>"/>
24
+ <meta property="wg:description"
25
+ content="<?php echo $wigzo["product"]->getDescription() != null ? $wigzo["product"]->getDescription() : ""; ?>"/>
26
+ <meta property="wg:url"
27
+ content="<?php echo $wigzo["product"]->getProductUrl() != null ? $wigzo["product"]->getProductUrl() : ""; ?>"/>
28
+ <link rel="canonical"
29
+ href="<?php echo $wigzo["product"]->getProductUrl() != null ? $wigzo["product"]->getProductUrl() : ""; ?>"/>
30
+ <meta property="wg:image"
31
+ content="<?php echo $wigzo["product"]->getImageUrl() != null ? $wigzo["product"]->getImageUrl() : ""; ?>"/>
32
+ <meta property="wg:price" content="<?php echo $wigzo["currency"] != null ? $wigzo["currency"] : ""; ?>"/>
33
  <?php } ?>
34
  <?php if ($wigzo["browserpush"]) { ?>
35
 
36
+ <!-- Wigzo Browser Push Support: Added by Magento Extension -->
37
+ <?php if ($wigzo["viahttps"]) { ?>
38
+ <script type="text/javascript">
39
+ window.wigzo = (function (module) {
40
+ module.wigzoGcmAutoSubscribe = true;
41
+ return module;
42
+ }(window.wigzo || {}));
43
+ </script>
44
 
45
+ <link rel="manifest" href="<?php echo $wigzo["subpath"]; ?>/gcm_manifest.json"/>
46
+ <script async
47
+ src="<?php echo $wigzo["tracker"]; ?>/wigzopush_manager.js?orgtoken=<?php echo $wigzo["orgidentifier"]; ?>&subpath=<?php echo urlencode($wigzo["subpath"]); ?>"
48
+ type="text/javascript"></script>
49
+ <?php } else { ?>
50
+ <script type="text/javascript">
51
+ window.wigzo = (function (module) {
52
+ module.httpGcmShowDialog = true;
53
+ return module;
54
+ }(window.wigzo || {}));
55
+ </script>
56
+ <script async
57
+ src="<?php echo $wigzo["tracker"]; ?>/gcm_http_subscribe.js?orgtoken=<?php echo $wigzo["orgidentifier"]; ?>"
58
+ type="text/javascript"></script>
59
+ <?php } ?>
60
+ <!-- End Wigzo Browser Push Support -->
61
 
62
+ <?php } ?>
63
  <?php } ?>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Wigzo_AutoCode</name>
4
- <version>0.2.1</version>
5
  <stability>stable</stability>
6
  <license>GNU</license>
7
  <channel>community</channel>
@@ -10,9 +10,9 @@
10
  <description>Wigzo Push is a plugin that allows you to Send and Track Web Push Notification through your Magento Store. It allows you to take Browser Opt in from people visiting your store and then Send and Track browser notifications to bring people back to your store, even when they are not browsing the site. It allows your store to re-engage your most loyal customers with targeted push notifications</description>
11
  <notes>Wigzo Push is a plugin that allows you to Send and Track Web Push Notification through your Magento Store. It allows you to take Browser Opt in from people visiting your store and then Send and Track browser notifications to bring people back to your store, even when they are not browsing the site. It allows your store to re-engage your most loyal customers with targeted push notifications</notes>
12
  <authors><author><name>wigzo</name><user>wigzo</user><email>info@wigo.com</email></author><author><name>shamail</name><user>shamail</user><email>shamail@wigzo.com</email></author></authors>
13
- <date>2017-05-24</date>
14
- <time>13:47:05</time>
15
- <contents><target name="magelocal"><dir name="Wigzo"><dir name="AutoCode"><dir name="Block"><dir name="Adminhtml"><file name="Autocodebackend.php" hash="da50f2305de5c4e7163f7dfb7459be32"/></dir><file name="Index.php" hash="88b27827847cb37a5ab250ad7b0b6fd5"/><file name=".DS_Store" hash="b0fd28d4d518e950dd364c245b6cc36c"/></dir><dir name="CodeBlock"><file name="Myblock.php" hash="fc6a2be1ba81ed3900b8fa7775a1766b"/></dir><dir name="Helper"><file name="Data.php" hash="43aff13a0e71fd995800fa1f9178c659"/></dir><dir name="Model"><file name="Observer.php" hash="0aa6a1320115acad7e731c136ae14ecc"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="AutocodebackendController.php" hash="5a0d87a3ce03fe5875da16540453ce0d"/></dir><file name="IndexController.php" hash="75f185ff119fa5c6ed7c67dfe2a090c7"/><file name=".DS_Store" hash="b0fd28d4d518e950dd364c245b6cc36c"/></dir><dir name="etc"><file name="config.xml" hash="8134f60205e5a067d145fe42753f0bbf"/><file name="system.xml" hash="92e358822c1457b0c170b8f61837d413"/></dir><file name=".DS_Store" hash="e1cd85e1ad3e575f3343c82cbc563116"/></dir><dir name="ServiceWorker"><dir name="Helper"><file name="Data.php" hash="43aff13a0e71fd995800fa1f9178c659"/></dir><dir name="controllers"><file name="IndexController.php" hash="a3627ab1f94a5bfe1a8b9cc172867df2"/></dir><dir name="etc"><file name="config.xml" hash="7ff3615eb92a706dc4b2b19c9a1ccced"/></dir></dir><file name=".DS_Store" hash="d20f5483213a4800451c37408874a2dd"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="autocode.xml" hash="2aa2dbb52397cc65a59ac67e4e3afd66"/></dir><dir name="template"><dir name="autocode"><file name="autocodebackend.phtml" hash="8f97de1bbc67ca5f11b5b172ef5b5342"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="scriptblock.xml" hash="51512b2845d56dafa3028e8892702a76"/></dir><dir name="template"><dir name="scriptblock"><file name="foot.phtml" hash="2ded2491adf32d8157b8c6d5ec0b7726"/><file name="head.phtml" hash="a5ca4f111597868eb88302c356c2d9fe"/><file name="index.phtml" hash="da91307168404679f859274c2bb878b9"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Wigzo_AutoCode.xml" hash="fba2c2a20f4dad9b72a67f8876465906"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.4.0</min><max>5.9.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Wigzo_AutoCode</name>
4
+ <version>0.2.2</version>
5
  <stability>stable</stability>
6
  <license>GNU</license>
7
  <channel>community</channel>
10
  <description>Wigzo Push is a plugin that allows you to Send and Track Web Push Notification through your Magento Store. It allows you to take Browser Opt in from people visiting your store and then Send and Track browser notifications to bring people back to your store, even when they are not browsing the site. It allows your store to re-engage your most loyal customers with targeted push notifications</description>
11
  <notes>Wigzo Push is a plugin that allows you to Send and Track Web Push Notification through your Magento Store. It allows you to take Browser Opt in from people visiting your store and then Send and Track browser notifications to bring people back to your store, even when they are not browsing the site. It allows your store to re-engage your most loyal customers with targeted push notifications</notes>
12
  <authors><author><name>wigzo</name><user>wigzo</user><email>info@wigo.com</email></author><author><name>shamail</name><user>shamail</user><email>shamail@wigzo.com</email></author></authors>
13
+ <date>2017-05-25</date>
14
+ <time>13:25:23</time>
15
+ <contents><target name="magelocal"><dir name="Wigzo"><dir name="AutoCode"><dir name="Block"><dir name="Adminhtml"><file name="Autocodebackend.php" hash="da50f2305de5c4e7163f7dfb7459be32"/></dir><file name="Index.php" hash="88b27827847cb37a5ab250ad7b0b6fd5"/><file name=".DS_Store" hash="b0fd28d4d518e950dd364c245b6cc36c"/></dir><dir name="CodeBlock"><file name="Myblock.php" hash="70f7ca117ef7a3f39c7ef723e2477cc1"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="AutocodebackendController.php" hash="5a0d87a3ce03fe5875da16540453ce0d"/></dir><file name="IndexController.php" hash="75f185ff119fa5c6ed7c67dfe2a090c7"/><file name=".DS_Store" hash="b0fd28d4d518e950dd364c245b6cc36c"/></dir><dir name="etc"><file name="config.xml" hash="40efbeee0f1ea48d1d7e5be5968443a2"/><file name="system.xml" hash="92e358822c1457b0c170b8f61837d413"/></dir><dir name="Helper"><file name="Data.php" hash="43aff13a0e71fd995800fa1f9178c659"/></dir><dir name="Model"><file name="Observer.php" hash="51583a6def9fe583484d04744bbb0088"/></dir><file name=".DS_Store" hash="e1cd85e1ad3e575f3343c82cbc563116"/></dir><dir name="ServiceWorker"><dir name="controllers"><file name="IndexController.php" hash="a3627ab1f94a5bfe1a8b9cc172867df2"/></dir><dir name="etc"><file name="config.xml" hash="7ff3615eb92a706dc4b2b19c9a1ccced"/></dir><dir name="Helper"><file name="Data.php" hash="43aff13a0e71fd995800fa1f9178c659"/></dir></dir><file name=".DS_Store" hash="d20f5483213a4800451c37408874a2dd"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="autocode.xml" hash="2aa2dbb52397cc65a59ac67e4e3afd66"/></dir><dir name="template"><dir name="autocode"><file name="autocodebackend.phtml" hash="a88a28323413fc77c29c935a82715c9a"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="scriptblock.xml" hash="51512b2845d56dafa3028e8892702a76"/></dir><dir name="template"><dir name="scriptblock"><file name="foot.phtml" hash="2ded2491adf32d8157b8c6d5ec0b7726"/><file name="head.phtml" hash="53b5755dbd79862e4579fb46e57a93ea"/><file name="index.phtml" hash="da91307168404679f859274c2bb878b9"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Wigzo_AutoCode.xml" hash="fba2c2a20f4dad9b72a67f8876465906"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.4.0</min><max>5.9.0</max></php></required></dependencies>
18
  </package>