Tagnpin_Loyalty - Version 1.0.0

Version Notes

works on all versions of the magento

Download this release

Release Info

Developer Magento Core Team
Extension Tagnpin_Loyalty
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/local/Tagnpin/Loyalty/Block/Block.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Developed By Siddharth Gupta
4
+ * @copyright Copyright (c) 2011-2012 tagNpin
5
+ * @license http://www.tagNpin.com/LICENSE-M1.txt
6
+ */
7
+
8
+ class Tagnpin_Loyalty_Block_Block extends Mage_Core_Block_Template
9
+ {
10
+ protected function _toHtml()
11
+
12
+ {
13
+ $brandID = Mage::getStoreConfig('general/loyalty/brandid');
14
+ $secretKey = Mage::getStoreConfig('general/loyalty/secretkey');
15
+ $title = Mage::getStoreConfig('general/loyalty/title');
16
+ $xposition = Mage::getStoreConfig('general/loyalty/x-coordinate');
17
+ $yposition = Mage::getStoreConfig('general/loyalty/y-coordinate');
18
+ //print '==========='.$brandID.'==========='.$title.'==========='.$xposition.'==========='.$yposition.'==========='.$secretKey.'===========';
19
+ echo "<script> var tnp_data = { id: ".$brandID.", text: '".$title."', position: {x: '".$xposition."', y: '".$yposition."'} }; (function() { var tnp = document.createElement('script'); tnp.type = 'text/javascript'; tnp.async = true; tnp.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'www.tagnpin.com/js/websitePlugin.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(tnp, s); })(); </script>";
20
+ }
21
+ }
app/code/local/Tagnpin/Loyalty/Block/Checkout.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Developed By Siddharth Gupta
4
+ * @copyright Copyright (c) 2011-2012 tagNpin
5
+ * @license http://www.tagNpin.com/LICENSE-M1.txt
6
+ */
7
+
8
+ class Tagnpin_Loyalty_Block_Checkout extends Mage_Core_Block_Template
9
+ {
10
+ protected function _toHtml()
11
+
12
+ {
13
+ $brandID = Mage::getStoreConfig('general/loyalty/brandid');
14
+ $secretKey = Mage::getStoreConfig('general/loyalty/secretkey');
15
+
16
+ $order = new Mage_Sales_Model_Order();
17
+ $incrementId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
18
+ $order->loadByIncrementId($incrementId);
19
+
20
+ $email = $order->getCustomerEmail(); // set email id
21
+ $purchaseValue = $order->getGrandTotal(); // set purchase value
22
+ $points = ''; // optional if you want to give points irrespective of points logic on any activity
23
+ $fname = $order->getCustomerFirstname();; // set first name
24
+ $lname = $order->getCustomerLastname(); // set last name
25
+ $type = 'purchase'; // See end section for details
26
+ //print 'http://www.tagnpin.com/api/brandApi/assignPointsViaEmail?brandid='.$brandID.'&signature='.$secretKey.'&email='.$email.'&amount='.$purchaseValue.'&points='.$points.'&fname='.$fname.'&lname='.$lname.'&type='.$type;die;
27
+ $apiUrl = 'http://www.tagnpin.com/api/brandApi/assignPointsViaEmail?brandid='.$brandID.'&signature='.$secretKey.'&email='.$email.'&amount='.$purchaseValue.'&points='.$points.'&fname='.$fname.'&lname='.$lname.'&type='.$type;
28
+ $result = $this->getDataCurl($apiUrl);
29
+ //$result = file_get_contents($apiUrl);
30
+ $resultArray = (array)json_decode($result);/* json decode the response */
31
+ //print_r($resultArray); die;
32
+ if($resultArray['type'] == 'success'){
33
+ $message = 'Dear '.$fname.' , you have just earned '.$resultArray['points'].' points on your recent purchase. You can check your points on loyalty tab on home page.';
34
+ print "<script>alert('".$message."');</script>";
35
+ }
36
+ }
37
+
38
+ /**
39
+ * curl call function
40
+ * @param $url
41
+ * @param $postfields
42
+ */
43
+ function getDataCurl($url,$postfields=false){
44
+ //echo "calling url ".$url;
45
+ $session = curl_init($url);
46
+ // Don't return HTTP headers. Do return the contents of the call
47
+ curl_setopt($session, CURLOPT_HEADER, false);
48
+
49
+ $i =0;
50
+ $cookie = "";
51
+ foreach($_COOKIE as $key=>$val){
52
+ $cookie .= $key.'='.urlencode($val).";" ;
53
+ }
54
+
55
+ curl_setopt($session, CURLOPT_COOKIE, $cookie);
56
+ curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
57
+ curl_setopt($session, CURLOPT_CONNECTTIMEOUT, 20);
58
+ curl_setopt($session, CURLOPT_TIMEOUT, 20);
59
+ curl_setopt($session, CURLOPT_FOLLOWLOCATION,1);
60
+
61
+ if( $postfields ) {
62
+ curl_setopt ($session, CURLOPT_POST, 1);
63
+ curl_setopt ($session, CURLOPT_POSTFIELDS, $postfields);
64
+ }
65
+ if(strpos($url,"https") !== "false"){
66
+ curl_setopt($session, CURLOPT_SSL_VERIFYPEER, false);
67
+ curl_setopt($session, CURLOPT_SSL_VERIFYHOST, false);
68
+ }
69
+ // Make the call
70
+ $output = curl_exec($session);
71
+ $error = curl_error($session);
72
+ $info = curl_getinfo($session);
73
+ curl_close($session);
74
+ return $output;
75
+ }
76
+
77
+ }
app/code/local/Tagnpin/Loyalty/Helper/Data.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Tagnpin_Loyalty_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ }
app/code/local/Tagnpin/Loyalty/etc/config.xml ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Tagnpin_Loyalty>
5
+ <version>0.1.0</version>
6
+ </Tagnpin_Loyalty>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <loyalty>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>Tagnpin_Loyalty</module>
14
+ <frontName>loyalty</frontName>
15
+ </args>
16
+ </loyalty>
17
+ </routers>
18
+ <layout>
19
+ <updates>
20
+ <loyalty>
21
+ <file>loyalty.xml</file>
22
+ </loyalty>
23
+ </updates>
24
+ </layout>
25
+ </frontend>
26
+ <global>
27
+ <models>
28
+ <loyalty>
29
+ <class>Tagnpin_Loyalty_Model</class>
30
+ </loyalty>
31
+ </models>
32
+ <resources>
33
+ </resources>
34
+ <blocks>
35
+ <loyalty>
36
+ <class>Tagnpin_Loyalty_Block</class>
37
+ </loyalty>
38
+ </blocks>
39
+ <helpers>
40
+ <loyalty>
41
+ <class>Tagnpin_Loyalty_Helper</class>
42
+ </loyalty>
43
+ </helpers>
44
+ </global>
45
+ <!--
46
+ <default>
47
+ <tagnpin_loyalty>
48
+ <columns>
49
+ <active>1</active>
50
+ </columns>
51
+ </tagnpin_loyalty>
52
+ </default>
53
+ -->
54
+ <default>
55
+ <general>
56
+ <loyalty>
57
+ <active>1</active>
58
+ <title>Loyalty</title>
59
+ </loyalty>
60
+ </general>
61
+ </default>
62
+
63
+ </config>
app/code/local/Tagnpin/Loyalty/etc/system.xml ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <general>
5
+ <groups>
6
+ <loyalty translate="label" module="loyalty">
7
+ <label>tagNpin Loyalty Module</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
+ <active translate="label">
15
+ <label>Enabled</label>
16
+ <frontend_type>select</frontend_type>
17
+ <source_model>adminhtml/system_config_source_yesno</source_model>
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
+ </active>
23
+ <brandid translate="label">
24
+ <label>brandid</label>
25
+ <comment>You can find this in tagnpin admin panel -> Developer Api -> API -> authentication</comment>
26
+ <frontend_type>text</frontend_type>
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
+ </brandid>
32
+ <secretkey translate="label">
33
+ <label>Secret Key</label>
34
+ <comment>You can find this in tagnpin admin panel -> Developer Api -> API -> authentication</comment>
35
+ <frontend_type>text</frontend_type>
36
+ <sort_order>3</sort_order>
37
+ <show_in_default>1</show_in_default>
38
+ <show_in_website>1</show_in_website>
39
+ <show_in_store>0</show_in_store>
40
+ </secretkey>
41
+ <title translate="label">
42
+ <label>Title</label>
43
+ <frontend_type>text</frontend_type>
44
+ <sort_order>4</sort_order>
45
+ <show_in_default>1</show_in_default>
46
+ <show_in_website>1</show_in_website>
47
+ <show_in_store>0</show_in_store>
48
+ </title>
49
+ <x-coordinate translate="label">
50
+ <label>Float Btn X-Position</label>
51
+ <comment>write one of the following in the label - left/right</comment>
52
+ <frontend_type>text</frontend_type>
53
+ <sort_order>5</sort_order>
54
+ <show_in_default>1</show_in_default>
55
+ <show_in_website>1</show_in_website>
56
+ <show_in_store>0</show_in_store>
57
+ </x-coordinate>
58
+ <y-coordinate translate="label">
59
+ <label>Float Btn Y-Position</label>
60
+ <comment>write one of the following in the label - top/bottom</comment>
61
+ <frontend_type>text</frontend_type>
62
+ <sort_order>6</sort_order>
63
+ <show_in_default>1</show_in_default>
64
+ <show_in_website>1</show_in_website>
65
+ <show_in_store>0</show_in_store>
66
+ </y-coordinate>
67
+ </fields>
68
+ </loyalty>
69
+ </groups>
70
+ </general>
71
+ </sections>
72
+ </config>
app/design/frontend/default/default/layout/loyalty.xml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <default>
4
+ <reference name="before_body_end" >
5
+ <block type="loyalty/block" name="page.bottom1" >
6
+ </block>
7
+ </reference>
8
+ </default>
9
+ <checkout_onepage_success>
10
+ <reference name="before_body_end" >
11
+ <block type="loyalty/checkout" name="page.bottom" >
12
+ </block>
13
+ </reference>
14
+ </checkout_onepage_success>
15
+ </layout>
app/etc/modules/Tagnpin_Loyalty.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Tagnpin_Loyalty>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </Tagnpin_Loyalty>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Tagnpin_Loyalty</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.gnu.org/licenses/gpl.html">GPL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>tagNpin is a social loyalty platform for ecommerce. It rewards customers not only for purchases but also for social sharing. This plugin integrates tagNpin with your magento installation</summary>
10
+ <description>tagNpin is completely self serve, fully customizable, plug and play social loyalty platform for ecommerce. On sign up on tagNpin, you get following features
11
+ 1.) Facebook loyalty app
12
+ 2.) Website widget to reward social actions like sharing on Facebook, twitter follow etc
13
+ 3.) Loyalty dashboard where customers can see their information on website
14
+ 4.) Developer Apis to leverage full potential of tagNpin
15
+ 5.) Run data driven campaigns through tagNpin admin panel
16
+ 6.) Run coalition loyalty program with other loyalty partners within minutes</description>
17
+ <notes>works on all versions of the magento</notes>
18
+ <authors><author><name>Siddharth Gupta</name><user>auto-converted</user><email>siddharthguptansit@gmail.com</email></author></authors>
19
+ <date>2012-10-22</date>
20
+ <time>10:46:39</time>
21
+ <contents><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="loyalty.xml" hash="5d8f33bf7ae780b551b16ec22c3a7fd5"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Tagnpin_Loyalty.xml" hash="9e0e9a94a54c873fde61ae86af09935c"/></dir></target><target name="magelocal"><dir name="Tagnpin"><dir name="Loyalty"><dir name="Block"><file name="Block.php" hash="7253b471475002c0f2f8f2284352bf2b"/><file name="Checkout.php" hash="0f5e62961cf1b65e89ed3969d4f7c67d"/></dir><dir name="etc"><file name="config.xml" hash="c9de387745d470912b79984c94bf9d2c"/><file name="system.xml" hash="5ee0a11af9280ef77871f36e194d143b"/></dir><dir name="Helper"><file name="Data.php" hash="e48d8c436e86138d35baf1c2d20d86a6"/></dir></dir></dir></target></contents>
22
+ <compatible/>
23
+ <dependencies/>
24
+ </package>