Olark_Chatbox - Version 1.0.4

Version Notes

This is the first stable release of the official Olark Live Chat CartSaver extension for Magento. It should work for all versions from Magento 1.4 upwards.

Download this release

Release Info

Developer Olark Live Chat
Extension Olark_Chatbox
Version 1.0.4
Comparing to
See all releases


Version 1.0.4

app/code/community/Olark/Chatbox/Block/Chatbox.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Widget that adds Olark Live Chat to Magento stores.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to support@olark.com so we can send you a copy immediately.
14
+ *
15
+ * @category Olark
16
+ * @package Olark_Chatbox
17
+ * @copyright Copyright 2012. Habla, Inc. (http://www.olark.com)
18
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
19
+ */
20
+
21
+ class Olark_Chatbox_Block_Chatbox
22
+ extends Mage_Core_Block_Abstract
23
+ implements Mage_Widget_Block_Interface
24
+ {
25
+
26
+ /**
27
+ * Produces Olark Chatbox html
28
+ *
29
+ * @return string
30
+ */
31
+ protected function _toHtml()
32
+ {
33
+ $customer = $products = array();
34
+ $totalValue = $totalItems = 0;
35
+
36
+ // don't show the Olark code if there is no account number
37
+ $siteID = $this->getData('siteID');
38
+ if (empty($siteID)) {
39
+ return '';
40
+ }
41
+
42
+ // build customer array
43
+ $info = Mage::getSingleton('customer/session')->getCustomer();
44
+ if ($info) {
45
+
46
+ $billingAddress = $info->getPrimaryBillingAddress();
47
+ if( $billingAddress ) $billingAddress = $billingAddress->format('text');
48
+
49
+ $shippingAddress = $info->getPrimaryShippingAddress();
50
+ if( $shippingAddress ) $shippingAddress = $shippingAddress->format('text');
51
+
52
+ $customer = array(
53
+ 'name' => $info->getName(),
54
+ 'email' => $info->getEmail(),
55
+ 'billing' => $billingAddress,
56
+ 'shipping' => $shippingAddress
57
+ );
58
+ }
59
+
60
+ // build cart and total arrays
61
+ $items = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();
62
+ if ($items) {
63
+ $totalValue = $totalItems = 0;
64
+ foreach($items as $item) {
65
+ $product = array(
66
+ 'name' => $item->getName(),
67
+ 'sku' => $item->getSku(),
68
+ 'quantity' => $item->getQty(),
69
+ 'price' => $item->getPrice()
70
+ );
71
+ $products[] = $product;
72
+ $totalItems = $totalItems + $product['quantity'];
73
+ $totalValue = $totalValue + ($product['price'] * $product['quantity']);
74
+ }
75
+ }
76
+
77
+ // build the html & javascript string
78
+ $html = '
79
+ <!-- begin olark code --><script type=\'text/javascript\'>/*{literal}<![CDATA[*/
80
+ window.olark||(function(c){var f=window,d=document,l=f.location.protocol=="https:"?"https:":"http:",z=c.name,r="load";var nt=function(){f[z]=function(){(a.s=a.s||[]).push(arguments)};var a=f[z]._={},q=c.methods.length;while(q--){(function(n){f[z][n]=function(){f[z]("call",n,arguments)}})(c.methods[q])}a.l=c.loader;a.i=nt;a.p={0:+new Date};a.P=function(u){a.p[u]=new Date-a.p[0]};function s(){a.P(r);f[z](r)}f.addEventListener?f.addEventListener(r,s,false):f.attachEvent("on"+r,s);var ld=function(){function p(hd){hd="head";return["<",hd,"></",hd,"><",i,\' onl\' + \'oad="var d=\',g,";d.getElementsByTagName(\'head\')[0].",j,"(d.",h,"(\'script\')).",k,"=\'",l,"//",a.l,"\'",\'"\',"></",i,">"].join("")}var i="body",m=d[i];if(!m){return setTimeout(ld,100)}a.P(1);var j="appendChild",h="createElement",k="src",n=d[h]("div"),v=n[j](d[h](z)),b=d[h]("iframe"),g="document",e="domain",o;n.style.display="none";m.insertBefore(n,m.firstChild).id=z;b.frameBorder="0";b.id=z+"-loader";if(/MSIE[ ]+6/.test(navigator.userAgent)){b.src="javascript:false"}b.allowTransparency="true";v[j](b);try{b.contentWindow[g].open()}catch(w){c[e]=d[e];o="javascript:var d="+g+".open();d.domain=\'"+d.domain+"\';";b[k]=o+"void(0);"}try{var t=b.contentWindow[g];t.write(p());t.close()}catch(x){b[k]=o+\'d.write("\'+p().replace(/"/g,String.fromCharCode(92)+\'"\')+\'");d.close();\'}a.P(2)};ld()};nt()})({loader: "static.olark.com/jsclient/loader0.js",name:"olark",methods:["configure","extend","declare","identify"]});
81
+ /* custom configuration goes here (www.olark.com/documentation) */
82
+ olark.identify(\''.$siteID.'\'); /*]]>{/literal}*/</script>
83
+ <noscript><a href="https://www.olark.com/site/'.$siteID.'/contact" title="Contact us" target="_blank">Questions? Feedback?</a> powered by <a href="http://www.olark.com?welcome" title="Olark live chat software">Olark live chat software</a></noscript>
84
+ <!-- olark magento cart saver -->
85
+ <script type=\'text/javascript\'>
86
+ olark.extend(\'Magento\');
87
+ olark.configure(\'Magento.items\', '.json_encode($totalItems).');
88
+ olark.configure(\'Magento.total\', '.json_encode($totalValue).');
89
+ olark.configure(\'Magento.products\', '.json_encode($products).');
90
+ olark.configure(\'Magento.customer\', '.json_encode($customer).');
91
+ olark.configure(\'Magento.valueThreshold\', '.json_encode($this->getData('valueThreshold')).');
92
+ olark.configure(\'Magento.removeNotification\', '.json_encode(!!$this->getData('removeNotification')).');
93
+ olark.configure(\'Magento.addNotification\', '.json_encode(!!$this->getData('addNotification')).');
94
+ olark.configure(\'Magento.showSku\', '.json_encode(!!$this->getData('showSku')).');
95
+ olark.configure(\'Magento.version\', \'0.0.1\');
96
+ </script>
97
+ <!-- custom olark config -->
98
+ '.$this->getData('customConfig');
99
+
100
+ return $html;
101
+ }
102
+
103
+ }
app/code/community/Olark/Chatbox/Helper/Data.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Widget that adds Olark Live Chat to Magento stores.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to support@olark.com so we can send you a copy immediately.
14
+ *
15
+ * @category Olark
16
+ * @package Olark_Chatbox
17
+ * @copyright Copyright 2012. Habla, Inc. (http://www.olark.com)
18
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
19
+ */
20
+
21
+ class Olark_Chatbox_Helper_Data extends Mage_Core_Helper_Abstract
22
+ {
23
+
24
+ }
app/code/community/Olark/Chatbox/etc/config.xml ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Widget that adds Olark Live Chat to Magento stores.
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Academic Free License (AFL 3.0)
9
+ * that is bundled with this package in the file LICENSE_AFL.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/afl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to support@olark.com so we can send you a copy immediately.
15
+ *
16
+ * @category Olark
17
+ * @package Olark_Chatbox
18
+ * @copyright Copyright 2012. Habla, Inc. (http://www.olark.com)
19
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
20
+ */
21
+ -->
22
+ <config>
23
+ <modules>
24
+ <Olark_Chatbox>
25
+ <version>1.0.0</version>
26
+ <cache_lifetime>0</cache_lifetime>
27
+ </Olark_Chatbox>
28
+ </modules>
29
+ <global>
30
+ <helpers>
31
+ <chatbox>
32
+ <class>Olark_Chatbox_Helper</class>
33
+ </chatbox>
34
+ </helpers>
35
+ <blocks>
36
+ <chatbox>
37
+ <class>Olark_Chatbox_Block</class>
38
+ </chatbox>
39
+ </blocks>
40
+ </global>
41
+ </config>
app/code/community/Olark/Chatbox/etc/widget.xml ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Widget that adds Olark Live Chat to Magento stores.
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Academic Free License (AFL 3.0)
9
+ * that is bundled with this package in the file LICENSE_AFL.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/afl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to support@olark.com so we can send you a copy immediately.
15
+ *
16
+ * @category Olark
17
+ * @package Olark_Chatbox
18
+ * @copyright Copyright 2012. Habla, Inc. (http://www.olark.com)
19
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
20
+ */
21
+ -->
22
+ <widgets>
23
+ <chatbox_chatbox type="chatbox/chatbox" translate="name description" module="chatbox">
24
+ <name>Olark Live Chat</name>
25
+ <description>Adds Olark Live Chat to your website.</description>
26
+ <parameters>
27
+ <siteID>
28
+ <label>Olark Site-ID</label>
29
+ <visible>1</visible>
30
+ <required>1</required>
31
+ <type>text</type>
32
+ <description>
33
+ <![CDATA[
34
+ <strong>New to Olark?</strong>
35
+ <a target="_blank" href="https://olark.com/signup/create_new_account?rid=magentocartsaver1_0">Signup for a FREE Olark account.</a>
36
+ <strong>Already an Olark user?</strong>
37
+ <a target="_blank" href="https://olark.com/install">Find your Olark Site-ID.</a>
38
+ ]]>
39
+ </description>
40
+ </siteID>
41
+ <valueThreshold>
42
+ <label>Minimum Cart Value for Notifications</label>
43
+ <visible>1</visible>
44
+ <required>0</required>
45
+ <type>text</type>
46
+ <description>
47
+ <![CDATA[
48
+ Send a notification to your operator when a customer's cart reaches at least this value.
49
+ ]]>
50
+ </description>
51
+ </valueThreshold>
52
+ <addNotification>
53
+ <label>Send Cart Add Notifications?</label>
54
+ <visible>1</visible>
55
+ <required>0</required>
56
+ <type>select</type>
57
+ <values>
58
+ <one translate="label">
59
+ <value>1</value>
60
+ <label>Yes</label>
61
+ </one>
62
+ <two translate="label">
63
+ <value>0</value>
64
+ <label>No</label>
65
+ </two>
66
+ </values>
67
+ <description>
68
+ <![CDATA[
69
+ Turn on or off notifications to your operator when a product is added from a customer's cart.
70
+ ]]>
71
+ </description>
72
+ </addNotification>
73
+ <removeNotification>
74
+ <label>Send Cart Removal Notifications?</label>
75
+ <visible>1</visible>
76
+ <required>0</required>
77
+ <type>select</type>
78
+ <values>
79
+ <one translate="label">
80
+ <value>1</value>
81
+ <label>Yes</label>
82
+ </one>
83
+ <two translate="label">
84
+ <value>0</value>
85
+ <label>No</label>
86
+ </two>
87
+ </values>
88
+ <description>
89
+ <![CDATA[
90
+ Turn on or off notifications to your operator when a product is removed from a customers cart.
91
+ ]]>
92
+ </description>
93
+ </removeNotification>
94
+ <showSku>
95
+ <label>Show SKU?</label>
96
+ <visible>1</visible>
97
+ <required>0</required>
98
+ <type>select</type>
99
+ <values>
100
+ <one translate="label">
101
+ <value>1</value>
102
+ <label>Yes</label>
103
+ </one>
104
+ <two translate="label">
105
+ <value>0</value>
106
+ <label>No</label>
107
+ </two>
108
+ </values>
109
+ <description>
110
+ <![CDATA[
111
+ Show the SKU as part of the product name in the operator's buddy list.
112
+ ]]>
113
+ </description>
114
+ </showSku>
115
+ <customConfig>
116
+ <label>Developer API snippets</label>
117
+ <visible>1</visible>
118
+ <required>0</required>
119
+ <type>textarea</type>
120
+ <description>
121
+ <![CDATA[
122
+ For help on how to use the API and for example snippets, go to <a target="_blank" href="http://olark.com/developer">http://olark.com/developer</a>
123
+ ]]>
124
+ </description>
125
+ </customConfig>
126
+ </parameters>
127
+ </chatbox_chatbox>
128
+ </widgets>
app/etc/modules/Olark_Chatbox.xml ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Widget that adds Olark Live Chat to Magento stores.
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Academic Free License (AFL 3.0)
9
+ * that is bundled with this package in the file LICENSE_AFL.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/afl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to support@olark.com so we can send you a copy immediately.
15
+ *
16
+ * @category Olark
17
+ * @package Olark_Chatbox
18
+ * @copyright Copyright 2012. Habla, Inc. (http://www.olark.com)
19
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
20
+ */
21
+ -->
22
+ <config>
23
+ <modules>
24
+ <Olark_Chatbox>
25
+ <active>true</active>
26
+ <codePool>community</codePool>
27
+ <depends>
28
+ <Mage_Core/>
29
+ <Mage_Rule/>
30
+ <Mage_Catalog/>
31
+ <Mage_Customer/>
32
+ <Mage_Payment/>
33
+ <Mage_Cms />
34
+ </depends>
35
+ </Olark_Chatbox>
36
+ </modules>
37
+ </config>
package.xml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Olark_Chatbox</name>
4
+ <version>1.0.4</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/afl-3.0.php">Academic Free License (AFL 3.0)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Drive more sales. Talk to your customers on your Magento store with Olark Live Chat.</summary>
10
+ <description>Talk to your customers. You'll sell more, faster.&#xD;
11
+ &#xD;
12
+ Olark Live Chat helps thousands of businesses talk to the customers browsing their website so they can drive more sales.&#xD;
13
+ &#xD;
14
+ With Olark's CartSaver extension for Magento, you can put an end to abandoned shopping carts. Watch your customers add and remove items from their shopping carts while they shop and then step in to talk to them to close the sale.&#xD;
15
+ &#xD;
16
+ Try it FREE at Olark.com.</description>
17
+ <notes>This is the first stable release of the official Olark Live Chat CartSaver extension for Magento. It should work for all versions from Magento 1.4 upwards.</notes>
18
+ <authors><author><name>Olark Live Chat</name><user>olark</user><email>support@olark.com</email></author></authors>
19
+ <date>2012-09-17</date>
20
+ <time>22:16:32</time>
21
+ <contents><target name="magecommunity"><dir name="Olark"><dir name="Chatbox"><dir name="Block"><file name="Chatbox.php" hash="ad94ec36b70849e4799d295de94f86ad"/></dir><dir name="Helper"><file name="Data.php" hash="c7bb144614b8490213397584f1050492"/></dir><dir name="etc"><file name="config.xml" hash="8aa65fd4a9fe24e759a7ace841541833"/><file name="widget.xml" hash="250dc2b34a2051549ff4f0c818647942"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Olark_Chatbox.xml" hash="220e124817be0b67876250efca078b83"/></dir></target></contents>
22
+ <compatible/>
23
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
24
+ </package>