Jira_Woopra - Version 1.0.5

Version Notes

This module enables Woopra for the Magento frontend

Download this release

Release Info

Developer Magento Core Team
Extension Jira_Woopra
Version 1.0.5
Comparing to
See all releases


Code changes from version 1.0.4 to 1.0.5

app/code/community/Jira/Woopra/Block/Script.php CHANGED
@@ -4,8 +4,8 @@
4
  *
5
  * @category design_default
6
  * @package Jira_Woopra
7
- * @author Jisse Reitsma (Jira ICT)
8
- * @copyright Copyright (c) 2009 Jira ICT (http://www.jira.nl/)
9
  * @license Open Software License
10
  */
11
 
@@ -13,6 +13,10 @@ class Jira_Woopra_Block_Script extends Mage_Core_Block_Template
13
  {
14
  /*
15
  * Constructor method
 
 
 
 
16
  */
17
  public function _construct()
18
  {
@@ -21,38 +25,65 @@ class Jira_Woopra_Block_Script extends Mage_Core_Block_Template
21
  // Decide whether the Woopra Plugin has been actived
22
  $website_id = Mage::helper('woopra')->getWebsiteId();
23
  if(Mage::helper('woopra')->enabled() == true && !empty($website_id)) {
24
- // Setting the template-name will generate the block
25
  $this->setTemplate('woopra/script.phtml');
26
  }
27
  }
28
 
29
  /*
30
  * Helper method to get data to show in Woopra
 
 
 
 
31
  */
32
- public function getSetting($key = '')
33
  {
34
  static $data;
35
  if(empty($data)) {
36
 
 
37
  $data = array(
38
  'website_id' => Mage::helper('woopra')->getWebsiteId(), // Woopra website ID
39
  'enabled' => Mage::helper('woopra')->enabled(), // Plugin status
40
  'test' => Mage::helper('woopra')->test(), // Plugin testing mode
41
  );
42
 
 
 
 
 
 
43
  $customer = Mage::getSingleton('customer/session')->getCustomer();
44
  if(!empty($customer)) {
45
- $data['name'] = Mage::getSingleton('customer/session')->getCustomer()->getName();
46
- $data['email'] = Mage::getSingleton('customer/session')->getCustomer()->getEmail();
47
- $data['avatar'] = '';
48
 
 
 
 
 
 
49
  $address = $customer->getDefaultBillingAddress();
50
- if(!empty($address)) $address = $customer->getDefaultShippingAddress();
 
 
 
 
51
  if(!empty($address)) {
52
  $data['company'] = $address->getCompany();
 
53
  $data['city'] = $address->getCity() . ' (' . $address->getCountryId() . ')';
54
  }
55
  }
 
 
 
 
 
 
 
 
 
 
 
56
  }
57
 
58
  if(isset($data[$key])) {
4
  *
5
  * @category design_default
6
  * @package Jira_Woopra
7
+ * @author Yireo (http://www.yireo.com/)
8
+ * @copyright Copyright (c) 2010 Yireo (http://www.yireo.com/)
9
  * @license Open Software License
10
  */
11
 
13
  {
14
  /*
15
  * Constructor method
16
+ *
17
+ * @access public
18
+ * @param null
19
+ * @return null
20
  */
21
  public function _construct()
22
  {
25
  // Decide whether the Woopra Plugin has been actived
26
  $website_id = Mage::helper('woopra')->getWebsiteId();
27
  if(Mage::helper('woopra')->enabled() == true && !empty($website_id)) {
 
28
  $this->setTemplate('woopra/script.phtml');
29
  }
30
  }
31
 
32
  /*
33
  * Helper method to get data to show in Woopra
34
+ *
35
+ * @access public
36
+ * @param string $key
37
+ * @return string
38
  */
39
+ public function getSetting($key = null)
40
  {
41
  static $data;
42
  if(empty($data)) {
43
 
44
+ // Add generic settings
45
  $data = array(
46
  'website_id' => Mage::helper('woopra')->getWebsiteId(), // Woopra website ID
47
  'enabled' => Mage::helper('woopra')->enabled(), // Plugin status
48
  'test' => Mage::helper('woopra')->test(), // Plugin testing mode
49
  );
50
 
51
+ // Add things from the cart
52
+ $data['cart_items'] = Mage::helper('checkout/cart')->getCart()->getItemsCount();
53
+ $data['cart_total'] = Mage::getSingleton('checkout/session')->getQuote()->getBaseSubtotal();
54
+
55
+ // Add customer records
56
  $customer = Mage::getSingleton('customer/session')->getCustomer();
57
  if(!empty($customer)) {
 
 
 
58
 
59
+ $data['name'] = $customer->getName();
60
+ $data['email'] = $customer->getEmail();
61
+ $data['avatar'] = $customer->getAvatar();
62
+
63
+ // Load the address
64
  $address = $customer->getDefaultBillingAddress();
65
+ if(!empty($address)) {
66
+ $address = $customer->getDefaultShippingAddress();
67
+ }
68
+
69
+ // Add address data
70
  if(!empty($address)) {
71
  $data['company'] = $address->getCompany();
72
+ $data['phone'] = $address->getTelephone();
73
  $data['city'] = $address->getCity() . ' (' . $address->getCountryId() . ')';
74
  }
75
  }
76
+
77
+ $currentCategory = Mage::registry('current_category');
78
+ if(!empty($currentCategory)) {
79
+ $data['category'] = $currentCategory->getName();
80
+ }
81
+
82
+ $currentProduct = Mage::registry('current_product');
83
+ if(!empty($currentProduct)) {
84
+ $data['product_sku'] = $currentProduct->getSku();
85
+ $data['product_price'] = strip_tags(Mage::app()->getStore()->formatPrice($currentProduct->getPrice()));
86
+ }
87
  }
88
 
89
  if(isset($data[$key])) {
app/code/community/Jira/Woopra/Helper/Data.php CHANGED
@@ -4,8 +4,8 @@
4
  *
5
  * @category design_default
6
  * @package Jira_Woopra
7
- * @author Jisse Reitsma (Jira ICT)
8
- * @copyright Copyright (c) 2009 Jira ICT (http://www.jira.nl/)
9
  * @license Open Software License
10
  */
11
 
4
  *
5
  * @category design_default
6
  * @package Jira_Woopra
7
+ * @author Yireo
8
+ * @copyright Copyright (c) 2009 Yireo (http://www.yireo.com/)
9
  * @license Open Software License
10
  */
11
 
app/code/community/Jira/Woopra/etc/config.xml CHANGED
@@ -5,8 +5,8 @@
5
  *
6
  * @category design_default
7
  * @package Jira_Woopra
8
- * @author Jisse Reitsma (Jira ICT)
9
- * @copyright Copyright (c) 2009 Jira ICT (http://www.jira.nl/)
10
  * @license Open Software License
11
  */
12
  -->
@@ -14,7 +14,7 @@
14
 
15
  <modules>
16
  <Jira_Woopra>
17
- <version>1.0.4</version>
18
  </Jira_Woopra>
19
  </modules>
20
 
5
  *
6
  * @category design_default
7
  * @package Jira_Woopra
8
+ * @author Yireo
9
+ * @copyright Copyright (c) 2009 Yireo (http://www.yireo.com/)
10
  * @license Open Software License
11
  */
12
  -->
14
 
15
  <modules>
16
  <Jira_Woopra>
17
+ <version>1.0.5</version>
18
  </Jira_Woopra>
19
  </modules>
20
 
app/code/community/Jira/Woopra/etc/system.xml CHANGED
@@ -5,8 +5,8 @@
5
  *
6
  * @category design_default
7
  * @package Jira_Woopra
8
- * @author Jisse Reitsma (Jira ICT)
9
- * @copyright Copyright (c) 2009 Jira ICT (http://www.jira.nl/)
10
  * @license Open Software License
11
  */
12
  -->
5
  *
6
  * @category design_default
7
  * @package Jira_Woopra
8
+ * @author Yireo
9
+ * @copyright Copyright (c) 2009 Yireo (http://www.yireo.com/)
10
  * @license Open Software License
11
  */
12
  -->
app/design/frontend/default/default/layout/woopra.xml DELETED
@@ -1,25 +0,0 @@
1
- <?xml version="1.0"?>
2
- <!--
3
- /**
4
- * Woopra plugin for Magento
5
- *
6
- * @category design_default
7
- * @package Jira_Woopra
8
- * @author Jisse Reitsma (Jira ICT)
9
- * @copyright Copyright (c) 2009 Jira ICT (http://www.jira.nl/)
10
- * @license Open Software License
11
- *
12
- * @todo
13
- * - We need to initialize Woopra-block twice, to make it work
14
- */
15
- -->
16
- <layout version="1.0.4">
17
- <default>
18
- <!--<block type="woopra/script"/>-->
19
-
20
- <reference name="before_body_end">
21
- <block type="woopra/script" name="woopra" as="woopra" template="woopra/script.phtml"/>
22
- </reference>
23
-
24
- </default>
25
- </layout>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/default/default/template/woopra/script.phtml CHANGED
@@ -4,33 +4,30 @@
4
  *
5
  * @category design_default
6
  * @package Jira_Woopra
7
- * @author Jisse Reitsma (Jira ICT)
8
- * @copyright Copyright (c) 2009 Jira ICT (http://www.jira.nl/)
9
  * @license Open Software License
10
- *
11
- * @todo
12
- * - convert woopra_array into woopra_visitor
13
- * - introduce woopra_event['sale']
14
- * - rewrite SSL-check from JavaScript to PHP-code (Magento class)
15
- * - add extra information like woopra_array['fullname'] or woopra_array['']
16
  */
17
  ?>
18
- <!-- BEGIN WOOPRA PLUGIN CODE -->
19
- <script type="text/javascript" language="javascript">
20
  <?php if($this->getSetting('test')) { ?>
 
21
  alert('Woopra is installed but in test mode');
 
22
  <?php } else { ?>
23
- var woopra_id = '<?php echo $this->getSetting('website_id'); ?>';
24
- var woopra_visitor = new Array();
25
- woopra_visitor['name'] = '<?php echo $this->getSetting('name'); ?>';
26
- woopra_visitor['email'] = '<?php echo $this->getSetting('email'); ?>';
27
- woopra_visitor['avatar'] = '<?php echo $this->getSetting('avatar'); ?>';
28
- woopra_visitor['company'] = '<?php echo $this->getSetting('company'); ?>';
29
- woopra_visitor['city'] = '<?php echo $this->getSetting('city'); ?>';
30
- var woopra_event = new Array();
31
- woopra_event['title'] = '<?php echo trim($this->getLayout()->getBlock('head')->getTitle()); ?>';
32
- var woopra_host = ((document.location.protocol=='https:') ? "https://sec1.woopra.com" : "http://static.woopra.com");
33
- document.write(unescape("%3Cscript src='" + woopra_host + "/js/woopra.js' type='text/javascript'%3E%3C/script%3E"));
34
- <?php } ?>
 
 
 
35
  </script>
36
- <!-- END WOOPRA PLUGIN CODE -->
4
  *
5
  * @category design_default
6
  * @package Jira_Woopra
7
+ * @author Yireo (http://www.yireo.com/)
8
+ * @copyright Copyright (c) 2010 Yireo (http://www.yireo.com/)
9
  * @license Open Software License
 
 
 
 
 
 
10
  */
11
  ?>
 
 
12
  <?php if($this->getSetting('test')) { ?>
13
+ <script type="text/javascript" language="javascript">
14
  alert('Woopra is installed but in test mode');
15
+ </script>
16
  <?php } else { ?>
17
+ <script type="text/javascript" src="http://static.woopra.com/js/woopra.v2.js"></script>
18
+ <script type="text/javascript">
19
+ woopraTracker.addVisitorProperty("name", "<?php echo $this->getSetting('name'); ?>");
20
+ woopraTracker.addVisitorProperty("email", "<?php echo $this->getSetting('email'); ?>");
21
+ woopraTracker.addVisitorProperty("avatar", "<?php echo $this->getSetting('avatar'); ?>");
22
+ woopraTracker.addVisitorProperty("company", "<?php echo $this->getSetting('company'); ?>");
23
+ woopraTracker.addVisitorProperty("city", "<?php echo $this->getSetting('city'); ?>");
24
+ woopraTracker.addVisitorProperty("phone", "<?php echo $this->getSetting('phone'); ?>");
25
+ woopraTracker.addVisitorProperty("cart_items", "<?php echo $this->getSetting('cart_items'); ?>");
26
+ woopraTracker.addVisitorProperty("cart_total", "<?php echo $this->getSetting('cart_total'); ?>");
27
+ woopraTracker.track(window.location.pathname, document.title, {
28
+ category: '<?php echo $this->getSetting('category'); ?>',
29
+ product_price: '<?php echo $this->getSetting('product_price'); ?>',
30
+ product_sku: '<?php echo $this->getSetting('product_sku'); ?>'
31
+ });
32
  </script>
33
+ <?php } ?>
app/etc/modules/Jira_Woopra.xml CHANGED
@@ -3,10 +3,9 @@
3
  /**
4
  * Woopra plugin for Magento
5
  *
6
- * @category design_default
7
  * @package Jira_Woopra
8
- * @author Jisse Reitsma (Jira ICT)
9
- * @copyright Copyright (c) 2009 Jira ICT (http://www.jira.nl/)
10
  * @license Open Software License
11
  */
12
  -->
3
  /**
4
  * Woopra plugin for Magento
5
  *
 
6
  * @package Jira_Woopra
7
+ * @author Yireo (https://www.yireo.com/)
8
+ * @copyright Copyright (c) 2009 Yireo (https://www.yireo.com/)
9
  * @license Open Software License
10
  */
11
  -->
package.xml CHANGED
@@ -1,18 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Jira_Woopra</name>
4
- <version>1.0.0</version>
5
  <stability>stable</stability>
6
- <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>This module integrates Magento with Woopra</summary>
10
- <description>This module integrates Magento with Woopra</description>
11
- <notes>fs</notes>
12
- <authors><author><name>Jisse Reitsma</name><user>auto-converted</user><email>info@jira.nl</email></author></authors>
13
- <date>2009-04-03</date>
14
- <time>14:03:57</time>
15
- <contents><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="woopra.xml" hash="a669d551ae0f420c1c0d41120bb63b1b"/></dir><dir name="template"><dir name="woopra"><file name="script.phtml" hash="b94d61eaa503f1200ceb2bce7d52c617"/></dir></dir></dir></dir></dir></target><target name="magecommunity"><dir name="Jira"><dir name="Woopra"><dir name="Block"><file name="Script.php" hash="e5ecdb8c2c9e57e122afe1e0f55deb9d"/></dir><dir name="etc"><file name="config.xml" hash="b3bca69e98758e12e11b5424f813bc07"/><file name="system.xml" hash="28ea9bbe116f4a292ec9bf2a1313c4e4"/></dir><dir name="Helper"><file name="Data.php" hash="1579ee95b1f3e3556ec5fca65856cf05"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Jira_Woopra.xml" hash="7bfe9331fb9392f7ac313fa55e76ce2c"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies/>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Jira_Woopra</name>
4
+ <version>1.0.5</version>
5
  <stability>stable</stability>
6
+ <license uri="http://www.opensource.org/licenses/osl-3.0.php/">Open Software License</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>This module enables Woopra for the Magento frontend</summary>
10
+ <description>This module enables Woopra for the Magento frontend</description>
11
+ <notes>This module enables Woopra for the Magento frontend</notes>
12
+ <authors><author><name>Yireo</name><user>auto-converted</user><email>info@yireo.com</email></author></authors>
13
+ <date>2010-08-16</date>
14
+ <time>15:38:57</time>
15
+ <contents><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="woopra"><file name="script.phtml" hash="861c36da9d6970733017cd66f659335b"/></dir></dir></dir></dir></dir></target><target name="magecommunity"><dir name="Jira"><dir name="Woopra"><dir name="Block"><file name="Script.php" hash="cd28605f6772e36b47ea8301954803b5"/></dir><dir name="etc"><file name="config.xml" hash="a61a9e81931ee8427571f135c75e5b01"/><file name="system.xml" hash="f787d2cd1d87636ab829773feb548e8f"/></dir><dir name="Helper"><file name="Data.php" hash="270036fa2fb761ad3b4d0e3a2d2d5e13"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Jira_Woopra.xml" hash="ace85137f7edb480d4fe170ada584f98"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies/>
18
  </package>