Version Notes
Stable Version of Refiral Plugin
Download this release
Release Info
Developer | Refiral |
Extension | Refiral |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/local/Refiral/Campaign/Block/Campaign.php +56 -0
- app/code/local/Refiral/Campaign/Block/Checkout.php +38 -0
- app/code/local/Refiral/Campaign/Helper/Data.php +11 -0
- app/code/local/Refiral/Campaign/etc/config.xml +54 -0
- app/code/local/Refiral/Campaign/etc/system.xml +37 -0
- app/design/frontend/default/default/layout/campaign.xml +15 -0
- app/etc/modules/Refiral_Campaign.xml +9 -0
- package.xml +18 -0
app/code/local/Refiral/Campaign/Block/Campaign.php
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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()); // Get grand total
|
20 |
+
$order_coupon = $order->getCouponCode(); // Get coupon used
|
21 |
+
$items = $order->getAllItems(); // Get items info
|
22 |
+
$cartInfo = '';
|
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 .= $name.'-'.$qty. ', ';
|
29 |
+
}
|
30 |
+
$order_name = $order->getCustomerName(); // Get customer's name
|
31 |
+
$order_email = $order->getCustomerEmail(); // Get customer's email id
|
32 |
+
|
33 |
+
// Call invoiceRefiral function
|
34 |
+
echo "<script>invoiceRefiral('$order_total', '$order_total', '$order_coupon', '$cartInfo', '$order_name', '$order_email');</script>";
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
}
|
app/code/local/Refiral/Campaign/Helper/Data.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
ADDED
@@ -0,0 +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 |
+
<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>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>Loyalty</title>
|
50 |
+
</campaign>
|
51 |
+
</general>
|
52 |
+
</default>
|
53 |
+
|
54 |
+
</config>
|
app/code/local/Refiral/Campaign/etc/system.xml
ADDED
@@ -0,0 +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>
|
app/design/frontend/default/default/layout/campaign.xml
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
ADDED
@@ -0,0 +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>
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Refiral</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license>GPLv2</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 Plugin</notes>
|
12 |
+
<authors><author><name>Refiral</name><user>refiral</user><email>support@refiral.com</email></author></authors>
|
13 |
+
<date>2014-03-17</date>
|
14 |
+
<time>18:52:26</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="cc52343f76647bf22ba325bd47fdd741"/></dir><dir name="Helper"><file name="Data.php" hash="fa55e018e847a099126b48b719c91bb5"/></dir><dir name="etc"><file name="config.xml" hash="d33e0e8e0b2cdb43ae26e8249b222102"/><file name="system.xml" hash="4ebb1f08d22f90878915eb5fc4dd7370"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="campaign.xml" hash="7a11d660175f9de93949f9e290a2d48f"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Refiral_Campaign.xml" hash="58b93da6e3a823bbdd7c6f8fb94551e9"/></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
+
</package>
|