Shopa_ShareAndEarn - Version 0.0.1

Version Notes

First version

Download this release

Release Info

Developer Tim Macfarlane
Extension Shopa_ShareAndEarn
Version 0.0.1
Comparing to
See all releases


Version 0.0.1

app/code/community/Shopa/ShareAndEarn/Block/Button.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Shopa Button
4
+ *
5
+ * @author Shopa
6
+ */
7
+ class Shopa_ShareAndEarn_Block_Button extends Mage_Catalog_Block_Product_Abstract
8
+ {
9
+ public function getCommission() {
10
+ return Mage::getStoreConfig('shopa_shareandearn_options/commission/percentage') . '%';
11
+ }
12
+
13
+ public function getPrice() {
14
+ return $this->getPriceInclTax();
15
+ }
16
+
17
+ public function getCurrency() {
18
+ return 'GBP';
19
+ }
20
+
21
+ public function getIsButtonVisible() {
22
+ $show_button = Mage::getStoreConfig('shopa_shareandearn_options/commission/show_button');
23
+ return $show_button;
24
+ }
25
+
26
+ public function getApiKey() {
27
+ return Mage::getStoreConfig('shopa_shareandearn_options/security/api_key');
28
+ }
29
+
30
+ public function getSignature() {
31
+ $commission = $this->getCommission();
32
+ $price = $this->getPrice();
33
+ $currency = $this->getCurrency();
34
+ $apiKey = $this->getApiKey();
35
+ $apiSecret = Mage::getStoreConfig('shopa_shareandearn_options/security/api_secret');
36
+
37
+ $data = "$commission:$price:$currency:$apiKey:$apiSecret";
38
+ return sha1($data);
39
+ }
40
+
41
+ public function getPriceInclTax() {
42
+ $product = $this->getProduct();
43
+ return $this->helper('tax')->getPrice($product, $product->getFinalPrice(), true);
44
+ }
45
+
46
+ public function getButtonUrl() {
47
+ return Mage::getStoreConfig('shopa_shareandearn_options/advanced/shopa_base_url') . "btn.js";
48
+ }
49
+ }
app/code/community/Shopa/ShareAndEarn/Block/Success.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <?php
3
+ /**
4
+ * Shopa Button
5
+ *
6
+ * @author Shopa
7
+ */
8
+ class Shopa_ShareAndEarn_Block_Success extends Mage_Core_Block_Template
9
+ {
10
+ public function getCommission() {
11
+ return Mage::getStoreConfig('shopa_shareandearn_options/commission/percentage') . '%';
12
+ }
13
+
14
+ public function getSignature() {
15
+ $commission = $this->getCommission();
16
+ $price = $this->getPrice();
17
+ $currency = $this->getCurrency();
18
+ $orderId = $this->getOrderId();
19
+ $apiKey = $this->getApiKey();
20
+ $apiSecret = Mage::getStoreConfig('shopa_shareandearn_options/security/api_secret');
21
+
22
+ $data = "$commission:$price:$currency:$orderId:$apiKey:$apiSecret";
23
+ return sha1($data);
24
+ }
25
+
26
+ public function getApiKey() {
27
+ return Mage::getStoreConfig('shopa_shareandearn_options/security/api_key');
28
+ }
29
+
30
+ public function getOrderId() {
31
+ return Mage::getSingleton('checkout/session')->getLastOrderId();
32
+ }
33
+
34
+ public function getPrice() {
35
+ return $this->getSubtotalInclTax();
36
+ }
37
+
38
+ public function getCurrency() {
39
+ return 'GBP';
40
+ }
41
+
42
+ public function getSubtotalInclTax() {
43
+ $orderId = $this->getOrderId();
44
+ if ($orderId) {
45
+ $order = Mage::getModel('sales/order')->load($orderId);
46
+ return $order->getSubtotalInclTax();
47
+ } else {
48
+ return 0.0;
49
+ }
50
+ }
51
+
52
+ public function getButtonUrl() {
53
+ return Mage::getStoreConfig('shopa_shareandearn_options/advanced/shopa_base_url') . "btn.js";
54
+ }
55
+ }
app/code/community/Shopa/ShareAndEarn/Helper/Data.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // This doesn't actually do anything, but Magento expects it to be here
4
+ // anyway.
5
+ //
6
+ // See http://alanstorm.com/custom_magento_system_configuration.
7
+
8
+ class Shopa_ShareAndEarn_Helper_Data extends Mage_Core_Helper_Abstract
9
+ {
10
+ }
app/code/community/Shopa/ShareAndEarn/etc/config.xml ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Shopa_ShareAndEarn>
5
+ <version>1.0.0.0.1</version>
6
+ </Shopa_ShareAndEarn>
7
+ </modules>
8
+ <global>
9
+ <blocks>
10
+ <shopa_shareandearn>
11
+ <class>Shopa_ShareAndEarn_Block</class>
12
+ </shopa_shareandearn>
13
+ </blocks>
14
+ <helpers>
15
+ <shopa_shareandearn>
16
+ <class>Shopa_ShareAndEarn_Helper</class>
17
+ </shopa_shareandearn>
18
+ </helpers>
19
+ <models>
20
+ <shopa_shareandearn>
21
+ <class>Shopa_ShareAndEarn_Model</class>
22
+ </shopa_shareandearn>
23
+ </models>
24
+ </global>
25
+ <frontend>
26
+ <layout>
27
+ <updates>
28
+ <shopa_shareandearn>
29
+ <file>shopa_shareandearn.xml</file>
30
+ </shopa_shareandearn>
31
+ </updates>
32
+ </layout>
33
+ </frontend>
34
+ <adminhtml>
35
+ <acl>
36
+ <resources>
37
+ <admin>
38
+ <children>
39
+ <system>
40
+ <children>
41
+ <config>
42
+ <children>
43
+ <shopa_shareandearn_options>
44
+ <title>Shopa Share and Earn Section</title>
45
+ </shopa_shareandearn_options>
46
+ </children>
47
+ </config>
48
+ </children>
49
+ </system>
50
+ </children>
51
+ </admin>
52
+ </resources>
53
+ </acl>
54
+ </adminhtml>
55
+ <default>
56
+ <shopa_shareandearn_options>
57
+ <commission>
58
+ <percentage>10</percentage>
59
+ <show_button>1</show_button>
60
+ </commission>
61
+ <security>
62
+ <api_secret>get your API secret from http://www.shopa.com/account/retailer</api_secret>
63
+ <api_key>get your API key from http://www.shopa.com/account/retailer</api_key>
64
+ </security>
65
+ <advanced>
66
+ <shopa_base_url>//cdn.shopa.com/</shopa_base_url>
67
+ </advanced>
68
+ </shopa_shareandearn_options>
69
+ </default>
70
+ </config>
app/code/community/Shopa/ShareAndEarn/etc/system.xml ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <config>
2
+ <tabs>
3
+ <shopa_shareandearn_tab translate="label" module="shopa_shareandearn">
4
+ <label>Shopa</label>
5
+ <sort_order>99999</sort_order>
6
+ </shopa_shareandearn_tab>
7
+ </tabs>
8
+ <sections>
9
+ <shopa_shareandearn_options translate="label" module="shopa_shareandearn">
10
+ <label>Share and Earn</label>
11
+ <tab>shopa_shareandearn_tab</tab>
12
+ <frontend_type>text</frontend_type>
13
+ <sort_order>1000</sort_order>
14
+ <show_in_default>1</show_in_default>
15
+ <show_in_website>1</show_in_website>
16
+ <show_in_store>1</show_in_store>
17
+ <groups>
18
+ <commission translate="label">
19
+ <label>Commission Settings</label>
20
+ <frontend_type>text</frontend_type>
21
+ <sort_order>1</sort_order>
22
+ <show_in_default>1</show_in_default>
23
+ <show_in_website>1</show_in_website>
24
+ <show_in_store>1</show_in_store>
25
+ <fields>
26
+ <percentage>
27
+ <label>Percentage</label>
28
+ <frontend_type>text</frontend_type>
29
+ <sort_order>1</sort_order>
30
+ <show_in_default>1</show_in_default>
31
+ <show_in_website>1</show_in_website>
32
+ <show_in_store>1</show_in_store>
33
+ <validate>validate-percents</validate>
34
+ </percentage>
35
+ </fields>
36
+ <fields>
37
+ <show_button>
38
+ <label>Show Button</label>
39
+ <frontend_type>select</frontend_type>
40
+ <source_model>adminhtml/system_config_source_yesno</source_model>
41
+ <sort_order>2</sort_order>
42
+ <show_in_default>1</show_in_default>
43
+ <show_in_website>1</show_in_website>
44
+ <show_in_store>1</show_in_store>
45
+ </show_button>
46
+ </fields>
47
+ </commission>
48
+ <security translate="label">
49
+ <label>Security</label>
50
+ <frontend_type>text</frontend_type>
51
+ <sort_order>2</sort_order>
52
+ <show_in_default>1</show_in_default>
53
+ <show_in_website>1</show_in_website>
54
+ <show_in_store>1</show_in_store>
55
+ <fields>
56
+ <api_key>
57
+ <label>API Key</label>
58
+ <frontend_type>text</frontend_type>
59
+ <sort_order>1</sort_order>
60
+ <show_in_default>1</show_in_default>
61
+ <show_in_website>1</show_in_website>
62
+ <show_in_store>1</show_in_store>
63
+ </api_key>
64
+ <api_secret>
65
+ <label>API Secret</label>
66
+ <frontend_type>text</frontend_type>
67
+ <sort_order>2</sort_order>
68
+ <show_in_default>1</show_in_default>
69
+ <show_in_website>1</show_in_website>
70
+ <show_in_store>1</show_in_store>
71
+ </api_secret>
72
+ </fields>
73
+ </security>
74
+ <advanced translate="label">
75
+ <label>Advanced</label>
76
+ <frontend_type>text</frontend_type>
77
+ <sort_order>3</sort_order>
78
+ <show_in_default>1</show_in_default>
79
+ <show_in_website>1</show_in_website>
80
+ <show_in_store>1</show_in_store>
81
+ <fields>
82
+ <shopa_base_url>
83
+ <label>Shopa Base URL</label>
84
+ <frontend_type>text</frontend_type>
85
+ <sort_order>1</sort_order>
86
+ <show_in_default>1</show_in_default>
87
+ <show_in_website>1</show_in_website>
88
+ <show_in_store>1</show_in_store>
89
+ </shopa_base_url>
90
+ </fields>
91
+ </advanced>
92
+ </groups>
93
+ </shopa_shareandearn_options>
94
+ </sections>
95
+ </config>
app/design/frontend/base/default/layout/shopa_shareandearn.xml ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Shopa
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
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/osl-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 license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @category design
17
+ * @package base_default
18
+ * @copyright Copyright (c) 2012 Shopa Ltd
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ -->
23
+ <layout version="0.1.0">
24
+ <!-- we need one of these elements for each product type (simple, configurable, virtual, group, and a maybe a couple others) -->
25
+ <PRODUCT_TYPE_simple>
26
+ <!-- if we want it above the price -->
27
+ <reference name="product.info.simple.extra">
28
+ <block type="shopa_shareandearn/button" name="shopa.shareandearn.button" template="shopa_shareandearn/button.phtml" />
29
+ </reference>
30
+ <!-- if we want it underneath the price -->
31
+ <!--
32
+ <reference name="product.info">
33
+ <block type="core/text_list" name="shopa.price" as="product_type_data">
34
+ <block type="catalog/product_view_type_configurable" name="product.info.configurable" as="product_type_data" template="catalog/product/view/type/default.phtml">
35
+ <block type="core/text_list" name="product.info.configurable.extra" as="product_type_data_extra" translate="label">
36
+ <label>Product Extra Info</label>
37
+ </block>
38
+ </block>
39
+ <block type="shopa_shareandearn/button" name="shopa.shareandearn.button" template="shopa_shareandearn/button.phtml" />
40
+ </block>
41
+ </reference>
42
+ -->
43
+ </PRODUCT_TYPE_simple>
44
+ <PRODUCT_TYPE_configurable>
45
+ <reference name="product.info.configurable.extra">
46
+ <block type="shopa_shareandearn/button" name="shopa.shareandearn.button" template="shopa_shareandearn/button.phtml" />
47
+ </reference>
48
+ </PRODUCT_TYPE_configurable>
49
+ <checkout_onepage_success translate="label">
50
+ <reference name="content">
51
+ <block type="shopa_shareandearn/success" name="shopa.shareandearn.success" template="shopa_shareandearn/success.phtml"/>
52
+ </reference>
53
+ </checkout_onepage_success>
54
+ </layout>
app/design/frontend/base/default/template/shopa_shareandearn/button.phtml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Shopa
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 license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2012 Shopa Ltd
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ if ($this->getIsButtonVisible()) {
28
+ $displayNone = '';
29
+ } else {
30
+ $displayNone = 'display: none;';
31
+ }
32
+ ?>
33
+ <button
34
+ class="shopa_se"
35
+ data-commission="<?php echo $this->getCommission() ?>"
36
+ data-price="<?php echo $this->getPriceInclTax() ?>"
37
+ data-currency="<?php echo $this->getCurrency() ?>"
38
+ data-api-key="<?php echo $this->getApiKey() ?>"
39
+ data-signature="<?php echo $this->getSignature() ?>"
40
+ style="<?php echo $displayNone; ?>visibility:hidden;width:143px;height:20px;border:none;float:right">
41
+ </button>
42
+ <script type="text/javascript" defer async=true src="<?php echo $this->getButtonUrl() ?>"></script>
app/design/frontend/base/default/template/shopa_shareandearn/success.phtml ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Shopa
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 license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2012 Shopa Ltd
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <input id="shopa_success" type="hidden"
28
+ data-commission="<?php echo $this->getCommission() ?>"
29
+ data-price="<?php echo $this->getPrice() ?>"
30
+ data-currency="<?php echo $this->getCurrency() ?>"
31
+ data-order-id="<?php echo $this->getOrderId() ?>"
32
+ data-api-key="<?php echo $this->getApiKey() ?>"
33
+ data-signature="<?php echo $this->getSignature() ?>" />
34
+ <script type="text/javascript" defer async=true src="<?php echo $this->getButtonUrl() ?>"></script>
app/etc/modules/Shopa_ShareAndEarn.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Shopa_ShareAndEarn>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Shopa_ShareAndEarn>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Shopa_ShareAndEarn</name>
4
+ <version>0.0.1</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.apache.org/licenses/LICENSE-2.0">Apache Software License (ASL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Adding shopa and its &#x2018;share &amp; earn&#x2019; tools to your retail site allows you to financially incentivize users to recommend your products to their networks and friends.</summary>
10
+ <description>With the addition of shopa&#x2019;s &#x2018;share &amp; earn&#x2019; tools, users of retail sites can easily share product suggestions with friends and then split a commission reward from the retailer 50/50 with anyone who buys.&#xD;
11
+ &#xD;
12
+ Financially incentivised users virally spread links to products they like to their personal networks, whilst online retailers benefit from additional sales through the recommendation of friends.&#xD;
13
+ &#xD;
14
+ Retailers only pay commissions to their users on a success basis. Utilising a financially incentivised community to promote products on their behalf, this &#x2018;no sale, no pay&#x2019; model allows retailers to reach as many people as possible as often and as cost effectively as possible.</description>
15
+ <notes>First version</notes>
16
+ <authors><author><name>Tim Macfarlane</name><user>featuristtim</user><email>tim@featurist.co.uk</email></author><author><name>Zi Makki</name><user>zmakki</user><email>zimakki@gmail.com</email></author></authors>
17
+ <date>2012-09-14</date>
18
+ <time>10:30:02</time>
19
+ <contents><target name="magecommunity"><dir name="Shopa"><dir name="ShareAndEarn"><dir name="Block"><file name="Button.php" hash="b9ffcdc5dca857e3b9bd219a50927b60"/><file name="Success.php" hash="c390f4fea9282a229fda27a762977837"/></dir><dir name="Helper"><file name="Data.php" hash="a2021ecd6e69f5bc3fcda9e4a97c1015"/></dir><dir name="etc"><file name="config.xml" hash="b67634e93a8a15eea2836eafee6978df"/><file name="system.xml" hash="638cce9e1e680b934cbc4c7916660e94"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="shopa_shareandearn.xml" hash="b172fd0820f4686029324ff4d16b5e5f"/></dir><dir name="template"><dir name="shopa_shareandearn"><file name="button.phtml" hash="c8eb9a4bde20e02b6c4ed2f3cf163353"/><file name="success.phtml" hash="1cf5547bdc66ec4d9b03930c3d696248"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Shopa_ShareAndEarn.xml" hash="7b5d8070ab388fb380977138e00e02df"/></dir></target><target name="magelocal"><dir/></target></contents>
20
+ <compatible/>
21
+ <dependencies><required><php><min>4.3.0</min><max>6.0.0</max></php></required></dependencies>
22
+ </package>