Shopa_ShareAndEarn - Version 0.0.5

Version Notes

Adding product urls and order email to button api

Download this release

Release Info

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


Code changes from version 0.0.4 to 0.0.5

app/code/community/Shopa/ShareAndEarn/Block/Success.php CHANGED
@@ -1,4 +1,3 @@
1
-
2
  <?php
3
  /**
4
  * Shopa Button
@@ -16,10 +15,11 @@ class Shopa_ShareAndEarn_Block_Success extends Mage_Core_Block_Template
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
 
@@ -31,6 +31,15 @@ class Shopa_ShareAndEarn_Block_Success extends Mage_Core_Block_Template
31
  return Mage::getSingleton('checkout/session')->getLastOrderId();
32
  }
33
 
 
 
 
 
 
 
 
 
 
34
  public function getPrice() {
35
  return $this->getSubtotalInclTax();
36
  }
@@ -39,16 +48,43 @@ class Shopa_ShareAndEarn_Block_Success extends Mage_Core_Block_Template
39
  return Mage::app()->getStore()->getCurrentCurrencyCode();
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
  }
 
1
  <?php
2
  /**
3
  * Shopa Button
15
  $price = $this->getPrice();
16
  $currency = $this->getCurrency();
17
  $orderId = $this->getOrderId();
18
+ $orderEmail = $this->getOrderEmail();
19
  $apiKey = $this->getApiKey();
20
  $apiSecret = Mage::getStoreConfig('shopa_shareandearn_options/security/api_secret');
21
 
22
+ $data = "$commission:$price:$currency:$orderId:$orderEmail$apiKey:$apiSecret";
23
  return sha1($data);
24
  }
25
 
31
  return Mage::getSingleton('checkout/session')->getLastOrderId();
32
  }
33
 
34
+ public function getOrderEmail()
35
+ {
36
+ if ($this->getOrderId()) {
37
+ return $this->getOrder()->getCustomerEmail();
38
+ } else {
39
+ return '';
40
+ }
41
+ }
42
+
43
  public function getPrice() {
44
  return $this->getSubtotalInclTax();
45
  }
48
  return Mage::app()->getStore()->getCurrentCurrencyCode();
49
  }
50
 
51
+ public function getOrder() {
52
+ $orderId = $this->getOrderId();
53
+ return Mage::getModel('sales/order')->load($orderId);
54
+ }
55
+
56
+ public function getSubtotalInclTax() {;
57
+ if ($this->getOrderId()) {
58
+ return $this->getOrder()->getSubtotalInclTax();
59
  } else {
60
  return 0.0;
61
  }
62
  }
63
 
64
+ public function getProductUrls()
65
+ {
66
+ if (!$this->getOrderId()) {
67
+ return array();
68
+ } else {
69
+ $order = $this->getOrder();
70
+
71
+ $productIds = array();
72
+ foreach ($order->getAllItems() as $item) {
73
+ $productIds[] = $item->getProductId();
74
+ }
75
+
76
+ $productCollection = Mage::getModel('catalog/product')->getCollection()
77
+ ->addIdFilter($productIds)
78
+ ->load();
79
+
80
+ $productUrls = array();
81
+ foreach ($productCollection as $product) {
82
+ $productUrls[] = $product->getProductUrl();
83
+ }
84
+ return $productUrls;
85
+ }
86
+ }
87
+
88
  public function getButtonUrl() {
89
  return Mage::getStoreConfig('shopa_shareandearn_options/advanced/shopa_base_url') . "btn.js";
90
  }
app/design/frontend/base/default/template/shopa_shareandearn/success.phtml CHANGED
@@ -23,12 +23,21 @@
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>
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
  ?>
28
  <input id="shopa_success" type="hidden"
29
  data-commission="<?php echo $this->getCommission() ?>"
30
  data-price="<?php echo $this->getPrice() ?>"
31
  data-currency="<?php echo $this->getCurrency() ?>"
32
  data-order-id="<?php echo $this->getOrderId() ?>"
33
+ data-order-email="<?php echo $this->getOrderEmail() ?>"
34
  data-api-key="<?php echo $this->getApiKey() ?>"
35
  data-signature="<?php echo $this->getSignature() ?>" />
36
+ <?php
37
+ $productUrls = '';
38
+ foreach ($this->getProductUrls() as $productUrl) {
39
+ $productUrls .= "<input name=\"shopa_product_url\" type=\"hidden\" value=\"$productUrl\" />";
40
+ }
41
+ echo $productUrls;
42
+ ?>
43
  <script type="text/javascript" defer async=true src="<?php echo $this->getButtonUrl() ?>"></script>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Shopa_ShareAndEarn</name>
4
- <version>0.0.4</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>
@@ -12,11 +12,11 @@
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>Fix multi currency issue on success page</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-11-15</date>
18
- <time>17:44:32</time>
19
- <contents><target name="magecommunity"><dir name="Shopa"><dir name="ShareAndEarn"><dir name="Block"><file name="Button.php" hash="eb3da40bedf6d18cab5005b68b97cff8"/><file name="Success.php" hash="33208c2e1779c4beac351e42996fef80"/></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></contents>
20
  <compatible/>
21
  <dependencies><required><php><min>4.3.0</min><max>6.0.0</max></php></required></dependencies>
22
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Shopa_ShareAndEarn</name>
4
+ <version>0.0.5</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>
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>Adding product urls and order email to button api</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-11-30</date>
18
+ <time>17:34:26</time>
19
+ <contents><target name="magecommunity"><dir name="Shopa"><dir name="ShareAndEarn"><dir name="Block"><file name="Button.php" hash="eb3da40bedf6d18cab5005b68b97cff8"/><file name="Success.php" hash="8bc8551669085c78eb75401d941b2ad2"/></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="a4fecb69f8715795d1cefb680bcc770b"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Shopa_ShareAndEarn.xml" hash="7b5d8070ab388fb380977138e00e02df"/></dir></target></contents>
20
  <compatible/>
21
  <dependencies><required><php><min>4.3.0</min><max>6.0.0</max></php></required></dependencies>
22
  </package>