Refiral - Version 1.0.3

Version Notes

Stable version of Refiral extension.

Download this release

Release Info

Developer Refiral
Extension Refiral
Version 1.0.3
Comparing to
See all releases


Code changes from version 1.0.2 to 1.0.3

app/code/community/Refiral/Campaign/Helper/Data.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ }
app/code/community/Refiral/Campaign/etc/config.xml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>
app/code/{local → community}/Refiral/Campaign/etc/system.xml RENAMED
@@ -1,37 +1,37 @@
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
+ <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>
app/code/local/Refiral/Campaign/Block/Campaign.php DELETED
@@ -1,56 +0,0 @@
1
- <?php
2
- /**
3
- * @author Refiral
4
- * @copyright Copyright (c) 2014 Refiral
5
- * @license GPLv2
6
- */
7
-
8
- class Refiral_Campaign_Block_Campaign extends Mage_Core_Block_Template
9
- {
10
- protected function _toHtml()
11
- {
12
- $campaignActive = Mage::getStoreConfig('general/campaign/active');
13
- // Check if campaign is enabled
14
- if(!empty($campaignActive))
15
- {
16
- // Get API Key
17
- $apiKey = Mage::getStoreConfig('general/campaign/apikey');
18
-
19
- /** Make sure jQuery is included **/
20
- ?>
21
- <script type="text/javascript">
22
- if ( (typeof jQuery === 'undefined') && !window.jQuery )
23
- {
24
- document.write(unescape("%3Cscript type='text/javascript' src='http://code.jquery.com/jquery-latest.min.js'%3E%3C/script%3E"));
25
- }
26
- else
27
- {
28
- if((typeof jQuery === 'undefined') && window.jQuery)
29
- {
30
- jQuery = window.jQuery;
31
- }
32
- else if((typeof jQuery !== 'undefined') && !window.jQuery)
33
- {
34
- window.jQuery = jQuery;
35
- }
36
- }
37
- </script>
38
- <script>
39
- var $j = jQuery.noConflict();
40
- </script>
41
- <?php
42
- /**********************************/
43
- $request = $this->getRequest();
44
- $module = $request->getModuleName();
45
- $controller = $request->getControllerName();
46
- $action = $request->getActionName();
47
- echo "<script>var apiKey = '$apiKey';</script>";
48
- if ($module == 'checkout' && $controller == 'onepage' && $action == 'success'){
49
- echo '<script>var showButton = false;</script>';
50
- }
51
- else
52
- echo '<script>var showButton = true;</script>';
53
- echo '<script src="http://refiral.com/api/all.js"></script>';
54
- }
55
- }
56
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Refiral/Campaign/Block/Checkout.php DELETED
@@ -1,39 +0,0 @@
1
- <?php
2
- /**
3
- * @author Refiral
4
- * @copyright Copyright (c) 2014 Refiral
5
- * @license GPLv2
6
- */
7
-
8
- class Refiral_Campaign_Block_Checkout extends Mage_Core_Block_Template
9
- {
10
- protected function _toHtml()
11
- {
12
- $campaignActive = Mage::getStoreConfig('general/campaign/active');
13
- // Check if campaign is enabled
14
- if(!empty($campaignActive))
15
- {
16
- $order = new Mage_Sales_Model_Order();
17
- $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
18
- $order->loadByIncrementId($orderId); // Load order details
19
- $order_total = round($order->getGrandTotal(), 2); // Get grand total
20
- $order_coupon = $order->getCouponCode(); // Get coupon used
21
- $items = $order->getAllItems(); // Get items info
22
- $cartInfo = array();
23
- // Convert object to string
24
- foreach($items as $item) {
25
- $product = Mage::getModel('catalog/product')->load($item->getProductId());
26
- $name = $item->getName();
27
- $qty = $item->getQtyToInvoice();
28
- $cartInfo[] = array('id' => $item->getProductId(), 'name' => $name, 'quantity' => $qty);
29
- }
30
- $cartInfoString = serialize($cartInfo);
31
- $order_name = $order->getCustomerName(); // Get customer's name
32
- $order_email = $order->getCustomerEmail(); // Get customer's email id
33
-
34
- // Call invoiceRefiral function
35
- echo "<script>invoiceRefiral('$order_total', '$order_total', '$order_coupon', '$cartInfoString', '$order_name', '$order_email');</script>";
36
- }
37
- }
38
-
39
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Refiral/Campaign/Helper/Data.php DELETED
@@ -1,11 +0,0 @@
1
- <?php
2
- /**
3
- * @author Refiral
4
- * @copyright Copyright (c) 2014 Refiral
5
- * @license GPLv2
6
- */
7
-
8
- class Refiral_Campaign_Helper_Data extends Mage_Core_Helper_Abstract
9
- {
10
-
11
- }
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Refiral/Campaign/etc/config.xml DELETED
@@ -1,54 +0,0 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <modules>
4
- <Refiral_Campaign>
5
- <version>1.0.2</version>
6
- </Refiral_Campaign>
7
- </modules>
8
- <frontend>
9
- <routers>
10
- <campaign>
11
- <use>standard</use>
12
- <args>
13
- <module>Refiral_Campaign</module>
14
- <frontName>campaign</frontName>
15
- </args>
16
- </campaign>
17
- </routers>
18
- <layout>
19
- <updates>
20
- <campaign>
21
- <file>refiral_campaign.xml</file>
22
- </campaign>
23
- </updates>
24
- </layout>
25
- </frontend>
26
- <global>
27
- <models>
28
- <campaign>
29
- <class>Refiral_Campaign_Model</class>
30
- </campaign>
31
- </models>
32
- <resources>
33
- </resources>
34
- <blocks>
35
- <campaign>
36
- <class>Refiral_Campaign_Block</class>
37
- </campaign>
38
- </blocks>
39
- <helpers>
40
- <campaign>
41
- <class>Refiral_Campaign_Helper</class>
42
- </campaign>
43
- </helpers>
44
- </global>
45
- <default>
46
- <general>
47
- <campaign>
48
- <active>1</active>
49
- <title>Campaign</title>
50
- </campaign>
51
- </general>
52
- </default>
53
-
54
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/layout/refiral.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
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/template/Refiral/campaign.phtml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ ?>
app/design/frontend/default/default/layout/refiral_campaign.xml DELETED
@@ -1,15 +0,0 @@
1
- <?xml version="1.0"?>
2
- <layout version="1.0.0">
3
- <default>
4
- <reference name="head" >
5
- <block type="campaign/campaign" name="campaign" >
6
- </block>
7
- </reference>
8
- </default>
9
- <checkout_onepage_success>
10
- <reference name="before_body_end" >
11
- <block type="campaign/checkout" name="checkout" >
12
- </block>
13
- </reference>
14
- </checkout_onepage_success>
15
- </layout>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/etc/modules/Refiral_Campaign.xml CHANGED
@@ -1,9 +1,9 @@
1
  <?xml version="1.0"?>
2
  <config>
3
- <modules>
4
- <Refiral_Campaign>
5
- <active>true</active>
6
- <codePool>local</codePool>
7
- </Refiral_Campaign>
8
- </modules>
9
- </config>
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>
package.xml CHANGED
@@ -1,18 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Refiral</name>
4
- <version>1.0.2</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.gnu.org/licenses/gpl-3.0-standalone.html">GPLv3</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>Launch your referral campaign virally.</summary>
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-05-29</date>
14
- <time>04:35:06</time>
15
- <contents><target name="magelocal"><dir name="Refiral"><dir name="Campaign"><dir name="Block"><file name="Campaign.php" hash="7d44a27e546f73d808b5e25b14ae8e0e"/><file name="Checkout.php" hash="f678586e1c978beb46f3b81511b23a03"/></dir><dir name="Helper"><file name="Data.php" hash="fa55e018e847a099126b48b719c91bb5"/></dir><dir name="etc"><file name="config.xml" hash="96f78200d264a0a6c2a581ec32f50876"/><file name="system.xml" hash="4ebb1f08d22f90878915eb5fc4dd7370"/></dir></dir></dir></target><target name="magedesign"><dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="refiral_campaign.xml" hash="7a11d660175f9de93949f9e290a2d48f"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir><dir name="modules"><file name="Refiral_Campaign.xml" hash="58b93da6e3a823bbdd7c6f8fb94551e9"/></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>
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>
8
  <extends/>
9
+ <summary>Launch your referral campaigns virally.</summary>
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>