Refiral - Version 1.0.4

Version Notes

Stable version of Refiral extension.

Download this release

Release Info

Developer Refiral
Extension Refiral
Version 1.0.4
Comparing to
See all releases


Code changes from version 1.0.3 to 1.0.4

app/code/community/Refiral/Campaign/Block/default.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Refiral_Campaign extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Refiral
13
+ * @package Refiral_Campaign
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Refiral Settings view block
19
+ *
20
+ * @category Refiral
21
+ * @package Refiral_Campaign
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Refiral_Campaign_Block_Default extends Mage_Core_Block_Template {
25
+ }
app/code/community/Refiral/Campaign/Helper/Data.php CHANGED
@@ -1,57 +1,78 @@
1
  <?php
2
- class Refiral_Campaign_Helper_Data extends Mage_Core_Helper_Abstract
3
- {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  public function isActive()
5
  {
6
- $campaignActive = Mage::getStoreConfig('general/campaign/active');
7
- if(!empty($campaignActive))
8
- return true;
9
- else
10
- return false;
11
  }
12
-
13
  public function getKey()
14
  {
15
- return Mage::getStoreConfig('general/campaign/apikey');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  }
17
-
18
- public function getScript()
19
- {
20
- $request = Mage::app()->getRequest();
21
- $module = $request->getModuleName();
22
- $controller = $request->getControllerName();
23
- $action = $request->getActionName();
24
- $script = "<script>var apiKey = '".$this->getKey()."';</script>";
25
- if ($module == 'checkout' && $controller == 'onepage' && $action == 'success')
26
- {
27
- $order = new Mage_Sales_Model_Order();
28
- $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
29
- $order->loadByIncrementId($orderId); // Load order details
30
- $order_total = round($order->getGrandTotal(), 2); // Get grand total
31
- $order_coupon = $order->getCouponCode(); // Get coupon used
32
- $items = $order->getAllItems(); // Get items info
33
- $cartInfo = array();
34
- // Convert object to string
35
- foreach($items as $item) {
36
- $product = Mage::getModel('catalog/product')->load($item->getProductId());
37
- $name = $item->getName();
38
- $qty = $item->getQtyToInvoice();
39
- $cartInfo[] = array('id' => $item->getProductId(), 'name' => $name, 'quantity' => $qty);
40
- }
41
- $cartInfoString = serialize($cartInfo);
42
- $order_name = $order->getCustomerName(); // Get customer's name
43
- $order_email = $order->getCustomerEmail(); // Get customer's email id
44
-
45
- // Call invoiceRefiral function
46
- $scriptAppend = "<script>invoiceRefiral('$order_total', '$order_total', '$order_coupon', '$cartInfoString', '$order_name', '$order_email');</script>";
47
- $script .= '<script>var showButton = false;</script>';
48
- }
49
- else
50
- {
51
- $scriptAppend = '';
52
- $script .= '<script>var showButton = true;</script>';
53
- }
54
- $script .= '<script src="//rfer.co/api/v0/js/all.js"></script>';
55
- return $script.$scriptAppend;
56
- }
57
  }
1
  <?php
2
+ /**
3
+ * Refiral_Campaign extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category Refiral
13
+ * @package Refiral_Campaign
14
+ * @copyright Copyright (c) 2014
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Campaign default helper
19
+ *
20
+ * @category Refiral
21
+ * @package Refiral_Campaign
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Refiral_Campaign_Helper_Data extends Mage_Core_Helper_Abstract {
25
  public function isActive()
26
  {
27
+ $campaignActive = Mage::getStoreConfig('general/refiral_campaign/active');
28
+ if(!empty($campaignActive))
29
+ return true;
30
+ else
31
+ return false;
32
  }
33
+
34
  public function getKey()
35
  {
36
+ return Mage::getStoreConfig('general/refiral_campaign/apikey');
37
+ }
38
+
39
+ public function getScript()
40
+ {
41
+ $request = Mage::app()->getRequest();
42
+ $module = $request->getModuleName();
43
+ $controller = $request->getControllerName();
44
+ $action = $request->getActionName();
45
+ $script = "<script>var apiKey = '".$this->getKey()."';</script>"."\n";
46
+ if ($module == 'checkout' && $controller == 'onepage' && $action == 'success')
47
+ {
48
+ $order = new Mage_Sales_Model_Order();
49
+ $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
50
+ $order->loadByIncrementId($orderId); // Load order details
51
+ $order_total = round($order->getGrandTotal(), 2); // Get grand total
52
+ $order_coupon = $order->getCouponCode(); // Get coupon used
53
+ $items = $order->getAllItems(); // Get items info
54
+ $cartInfo = array();
55
+ // Convert object to string
56
+ foreach($items as $item) {
57
+ $product = Mage::getModel('catalog/product')->load($item->getProductId());
58
+ $name = $item->getName();
59
+ $qty = $item->getQtyToInvoice();
60
+ $cartInfo[] = array('id' => $item->getProductId(), 'name' => $name, 'quantity' => $qty);
61
+ }
62
+ $cartInfoString = serialize($cartInfo);
63
+ $order_name = $order->getCustomerName(); // Get customer's name
64
+ $order_email = $order->getCustomerEmail(); // Get customer's email id
65
+
66
+ // Call invoiceRefiral function
67
+ $scriptAppend = "<script>invoiceRefiral('$order_total', '$order_total', '$order_coupon', '$cartInfoString', '$order_name', '$order_email', '$orderId');</script>"."\n";
68
+ $script .= '<script>var showButton = false;</script>'."\n";
69
+ }
70
+ else
71
+ {
72
+ $scriptAppend = '';
73
+ $script .= '<script>var showButton = true;</script>'."\n";
74
+ }
75
+ $script .= '<script src="//rfer.co/api/v1/js/all.js"></script>'."\n";
76
+ return $script.$scriptAppend;
77
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  }
app/code/community/Refiral/Campaign/etc/config.xml CHANGED
@@ -1,42 +1,54 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <modules>
4
- <Refiral_Campaign>
5
- <version>1.0.0</version>
6
- </Refiral_Campaign>
7
- </modules>
8
- <global>
9
- <blocks>
10
- <campaign>
11
- <class>Refiral_Campaign_Block</class>
12
- </campaign>
13
- </blocks>
14
- <helpers>
15
- <campaign>
16
- <class>Refiral_Campaign_Helper</class>
17
- </campaign>
18
- </helpers>
19
- <models>
20
- <campaign>
21
- <class>Refiral_Campaign_Model</class>
22
- </campaign>
23
- </models>
24
- </global>
25
- <frontend>
26
- <layout>
27
- <updates>
28
- <refiral>
29
- <file>refiral.xml</file>
30
- </refiral>
31
- </updates>
32
- </layout>
33
- </frontend>
34
- <default>
35
- <general>
36
- <campaign>
37
- <active>1</active>
38
- <title>Campaign</title>
39
- </campaign>
40
- </general>
41
- </default>
42
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Refiral_Campaign extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the MIT License
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/mit-license.php
12
+ *
13
+ * @category Refiral
14
+ * @package Refiral_Campaign
15
+ * @copyright Copyright (c) 2014
16
+ * @license http://opensource.org/licenses/mit-license.php MIT License
17
+ */
18
+ -->
19
+ <config>
20
+ <modules>
21
+ <Refiral_Campaign>
22
+ <version>1.0.4</version>
23
+ </Refiral_Campaign>
24
+ </modules>
25
+ <global>
26
+ <blocks>
27
+ <refiral_campaign>
28
+ <class>Refiral_Campaign_Block</class>
29
+ </refiral_campaign>
30
+ </blocks>
31
+ <helpers>
32
+ <campaign>
33
+ <class>Refiral_Campaign_Helper</class>
34
+ </campaign>
35
+ </helpers>
36
+ </global>
37
+ <frontend>
38
+ <layout>
39
+ <updates>
40
+ <refiral_campaign>
41
+ <file>refiral_campaign.xml</file>
42
+ </refiral_campaign>
43
+ </updates>
44
+ </layout>
45
+ </frontend>
46
+ <default>
47
+ <refiral_campaign>
48
+ <refiral>
49
+ <active>1</active>
50
+ <meta_title>Refiral Settings</meta_title>
51
+ </refiral>
52
+ </refiral_campaign>
53
+ </default>
54
+ </config>
app/code/community/Refiral/Campaign/etc/system.xml CHANGED
@@ -1,37 +1,54 @@
1
  <?xml version="1.0"?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  <config>
3
  <sections>
4
  <general>
5
  <groups>
6
- <campaign translate="label" module="campaign">
7
- <label>Refiral Campaign Settings</label>
8
- <frontend_type>text</frontend_type>
9
  <sort_order>0</sort_order>
10
  <show_in_default>1</show_in_default>
11
  <show_in_website>1</show_in_website>
12
  <show_in_store>1</show_in_store>
13
  <fields>
14
- <apikey translate="label">
15
- <label>API Key</label>
16
- <comment>You first need to create an account on Refiral.com and set-up your campaign to get API key.</comment>
17
- <frontend_type>text</frontend_type>
18
- <sort_order>1</sort_order>
19
- <show_in_default>1</show_in_default>
20
- <show_in_website>1</show_in_website>
21
- <show_in_store>0</show_in_store>
22
- </apikey>
23
  <active translate="label">
24
  <label>Enable Campaign</label>
25
  <frontend_type>select</frontend_type>
26
  <source_model>adminhtml/system_config_source_yesno</source_model>
27
- <sort_order>2</sort_order>
28
  <show_in_default>1</show_in_default>
29
  <show_in_website>1</show_in_website>
30
- <show_in_store>0</show_in_store>
31
  </active>
 
 
 
 
 
 
 
 
 
32
  </fields>
33
- </campaign>
34
  </groups>
35
  </general>
36
  </sections>
37
- </config>
1
  <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Refiral_Campaign extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the MIT License
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/mit-license.php
12
+ *
13
+ * @category Refiral
14
+ * @package Refiral_Campaign
15
+ * @copyright Copyright (c) 2014
16
+ * @license http://opensource.org/licenses/mit-license.php MIT License
17
+ */
18
+ -->
19
  <config>
20
  <sections>
21
  <general>
22
  <groups>
23
+ <refiral_campaign translate="label" module="campaign">
24
+ <label>Refiral Settings</label>
25
+ <frontend_type>text</frontend_type>
26
  <sort_order>0</sort_order>
27
  <show_in_default>1</show_in_default>
28
  <show_in_website>1</show_in_website>
29
  <show_in_store>1</show_in_store>
30
  <fields>
 
 
 
 
 
 
 
 
 
31
  <active translate="label">
32
  <label>Enable Campaign</label>
33
  <frontend_type>select</frontend_type>
34
  <source_model>adminhtml/system_config_source_yesno</source_model>
35
+ <sort_order>10</sort_order>
36
  <show_in_default>1</show_in_default>
37
  <show_in_website>1</show_in_website>
38
+ <show_in_store>1</show_in_store>
39
  </active>
40
+ <apikey translate="label comment">
41
+ <label>Refiral Key</label>
42
+ <frontend_type>text</frontend_type>
43
+ <sort_order>20</sort_order>
44
+ <show_in_default>1</show_in_default>
45
+ <show_in_website>1</show_in_website>
46
+ <show_in_store>1</show_in_store>
47
+ <comment><![CDATA[You first need to create an account on <a href="http://www.refiral.com" target="_blank">Refiral.com</a> and set-up your campaign to get API key.]]></comment>
48
+ </apikey>
49
  </fields>
50
+ </refiral_campaign>
51
  </groups>
52
  </general>
53
  </sections>
54
+ </config>
app/design/frontend/base/default/layout/refiral.xml DELETED
@@ -1,8 +0,0 @@
1
- <?xml version="1.0"?>
2
- <layout version="0.1.0">
3
- <default>
4
- <reference name="head">
5
- <block name="refiral" type="core/template" template="refiral/campaign.phtml"></block>
6
- </reference>
7
- </default>
8
- </layout>
 
 
 
 
 
 
 
 
app/design/frontend/base/default/layout/refiral_campaign.xml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Refiral_Campaign extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the MIT License
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/mit-license.php
12
+ *
13
+ * @category Refiral
14
+ * @package Refiral_Campaign
15
+ * @copyright Copyright (c) 2014
16
+ * @license http://opensource.org/licenses/mit-license.php MIT License
17
+ */
18
+ -->
19
+ <layout>
20
+ <default>
21
+ <reference name="head">
22
+ <block name="refiral" type="core/template" template="refiral_campaign/campaign.phtml"></block>
23
+ </reference>
24
+ </default>
25
+ </layout>
app/design/frontend/base/default/template/{Refiral → refiral_campaign}/campaign.phtml RENAMED
@@ -1,23 +1,25 @@
1
- <script type="text/javascript">
2
- if ( (typeof jQuery === 'undefined') && !window.jQuery )
3
- {
4
- document.write(unescape("%3Cscript type='text/javascript' src='http://code.jquery.com/jquery-latest.min.js'%3E%3C/script%3E"));
5
- }
6
- else
7
- {
8
- if((typeof jQuery === 'undefined') && window.jQuery)
9
- {
10
- jQuery = window.jQuery;
11
- }
12
- else if((typeof jQuery !== 'undefined') && !window.jQuery)
13
- {
14
- window.jQuery = jQuery;
15
- }
16
- }
17
- </script>
18
- <script>var $j = jQuery.noConflict();</script>
19
- <?php
20
- $_helper = Mage::helper('campaign');
21
- if($_helper->isActive())
22
- echo $_helper->getScript();
23
- ?>
 
 
1
+ <!-- Refiral Campaign Code Begin -->
2
+ <script type="text/javascript">
3
+ if ( (typeof jQuery === 'undefined') && !window.jQuery )
4
+ {
5
+ document.write(unescape("%3Cscript type='text/javascript' src='http://code.jquery.com/jquery-latest.min.js'%3E%3C/script%3E"));
6
+ }
7
+ else
8
+ {
9
+ if((typeof jQuery === 'undefined') && window.jQuery)
10
+ {
11
+ jQuery = window.jQuery;
12
+ }
13
+ else if((typeof jQuery !== 'undefined') && !window.jQuery)
14
+ {
15
+ window.jQuery = jQuery;
16
+ }
17
+ }
18
+ </script>
19
+ <script>var $j = jQuery.noConflict();</script>
20
+ <?php
21
+ $_helper = Mage::helper('campaign');
22
+ if($_helper->isActive())
23
+ echo $_helper->getScript();
24
+ ?>
25
+ <!-- Refiral Campaign Code End -->
app/etc/modules/Refiral_Campaign.xml CHANGED
@@ -1,9 +1,29 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <modules>
4
- <Refiral_Campaign>
5
- <active>true</active>
6
- <codePool>community</codePool>
7
- </Refiral_Campaign>
8
- </modules>
9
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Refiral_Campaign extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the MIT License
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/mit-license.php
12
+ *
13
+ * @category Refiral
14
+ * @package Refiral_Campaign
15
+ * @copyright Copyright (c) 2014
16
+ * @license http://opensource.org/licenses/mit-license.php MIT License
17
+ */
18
+ -->
19
+ <config>
20
+ <modules>
21
+ <Refiral_Campaign>
22
+ <active>true</active>
23
+ <codePool>community</codePool>
24
+ <depends>
25
+ <Mage_Core />
26
+ </depends>
27
+ </Refiral_Campaign>
28
+ </modules>
29
+ </config>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Refiral</name>
4
- <version>1.0.3</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.gnu.org/licenses/gpl-3.0-standalone.html">GPLv3</license>
7
  <channel>community</channel>
@@ -10,9 +10,9 @@
10
  <description>Boost your sales up to 3X with our new hybrid marketing channel. Run your personalized, easy to integrate fully automated referral program.</description>
11
  <notes>Stable version of Refiral extension.</notes>
12
  <authors><author><name>Refiral</name><user>refiral</user><email>support@refiral.com</email></author></authors>
13
- <date>2014-06-17</date>
14
- <time>14:14:54</time>
15
- <contents><target name="magecommunity"><dir name="Refiral"><dir name="Campaign"><dir name="Helper"><file name="Data.php" hash="e18360938c6c71bbc1f130047be936ce"/></dir><dir name="etc"><file name="config.xml" hash="52b5e1071e6076e8c988457470eb2a94"/><file name="system.xml" hash="c06478f003c118dee930380be2eb5af2"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="refiral.xml" hash="cfa836379eb2dff10a1d49f6d1e68f25"/></dir><dir name="template"><dir name="Refiral"><file name="campaign.phtml" hash="644f808bc08fda3b9a8f363eb77c0c34"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Refiral_Campaign.xml" hash="46ccfad98a5e7cba5fdc3cf5e8e3a003"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Refiral</name>
4
+ <version>1.0.4</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.gnu.org/licenses/gpl-3.0-standalone.html">GPLv3</license>
7
  <channel>community</channel>
10
  <description>Boost your sales up to 3X with our new hybrid marketing channel. Run your personalized, easy to integrate fully automated referral program.</description>
11
  <notes>Stable version of Refiral extension.</notes>
12
  <authors><author><name>Refiral</name><user>refiral</user><email>support@refiral.com</email></author></authors>
13
+ <date>2014-07-29</date>
14
+ <time>14:06:24</time>
15
+ <contents><target name="magecommunity"><dir name="Refiral"><dir name="Campaign"><dir name="Block"><file name="default.php" hash="39f687630fe10bbed1d15c069a7f1817"/></dir><dir name="Helper"><file name="Data.php" hash="a3ba5ebebcba5b8ab2d13e2e5c2aca74"/></dir><dir name="etc"><file name="config.xml" hash="9850240b5844d7ef003c1690225d787e"/><file name="system.xml" hash="06279a67e93961ea78c5c2cfa207c00d"/></dir></dir></dir></target><target name="magedesign"><dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="refiral_campaign"><file name="campaign.phtml" hash="2e7df9680f6eb266957f7b47e1a19ddc"/></dir></dir><dir name="layout"><file name="refiral_campaign.xml" hash="273dfeba936c497c90679a1c94225278"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir><dir name="modules"><file name="Refiral_Campaign.xml" hash="5cfba36effdd31e490eca65ae5086925"/></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>