unbeatablechat - Version 0.3.1

Version Notes

* Added currency value into Items data sent to Unbeatable
* Refactored Widget JS to use new UnbeatableReady function.

Download this release

Release Info

Developer Unbeatable.com
Extension unbeatablechat
Version 0.3.1
Comparing to
See all releases


Code changes from version 0.3.0 to 0.3.1

app/code/community/Unbeatable/Chat/Block/Footer.php CHANGED
@@ -4,9 +4,13 @@ class Unbeatable_Chat_Block_Footer extends Mage_Core_Block_Template
4
  {
5
 
6
  const XML_PATH_CHAT_ENABLED = 'unbeatable/unbeatable_group2/unbeatable_chat_enabled';
 
7
 
8
  public function isEnabled() {
9
  return Mage::getStoreConfig(self::XML_PATH_CHAT_ENABLED, Mage::app()->getStore());
10
  }
11
 
 
 
 
12
  }
4
  {
5
 
6
  const XML_PATH_CHAT_ENABLED = 'unbeatable/unbeatable_group2/unbeatable_chat_enabled';
7
+ const XML_PATH_CHAT_API_KEY = 'unbeatable/unbeatable_group2/unbeatable_apikey';
8
 
9
  public function isEnabled() {
10
  return Mage::getStoreConfig(self::XML_PATH_CHAT_ENABLED, Mage::app()->getStore());
11
  }
12
 
13
+ public function getApiKey() {
14
+ return Mage::getStoreConfig(self::XML_PATH_CHAT_ENABLED, Mage::app()->getStore());
15
+ }
16
  }
app/code/community/Unbeatable/Chat/Helper/Data.php CHANGED
@@ -14,39 +14,10 @@ class Unbeatable_Chat_Helper_Data extends Mage_Core_Helper_Abstract {
14
  'image' => $_item->getThumbnailUrl(),
15
  'name' => $_item->getName(),
16
  'quantity' => $item->getQty(),
 
17
  'price' => number_format($item->getBaseCalculationPrice(), 2, '.', '')
18
  );
19
  }
20
  return $products;
21
  }
22
-
23
- /*
24
- * Used to insert chat widget via Template
25
- */
26
- public function insertChatWidget(){
27
- $apikey = Mage::getStoreConfig('unbeatable/unbeatable_group2/unbeatable_apikey', Mage::app()->getStore());
28
-
29
- echo '<script src="https://dash.unbeatable.com/public/widget.js?client='.$apikey.'" async></script>';
30
- echo "<script>
31
- function ajax(url, callback, data, x) {
32
- try {
33
- x = new(this.XMLHttpRequest || ActiveXObject)('MSXML2.XMLHTTP.3.0');
34
- x.open(data ? 'POST' : 'GET', url, 1);
35
- x.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
36
- x.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
37
- x.onreadystatechange = function () {
38
- x.readyState > 3 && callback && callback(x.responseText, x);
39
- };
40
- x.send(data)
41
- } catch (e) {
42
- window.console && console.log(e);
43
- }
44
- };
45
- ajax('" . Mage::getBaseUrl() . "unbeatable/cart/index', function(response){
46
- if(Unbeatable){
47
- Unbeatable.setItems(JSON.parse(response));
48
- }
49
- });
50
- </script>";
51
- }
52
  }
14
  'image' => $_item->getThumbnailUrl(),
15
  'name' => $_item->getName(),
16
  'quantity' => $item->getQty(),
17
+ 'currency' => Mage::app()->getStore()->getCurrentCurrencyCode(),
18
  'price' => number_format($item->getBaseCalculationPrice(), 2, '.', '')
19
  );
20
  }
21
  return $products;
22
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  }
app/code/community/Unbeatable/Chat/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Unbeatable_Chat>
5
- <version>0.1.1</version>
6
  </Unbeatable_Chat>
7
  </modules>
8
  <global>
2
  <config>
3
  <modules>
4
  <Unbeatable_Chat>
5
+ <version>0.2.3</version>
6
  </Unbeatable_Chat>
7
  </modules>
8
  <global>
app/design/frontend/base/default/template/unbeatable/footer.phtml CHANGED
@@ -1,5 +1,28 @@
1
  <?php
2
  if($this->isEnabled()){
3
- Mage::helper('unbeatablechat')->insertChatWidget();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  }
5
  ?>
1
  <?php
2
  if($this->isEnabled()){
3
+ ?>
4
+ <script src="https://dash.unbeatable.com/public/widget.js?client=<?php echo $this->getApiKey(); ?>" async></script>
5
+ <script>
6
+ function ajax(url, callback, data, x) {
7
+ try {
8
+ x = new(this.XMLHttpRequest || ActiveXObject)('MSXML2.XMLHTTP.3.0');
9
+ x.open(data ? 'POST' : 'GET', url, 1);
10
+ x.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
11
+ x.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
12
+ x.onreadystatechange = function () {
13
+ x.readyState > 3 && callback && callback(x.responseText, x);
14
+ };
15
+ x.send(data)
16
+ } catch (e) {
17
+ window.console && console.log(e);
18
+ }
19
+ };
20
+ function UnbeatableReady() {
21
+ ajax('<?php echo Mage::getBaseUrl(); ?>unbeatable/cart/index', function(response){
22
+ Unbeatable.setItems(JSON.parse(response));
23
+ });
24
+ }
25
+ </script>
26
+ <?php
27
  }
28
  ?>
package.xml CHANGED
@@ -1,18 +1,19 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>unbeatablechat</name>
4
- <version>0.3.0</version>
5
  <stability>stable</stability>
6
  <license>GPL</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Unbeatable Chat Integration</summary>
10
  <description>Unbeatable Chat Integration</description>
11
- <notes>Code Improvements and Bug Fixes</notes>
 
12
  <authors><author><name>Unbeatable.com</name><user>Unbetable</user><email>support@unbeatable.com</email></author></authors>
13
- <date>2016-03-31</date>
14
- <time>12:11:55</time>
15
- <contents><target name="magecommunity"><dir name="Unbeatable"><dir name="Chat"><dir name="Block"><file name="Footer.php" hash="7075e7c25d6955fdd3a804b3b023153d"/></dir><dir name="Helper"><file name="Data.php" hash="c7f317b8093f07c3091809246ef241d7"/></dir><dir name="Model"><file name="Observer.php" hash="c19a8efa9855b590037bc16244b47ec9"/></dir><dir name="controllers"><file name="CartController.php" hash="b2f0199f7bdf8508ac1cb15e85209a14"/></dir><dir name="etc"><file name="adminhtml.xml" hash="1b249d797ac91b8a8f71455185e2cdf8"/><file name="config.xml" hash="63cbe021590463b680bf6dc2777110f0"/><file name="system.xml" hash="b38091e7eccc589055806fc2f5e034b2"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Unbeatable_Chat.xml" hash="0fefe4d3d22792b9af3318c00dd8b906"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="unbeatable"><file name="footer.phtml" hash="10e06a626c442d2401efa8d5c8483c1d"/></dir></dir><dir name="layout"><file name="unbeatable.xml" hash="cf7d3132c929915d91fe553209f774bf"/></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.0.0</min><max>7.0.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>unbeatablechat</name>
4
+ <version>0.3.1</version>
5
  <stability>stable</stability>
6
  <license>GPL</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Unbeatable Chat Integration</summary>
10
  <description>Unbeatable Chat Integration</description>
11
+ <notes>* Added currency value into Items data sent to Unbeatable&#xD;
12
+ * Refactored Widget JS to use new UnbeatableReady function.</notes>
13
  <authors><author><name>Unbeatable.com</name><user>Unbetable</user><email>support@unbeatable.com</email></author></authors>
14
+ <date>2016-06-15</date>
15
+ <time>09:25:50</time>
16
+ <contents><target name="magecommunity"><dir name="Unbeatable"><dir name="Chat"><dir name="Block"><file name="Footer.php" hash="0cd6e7336b6b1107a74c9c42a44b6fee"/></dir><dir name="Helper"><file name="Data.php" hash="5dc27553cd25eea2dfa12b38386f05a4"/></dir><dir name="Model"><file name="Observer.php" hash="c19a8efa9855b590037bc16244b47ec9"/></dir><dir name="controllers"><file name="CartController.php" hash="b2f0199f7bdf8508ac1cb15e85209a14"/></dir><dir name="etc"><file name="adminhtml.xml" hash="1b249d797ac91b8a8f71455185e2cdf8"/><file name="config.xml" hash="092c11ad2303e2500155c65ed8150faa"/><file name="system.xml" hash="b38091e7eccc589055806fc2f5e034b2"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Unbeatable_Chat.xml" hash="0fefe4d3d22792b9af3318c00dd8b906"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="unbeatable"><file name="footer.phtml" hash="e40fbe6a8c795090dfa5a5bb04626fb2"/></dir></dir><dir name="layout"><file name="unbeatable.xml" hash="cf7d3132c929915d91fe553209f774bf"/></dir></dir></dir></dir></target></contents>
17
  <compatible/>
18
  <dependencies><required><php><min>5.0.0</min><max>7.0.0</max></php></required></dependencies>
19
  </package>