Version Notes
Content updates for our new interface
Download this release
Release Info
Developer | RewardStream |
Extension | RewardStream_ReferAFriend |
Version | 1.1.0 |
Comparing to | |
See all releases |
Code changes from version 1.0.1 to 1.1.0
- app/code/community/Rewardstream/Referafriend/controllers/CartController.php +4 -4
- app/code/community/Rewardstream/Referafriend/controllers/IndexController.php +26 -33
- app/code/community/Rewardstream/Referafriend/data/rewardstream_setup/data-install-0.1.0.php +26 -49
- app/design/frontend/base/default/layout/rewardstream.xml +3 -0
- app/design/frontend/base/default/template/rewardstream/general_script.phtml +5 -0
- app/design/frontend/base/default/template/rewardstream/rewardstream.phtml +92 -188
- app/design/frontend/rwd/default/layout/rewardstream.xml +3 -0
- app/design/frontend/rwd/default/template/rewardstream/general_script.phtml +5 -0
- app/design/frontend/rwd/default/template/rewardstream/rewardstream.phtml +92 -188
- js/rewardstream/RSUtility.js +39 -0
- media/wysiwyg/rewardstream/rewardstream-magento-store-default-image.jpg +0 -0
- package.xml +5 -5
- skin/frontend/base/default/rewardstream/css/rewardstream.css +4 -8
- skin/frontend/rwd/default/rewardstream/css/rewardstream.css +4 -8
app/code/community/Rewardstream/Referafriend/controllers/CartController.php
CHANGED
@@ -83,14 +83,14 @@ class Rewardstream_Referafriend_CartController extends Mage_Checkout_CartControl
|
|
83 |
$result = $helper->getDataCallAPI( $apiurl . '/api/v2/custom/getOffer?api_key=' . $apiKey . '&code=' . $offerCode, "GET", false, "Basic " . $secretKey );
|
84 |
$responseData = json_decode( $result, true );
|
85 |
|
86 |
-
$rsOfferStatus = $responseData[
|
87 |
|
88 |
// If valid RS offer code, create coupon discount if necessary. Otherwise just apply code as normal and it will only work if there's a Magento coupon code already
|
89 |
if ( $rsOfferStatus == "valid" ) {
|
90 |
|
91 |
-
$rsDiscountValue = $responseData["
|
92 |
-
$rsOfferType = $responseData["
|
93 |
-
$rsMinimumPurchase = $responseData["
|
94 |
if ( $rsOfferType == "percent_off" ) {
|
95 |
|
96 |
$mgOfferType = "by_percent";
|
83 |
$result = $helper->getDataCallAPI( $apiurl . '/api/v2/custom/getOffer?api_key=' . $apiKey . '&code=' . $offerCode, "GET", false, "Basic " . $secretKey );
|
84 |
$responseData = json_decode( $result, true );
|
85 |
|
86 |
+
$rsOfferStatus = $responseData['Status'];
|
87 |
|
88 |
// If valid RS offer code, create coupon discount if necessary. Otherwise just apply code as normal and it will only work if there's a Magento coupon code already
|
89 |
if ( $rsOfferStatus == "valid" ) {
|
90 |
|
91 |
+
$rsDiscountValue = $responseData["Offer"]['Value'];
|
92 |
+
$rsOfferType = $responseData["Offer"]['Type'];
|
93 |
+
$rsMinimumPurchase = $responseData["Offer"]['MinimumPurchase'];
|
94 |
if ( $rsOfferType == "percent_off" ) {
|
95 |
|
96 |
$mgOfferType = "by_percent";
|
app/code/community/Rewardstream/Referafriend/controllers/IndexController.php
CHANGED
@@ -99,8 +99,7 @@ class Rewardstream_Referafriend_IndexController extends Mage_Core_Controller_Fro
|
|
99 |
}
|
100 |
|
101 |
//Refresh token for when reward member token expire than click to refresh button than apply this action
|
102 |
-
public function
|
103 |
-
|
104 |
$rewardid = $this->getRequest()->getParam( 'reward_id' );
|
105 |
$id = $this->getRequest()->getParam( 'customer_id' );
|
106 |
$customer = Mage::getModel( 'customer/customer' )->load( $id );
|
@@ -131,32 +130,31 @@ class Rewardstream_Referafriend_IndexController extends Mage_Core_Controller_Fro
|
|
131 |
$authorization_header = "Basic " . $apiSecret;
|
132 |
$currenttime = date( 'Y-m-d H:i:s' );
|
133 |
$currentdate = date( "Ymd" );
|
134 |
-
$data =
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
|
|
154 |
if ( $result ) {
|
155 |
-
|
156 |
$arrayofjson = json_decode( $result, true );
|
157 |
-
if ($arrayofjson['Error'])
|
158 |
-
|
159 |
-
echo "Sorry, the Refer a Friend functionality is currently unavailable. Please try again later. (" . $arrayofjson['Error']['Message'] . ")";
|
160 |
exit();
|
161 |
}
|
162 |
else {
|
@@ -165,7 +163,6 @@ class Rewardstream_Referafriend_IndexController extends Mage_Core_Controller_Fro
|
|
165 |
$model->setAccess_token( $arrayofjson['access_token'] );
|
166 |
$model->setExpires_in( $arrayofjson['expires_in'] );
|
167 |
$model->setMember_id( $arrayofjson['Member']['Id'] );
|
168 |
-
|
169 |
$model->setFirstname( $arrayofjson['Member']['FirstName'] );
|
170 |
$model->setLastname( $arrayofjson['Member']['LastName'] );
|
171 |
$model->setEmail( $arrayofjson['Member']['EmailAddress'] );
|
@@ -173,14 +170,10 @@ class Rewardstream_Referafriend_IndexController extends Mage_Core_Controller_Fro
|
|
173 |
$model->setActivationdate( $currentdate );
|
174 |
$model->setActivationtime( $currenttime );
|
175 |
$model->save();
|
176 |
-
|
177 |
-
$html = '<script type="text/javascript" src="' . $apiurl . '/js/spark.v2.min.js?api_key=' . $apiKey . '&token=' . $token . '"></script>';
|
178 |
-
$html .= '<a class="spark-refer">Refer a Friend</a>';
|
179 |
-
echo $html;
|
180 |
}
|
181 |
} else {
|
182 |
-
|
183 |
-
echo "Sorry, the Refer a Friend functionality is currently unavailable. Please try again later.";
|
184 |
exit();
|
185 |
}
|
186 |
}
|
99 |
}
|
100 |
|
101 |
//Refresh token for when reward member token expire than click to refresh button than apply this action
|
102 |
+
public function refreshTokenAction() {
|
|
|
103 |
$rewardid = $this->getRequest()->getParam( 'reward_id' );
|
104 |
$id = $this->getRequest()->getParam( 'customer_id' );
|
105 |
$customer = Mage::getModel( 'customer/customer' )->load( $id );
|
130 |
$authorization_header = "Basic " . $apiSecret;
|
131 |
$currenttime = date( 'Y-m-d H:i:s' );
|
132 |
$currentdate = date( "Ymd" );
|
133 |
+
$data = array(
|
134 |
+
"FirstName" => $firstname,
|
135 |
+
"LastName" => $lastname,
|
136 |
+
"EmailAddress" => $email,
|
137 |
+
"Account" => array(
|
138 |
+
"Number" => $accountnumber,
|
139 |
+
"InternalIdentifier" => $phone,
|
140 |
+
"Status" => "A",
|
141 |
+
"ActivationDate" => $currentdate
|
142 |
+
)
|
143 |
+
// TODO Re-add address if valid
|
144 |
+
//"Address" => array(
|
145 |
+
// "StreetLine1" => $street,
|
146 |
+
// "City" => $city,
|
147 |
+
// "State" => $state_code,
|
148 |
+
// "Country" => $country,
|
149 |
+
// "ZipCode" => $postcode
|
150 |
+
//)
|
151 |
+
);
|
152 |
+
|
153 |
+
$result = $helper->getDataCallAPIJSON( $url, $method, json_encode($data), $authorization_header );//Call SyncMemberApi for rewardstream update data
|
154 |
if ( $result ) {
|
|
|
155 |
$arrayofjson = json_decode( $result, true );
|
156 |
+
if ($arrayofjson['Error']) {
|
157 |
+
echo json_encode($result);
|
|
|
158 |
exit();
|
159 |
}
|
160 |
else {
|
163 |
$model->setAccess_token( $arrayofjson['access_token'] );
|
164 |
$model->setExpires_in( $arrayofjson['expires_in'] );
|
165 |
$model->setMember_id( $arrayofjson['Member']['Id'] );
|
|
|
166 |
$model->setFirstname( $arrayofjson['Member']['FirstName'] );
|
167 |
$model->setLastname( $arrayofjson['Member']['LastName'] );
|
168 |
$model->setEmail( $arrayofjson['Member']['EmailAddress'] );
|
170 |
$model->setActivationdate( $currentdate );
|
171 |
$model->setActivationtime( $currenttime );
|
172 |
$model->save();
|
173 |
+
echo json_encode($result);
|
|
|
|
|
|
|
174 |
}
|
175 |
} else {
|
176 |
+
echo "Sorry, the Refer a Friend functionality is currently unavailable. Please try again later. Back End";
|
|
|
177 |
exit();
|
178 |
}
|
179 |
}
|
app/code/community/Rewardstream/Referafriend/data/rewardstream_setup/data-install-0.1.0.php
CHANGED
@@ -1,26 +1,15 @@
|
|
1 |
<?php
|
2 |
//create dynamically page of rewardstream when uploading extension in the magento
|
3 |
$cmsPage = array(
|
4 |
-
'title' => 'Refer A Friend
|
5 |
'root_template' => 'one_column', // two_columns_left, two_columns_right, three_columns
|
6 |
'meta_keywords' => 'Referral,Refer-a-Friend,Refer A Friend,Invite,Share,Reward',
|
7 |
'meta_description' => 'Publicly accessible landing page that should advertise the referral program to customers with a call to action to send referrals.',
|
8 |
'identifier' => 'refer',
|
9 |
'content' => "<div class='main-rewardstream'>
|
10 |
-
<div class='
|
11 |
-
|
12 |
-
|
13 |
-
<p>Invite your friends and they'll get <strong>[Referee_Offer_Here]</strong>. You'll also [Referrer_Reward_Here] for referring your friend. Refer as often as you like!</p>
|
14 |
-
<h3>How to send a referral</h3>
|
15 |
-
<ol>
|
16 |
-
<li>Click <a href='{{store url=rewardstream/index/refer}}'>Refer A Friend </a>to get started</li>
|
17 |
-
<li>Sign into your My Account or create a My Account</li>
|
18 |
-
<li>Refer your friends by email, social media, text message, or your personal referral link</li>
|
19 |
-
<li>After your friend makes their first purchase, you'll get [Referrer_Reward_Here]</li>
|
20 |
-
</ol><p><a href='{{store url=rewardstream/index/refer}}'><button class='button' title='Refer A Friend' type='submit'><span><span>Refer A Friend</span></span></button></a></p>
|
21 |
-
<p>*Note: You must make an approved purchase before you can send a referral. For more details regarding our referral program, read our <a href='#'>Program Rules</a>.</p>
|
22 |
-
</div>
|
23 |
-
</div>",
|
24 |
'content_heading' => 'Refer A Friend',
|
25 |
'is_active' => 0,
|
26 |
'sort_order' => 0,
|
@@ -44,17 +33,14 @@ $staticBlock1 = array(
|
|
44 |
'title' => 'Refer A Friend Checkout Success Content',
|
45 |
'identifier' => 'refer-a-friend-checkout-success-content',
|
46 |
'content' => "<div class='refer-a-friend-checkout-success-content'>
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
</ol><p><a href='{{store url=rewardstream/index/refer}}'><button class='button' title='Refer A Friend' type='submit'><span><span>Refer A Friend</span></span></button></a></p>
|
56 |
-
<p>*Note: You must make an approved purchase before you can send a referral. For more details regarding our referral program, read our <a href='#'>Program Rules</a>.</p>
|
57 |
-
</div>",
|
58 |
'is_active' => 0,
|
59 |
'stores' => array( 0 ),
|
60 |
);
|
@@ -78,30 +64,21 @@ Mage::getModel( 'cms/block' )->setData( $staticBlock2 )->save();
|
|
78 |
$staticBlock3 = array(
|
79 |
'title' => 'Refer A Friend Page Content',
|
80 |
'identifier' => 'refer-a-friend-page-content',
|
81 |
-
'content' => "<div class
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
|
|
86 |
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
<div class=\"spark-refer-embed\"></div>
|
96 |
-
</div>
|
97 |
-
|
98 |
-
<div class=\"section-four\">
|
99 |
-
<h3>Referral History</h3>
|
100 |
-
<p>Click the button below to see the status of referrals you have made.</p>
|
101 |
-
<!-- Referral activity statement opens here using spark-statement class -->
|
102 |
-
<p><a class=\"spark-statement\" href=\"javascript:\"><button class='button' title='Referral History' type='submit'><span><span>Referral History</span></span></button></a></p>
|
103 |
-
</div>
|
104 |
-
</div>",
|
105 |
'is_active' => 0,
|
106 |
'stores' => array( 0 ),
|
107 |
);
|
1 |
<?php
|
2 |
//create dynamically page of rewardstream when uploading extension in the magento
|
3 |
$cmsPage = array(
|
4 |
+
'title' => 'Refer A Friend',
|
5 |
'root_template' => 'one_column', // two_columns_left, two_columns_right, three_columns
|
6 |
'meta_keywords' => 'Referral,Refer-a-Friend,Refer A Friend,Invite,Share,Reward',
|
7 |
'meta_description' => 'Publicly accessible landing page that should advertise the referral program to customers with a call to action to send referrals.',
|
8 |
'identifier' => 'refer',
|
9 |
'content' => "<div class='main-rewardstream'>
|
10 |
+
<div class='spark-refer-embed'></div>
|
11 |
+
{{block type=\"core/template\" template=\"rewardstream/general_script.phtml\"}}
|
12 |
+
</div>",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
'content_heading' => 'Refer A Friend',
|
14 |
'is_active' => 0,
|
15 |
'sort_order' => 0,
|
33 |
'title' => 'Refer A Friend Checkout Success Content',
|
34 |
'identifier' => 'refer-a-friend-checkout-success-content',
|
35 |
'content' => "<div class='refer-a-friend-checkout-success-content'>
|
36 |
+
<div class='checkout-success-promo'>
|
37 |
+
<h2><strong>Want {referrer_reward_here} off your next purchase?</strong></h2>
|
38 |
+
<p>Refer a friend and get {referrer_reward_here} for each successful referral. Your friends will get {referee_offer_here} off their first purchase. It's that easy.</p>
|
39 |
+
</div>
|
40 |
+
<div class='buttons-set'>
|
41 |
+
<a href='{{store url=rewardstream/index/refer}}'><button type='button' class='button' title='Refer A Friend'><span><span>Refer A Friend</span></span></button></a>
|
42 |
+
</div>
|
43 |
+
</div>",
|
|
|
|
|
|
|
44 |
'is_active' => 0,
|
45 |
'stores' => array( 0 ),
|
46 |
);
|
64 |
$staticBlock3 = array(
|
65 |
'title' => 'Refer A Friend Page Content',
|
66 |
'identifier' => 'refer-a-friend-page-content',
|
67 |
+
'content' => "<div class='refer-a-friend-page-content'>
|
68 |
+
<!-- Embeds the referral dashboard here -->
|
69 |
+
<div class='section-first'>
|
70 |
+
<!-- Referral interface embedded here using spark-refer-embed class -->
|
71 |
+
<div class='spark-refer-embed'></div>
|
72 |
+
</div>
|
73 |
|
74 |
+
<!-- Embeds a button for your customers to check their referral history -->
|
75 |
+
<div class='section-second'>
|
76 |
+
<h3>Referral History</h3>
|
77 |
+
<p>See a list of referrals you've made and the status of each referral:</p>
|
78 |
+
<!-- Referral activity statement opens here using spark-statement class -->
|
79 |
+
<p><a class='spark-statement' href='javascript:'><button class='button' title='Referral History' type='submit'><span><span>Referral History</span></span></button></a></p>
|
80 |
+
</div>
|
81 |
+
</div>",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
'is_active' => 0,
|
83 |
'stores' => array( 0 ),
|
84 |
);
|
app/design/frontend/base/default/layout/rewardstream.xml
CHANGED
@@ -45,6 +45,9 @@
|
|
45 |
<action method="addJs">
|
46 |
<script>rewardstream/noconflict.js</script>
|
47 |
</action>
|
|
|
|
|
|
|
48 |
<action method="addCss">
|
49 |
<stylesheet>rewardstream/css/rewardstream.css</stylesheet>
|
50 |
</action>
|
45 |
<action method="addJs">
|
46 |
<script>rewardstream/noconflict.js</script>
|
47 |
</action>
|
48 |
+
<action method="addJs">
|
49 |
+
<script>rewardstream/RSUtility.js</script>
|
50 |
+
</action>
|
51 |
<action method="addCss">
|
52 |
<stylesheet>rewardstream/css/rewardstream.css</stylesheet>
|
53 |
</action>
|
app/design/frontend/base/default/template/rewardstream/general_script.phtml
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$apiUrl = 'https://' . Mage::getStoreConfig( 'rewardstream_options/section_one/rewardstream_api_url' );
|
3 |
+
$apiKey = Mage::getStoreConfig( 'rewardstream_options/section_one/rewardstream_api_key' );
|
4 |
+
?>
|
5 |
+
<script src="<?php echo $apiUrl?>/js/spark.v2.min.js?api_key=<?php echo $apiKey;?>"></script>
|
app/design/frontend/base/default/template/rewardstream/rewardstream.phtml
CHANGED
@@ -1,201 +1,105 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
16 |
$customer = Mage::getSingleton( 'customer/session' )->getCustomer();
|
17 |
$email = $customer->getEmail();
|
18 |
-
|
19 |
-
|
|
|
20 |
$_orderCnt = $orderCollection->count();
|
21 |
$first_purchase_required = Mage::getStoreConfig( 'rewardstream_options/section_two/rewardstream_first_purchase' );
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
$
|
43 |
-
$
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
<script type="text/javascript">
|
59 |
-
|
60 |
-
jQuery(document).ready(function () {
|
61 |
-
var reward_id = "<?php echo $rewardid?>";
|
62 |
-
var customer_id = "<?php echo $id?>";
|
63 |
-
|
64 |
-
jQuery.ajax ({
|
65 |
-
url: "<?php echo $refreshTokenUrl;?>",
|
66 |
-
data: {"reward_id": reward_id, "customer_id": customer_id},
|
67 |
-
type: 'post',
|
68 |
-
beforeSend: function ()
|
69 |
-
{
|
70 |
-
jQuery('.loading').html('<img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA)."wysiwyg/rewardstream/loading.gif" ?>"/>');
|
71 |
-
},
|
72 |
-
success: function (result)
|
73 |
-
{
|
74 |
-
var errorString = "<?php echo $errorString; ?>";
|
75 |
-
if (result.indexOf(errorString) > -1) {
|
76 |
-
jQuery('.loading').hide();
|
77 |
-
alert(result);
|
78 |
-
}
|
79 |
-
else
|
80 |
-
{
|
81 |
-
window.location.reload(true);
|
82 |
-
}
|
83 |
-
}
|
84 |
-
|
85 |
-
});
|
86 |
-
});
|
87 |
-
|
88 |
-
</script>
|
89 |
-
|
90 |
-
<?php } else if ( $accesstoken == "" ) { ?>
|
91 |
-
|
92 |
-
<div class="loading"></div>
|
93 |
-
|
94 |
-
|
95 |
-
<script type="text/javascript">
|
96 |
-
|
97 |
-
jQuery(document).ready(function ()
|
98 |
-
{
|
99 |
-
var reward_id = "<?php echo $rewardid?>";
|
100 |
-
var customer_id = "<?php echo $id?>";
|
101 |
-
|
102 |
-
jQuery.ajax({
|
103 |
-
url: "<?php echo $refreshTokenUrl;?>",
|
104 |
-
data: {"reward_id": reward_id, "customer_id": customer_id},
|
105 |
-
type: 'post',
|
106 |
-
beforeSend: function ()
|
107 |
-
{
|
108 |
-
jQuery('.loading').html('<img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA)."wysiwyg/rewardstream/loading.gif" ?>"/>');
|
109 |
-
},
|
110 |
-
success: function (result)
|
111 |
-
{
|
112 |
-
var errorString = "<?php echo $errorString; ?>";
|
113 |
-
if (result.indexOf(errorString) > -1) {
|
114 |
-
jQuery('.loading').hide();
|
115 |
-
alert(result);
|
116 |
-
}
|
117 |
-
else
|
118 |
-
{
|
119 |
-
window.location.reload(true);
|
120 |
-
}
|
121 |
-
}
|
122 |
-
});
|
123 |
-
});
|
124 |
-
|
125 |
-
</script>
|
126 |
-
<?php } else if ( $currenttime < $expiretime ) { ?>
|
127 |
-
<script type="text/javascript" src="<?php echo $apiUrl ?>/js/spark.v2.min.js?api_key=<?php echo $apiKey ?>&token=<?php echo $accesstoken; ?>"></script>
|
128 |
-
|
129 |
-
<?php echo $this->getLayout()->createBlock( 'cms/block' )->setBlockId( 'refer-a-friend-page-content' )->toHtml(); ?>
|
130 |
-
<?php }
|
131 |
-
}
|
132 |
-
} else {
|
133 |
-
|
134 |
-
$customerData->getFirstname();
|
135 |
-
$customerData->getLastname();
|
136 |
-
$customerData->getEmail();
|
137 |
-
$customerData->getAddress();
|
138 |
-
$address_id = $customerData->getDefaultBilling();
|
139 |
-
|
140 |
-
$addressdata = Mage::getModel( 'customer/address' )->load( $address_id );
|
141 |
-
$addressdata['street'];
|
142 |
-
$addressdata['city'];
|
143 |
-
$addressdata['postcode'];
|
144 |
-
$addressdata['region'];
|
145 |
-
$addressdata['telephone'];
|
146 |
-
?>
|
147 |
-
|
148 |
-
|
149 |
-
<div class="loading"></div>
|
150 |
-
<script type="text/javascript">
|
151 |
-
|
152 |
-
jQuery(document).ready(function () {
|
153 |
-
var customer_id = "<?php echo $id?>";
|
154 |
-
|
155 |
-
jQuery.ajax ({
|
156 |
-
url: "<?php echo $refreshTokenUrl;?>",
|
157 |
-
data: {"customer_id": customer_id},
|
158 |
-
type: 'post',
|
159 |
-
beforeSend: function ()
|
160 |
-
{
|
161 |
-
jQuery('.loading').html('<img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA)."wysiwyg/rewardstream/loading.gif" ?>"/>');
|
162 |
-
},
|
163 |
-
success: function (result)
|
164 |
-
{
|
165 |
-
var errorString = "<?php echo $errorString; ?>";
|
166 |
-
if (result == "Please Contact to Merchant")
|
167 |
-
{
|
168 |
-
jQuery('.loading').hide();
|
169 |
-
alert("Please Contact to Merchant or Store Owner");
|
170 |
-
}
|
171 |
-
// If result message contains "Sorry, the Refer a Friend functionality is currently unavailable."
|
172 |
-
// Display the message
|
173 |
-
else if (result.indexOf(errorString) > -1) {
|
174 |
-
jQuery('.loading').hide();
|
175 |
-
alert(result);
|
176 |
-
}
|
177 |
-
else
|
178 |
-
{
|
179 |
-
window.location.reload(true);
|
180 |
-
}
|
181 |
-
}
|
182 |
-
});
|
183 |
-
});
|
184 |
-
|
185 |
-
</script>
|
186 |
-
|
187 |
-
<?php }?>
|
188 |
-
<?php } else { ?>
|
189 |
-
<div class="before-purchase">
|
190 |
-
<?php echo $this->getLayout()->createBlock( 'cms/block' )->setBlockId( 'refer-a-friend-purchase-required' )->toHtml(); ?>
|
191 |
-
</div>
|
192 |
-
<?php }
|
193 |
-
}
|
194 |
}
|
195 |
} else {
|
196 |
$customerLoginURL = $this->getBaseUrl() . "customer/account/login";
|
197 |
Mage::app()->getFrontController()->getResponse()->setRedirect( $customerLoginURL )->sendResponse();
|
198 |
} ?>
|
199 |
|
200 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
201 |
</div>
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* Beginning section is all data retrieval.
|
4 |
+
* - I don't want to mix php logic with html so I want to gather all the data first before applying them to the view
|
5 |
+
*/
|
6 |
+
$status = Mage::getStoreConfig( 'rewardstream_options/section_one/rewardstream_status' );
|
7 |
+
$title_name = Mage::getStoreConfig( 'rewardstream_options/section_two/rewardstream_refer_title' );
|
8 |
+
$displayFirstPurchaseMessage = true;
|
9 |
+
$pageRefresh = false;
|
10 |
+
|
11 |
+
// If the user hasn't set the menu title name
|
12 |
+
if (empty($title_name)) {
|
13 |
+
$title_name = "Refer A Friend";
|
14 |
+
}
|
15 |
+
|
16 |
+
// If the magento app enabled?
|
17 |
+
if ( $status == 1 ) {
|
18 |
+
if ( Mage::getSingleton( 'customer/session' )->isLoggedIn() ) {
|
19 |
$customer = Mage::getSingleton( 'customer/session' )->getCustomer();
|
20 |
$email = $customer->getEmail();
|
21 |
+
$orderCollection = Mage::getModel( 'sales/order' )->getCollection()
|
22 |
+
->addFieldToFilter( 'customer_email', $email )
|
23 |
+
->addFieldToFilter( 'status', array('complete', 'processing') );
|
24 |
$_orderCnt = $orderCollection->count();
|
25 |
$first_purchase_required = Mage::getStoreConfig( 'rewardstream_options/section_two/rewardstream_first_purchase' );
|
26 |
|
27 |
+
// Show referral platform?
|
28 |
+
if ($first_purchase_required==2 || $_orderCnt > 0) {
|
29 |
+
// Disable display of first purchase
|
30 |
+
$displayFirstPurchaseMessage = false;
|
31 |
+
|
32 |
+
$customerData = Mage::getSingleton( 'customer/session' )->getCustomer();
|
33 |
+
$id = $customerData->getId();
|
34 |
+
$apiUrl = 'https://' . Mage::getStoreConfig( 'rewardstream_options/section_one/rewardstream_api_url' );
|
35 |
+
|
36 |
+
$apiKey = Mage::getStoreConfig( 'rewardstream_options/section_one/rewardstream_api_key' );
|
37 |
+
$collection = Mage::getModel( 'rewardstream/rewardstream' )->load( $id, 'customer_id' );
|
38 |
+
|
39 |
+
$customerid = $collection['customer_id'];
|
40 |
+
$refreshTokenUrl = Mage::getUrl('rewardstream/index/refreshtoken');
|
41 |
+
|
42 |
+
// Does the customer exist in our system already?
|
43 |
+
if ( $customerid == $id ) {
|
44 |
+
$accesstoken = $collection['access_token'];
|
45 |
+
$rewardid = $collection['reward_id'];
|
46 |
+
$activationtime = $collection['activationtime'];
|
47 |
+
$expiretime = date( 'Y-m-d H:i:s', strtotime( '+2 hour', strtotime( $activationtime ) ) );
|
48 |
+
$currenttime = date( 'Y-m-d H:i:s' );
|
49 |
+
|
50 |
+
if ( isset( $accesstoken ) ) {
|
51 |
+
if ( $currenttime > $expiretime || $accesstoken == "" ) {
|
52 |
+
// Need to call backend call to get token
|
53 |
+
$pageRefresh = true;
|
54 |
+
}
|
55 |
+
}
|
56 |
+
} else {
|
57 |
+
// Need to call backend call to get token
|
58 |
+
$pageRefresh = true;
|
59 |
+
}
|
60 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
}
|
62 |
} else {
|
63 |
$customerLoginURL = $this->getBaseUrl() . "customer/account/login";
|
64 |
Mage::app()->getFrontController()->getResponse()->setRedirect( $customerLoginURL )->sendResponse();
|
65 |
} ?>
|
66 |
|
67 |
+
<!--Page Display-->
|
68 |
+
<div class="rewardstream-referafriend">
|
69 |
+
<div class="page-title">
|
70 |
+
<h1><?php echo $title_name;?></h1>
|
71 |
+
</div>
|
72 |
+
|
73 |
+
<div id="content-error" class="error"></div>
|
74 |
+
<div class="loading"></div>
|
75 |
+
|
76 |
+
<!--Display First Purchase Message-->
|
77 |
+
<?php if ($displayFirstPurchaseMessage) { ?>
|
78 |
+
<div class="before-purchase">
|
79 |
+
<?php echo $this->getLayout()->createBlock( 'cms/block' )->setBlockId( 'refer-a-friend-purchase-required' )->toHtml(); ?>
|
80 |
+
</div>
|
81 |
+
|
82 |
+
<!--Display Embedded Referral Site-->
|
83 |
+
<?php } else if (!$pageRefresh) { ?>
|
84 |
+
<!--Load the page-->
|
85 |
+
<div id="refer-a-friend-platform">
|
86 |
+
<script type="text/javascript" src="<?php echo $apiUrl ?>/js/spark.v2.min.js?api_key=<?php echo $apiKey ?>&token=<?php echo $accesstoken ?>"></script>
|
87 |
+
<?php echo $this->getLayout()->createBlock( 'cms/block' )->setBlockId( 'refer-a-friend-page-content' )->toHtml(); ?>
|
88 |
+
</div>
|
89 |
+
<?php } ?>
|
90 |
+
|
91 |
+
<!--Loader and get the data-->
|
92 |
+
<script type="text/javascript">
|
93 |
+
jQuery(document).ready(function () {
|
94 |
+
var reward_id = "<?php echo $rewardid?>";
|
95 |
+
var customer_id = "<?php echo $id?>";
|
96 |
+
var refreshTokenUrl = "<?php echo $refreshTokenUrl;?>";
|
97 |
+
var loaderUrl = "<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA)."wysiwyg/rewardstream/loading.gif" ?>";
|
98 |
+
var refreshPage = "<?php echo $pageRefresh?>";
|
99 |
+
|
100 |
+
if (refreshPage) {
|
101 |
+
RSUtility.refreshToken(reward_id, customer_id, refreshTokenUrl, "content-error", loaderUrl);
|
102 |
+
}
|
103 |
+
});
|
104 |
+
</script>
|
105 |
</div>
|
app/design/frontend/rwd/default/layout/rewardstream.xml
CHANGED
@@ -32,6 +32,9 @@
|
|
32 |
</action>
|
33 |
<action method="addJs">
|
34 |
<script>rewardstream/noconflict.js</script>
|
|
|
|
|
|
|
35 |
</action>
|
36 |
<action method="addCss">
|
37 |
<stylesheet>rewardstream/css/rewardstream.css</stylesheet>
|
32 |
</action>
|
33 |
<action method="addJs">
|
34 |
<script>rewardstream/noconflict.js</script>
|
35 |
+
</action>
|
36 |
+
<action method="addJs">
|
37 |
+
<script>rewardstream/RSUtility.js</script>
|
38 |
</action>
|
39 |
<action method="addCss">
|
40 |
<stylesheet>rewardstream/css/rewardstream.css</stylesheet>
|
app/design/frontend/rwd/default/template/rewardstream/general_script.phtml
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$apiUrl = 'https://' . Mage::getStoreConfig( 'rewardstream_options/section_one/rewardstream_api_url' );
|
3 |
+
$apiKey = Mage::getStoreConfig( 'rewardstream_options/section_one/rewardstream_api_key' );
|
4 |
+
?>
|
5 |
+
<script src="<?php echo $apiUrl?>/js/spark.v2.min.js?api_key=<?php echo $apiKey;?>"></script>
|
app/design/frontend/rwd/default/template/rewardstream/rewardstream.phtml
CHANGED
@@ -1,201 +1,105 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
16 |
$customer = Mage::getSingleton( 'customer/session' )->getCustomer();
|
17 |
$email = $customer->getEmail();
|
18 |
-
|
19 |
-
|
|
|
20 |
$_orderCnt = $orderCollection->count();
|
21 |
$first_purchase_required = Mage::getStoreConfig( 'rewardstream_options/section_two/rewardstream_first_purchase' );
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
$
|
43 |
-
$
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
<script type="text/javascript">
|
59 |
-
|
60 |
-
jQuery(document).ready(function () {
|
61 |
-
var reward_id = "<?php echo $rewardid?>";
|
62 |
-
var customer_id = "<?php echo $id?>";
|
63 |
-
|
64 |
-
jQuery.ajax ({
|
65 |
-
url: "<?php echo $refreshTokenUrl;?>",
|
66 |
-
data: {"reward_id": reward_id, "customer_id": customer_id},
|
67 |
-
type: 'post',
|
68 |
-
beforeSend: function ()
|
69 |
-
{
|
70 |
-
jQuery('.loading').html('<img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA)."wysiwyg/rewardstream/loading.gif" ?>"/>');
|
71 |
-
},
|
72 |
-
success: function (result)
|
73 |
-
{
|
74 |
-
var errorString = "<?php echo $errorString; ?>";
|
75 |
-
if (result.indexOf(errorString) > -1) {
|
76 |
-
jQuery('.loading').hide();
|
77 |
-
alert(result);
|
78 |
-
}
|
79 |
-
else
|
80 |
-
{
|
81 |
-
window.location.reload(true);
|
82 |
-
}
|
83 |
-
}
|
84 |
-
|
85 |
-
});
|
86 |
-
});
|
87 |
-
|
88 |
-
</script>
|
89 |
-
|
90 |
-
<?php } else if ( $accesstoken == "" ) { ?>
|
91 |
-
|
92 |
-
<div class="loading"></div>
|
93 |
-
|
94 |
-
|
95 |
-
<script type="text/javascript">
|
96 |
-
|
97 |
-
jQuery(document).ready(function ()
|
98 |
-
{
|
99 |
-
var reward_id = "<?php echo $rewardid?>";
|
100 |
-
var customer_id = "<?php echo $id?>";
|
101 |
-
|
102 |
-
jQuery.ajax({
|
103 |
-
url: "<?php echo $refreshTokenUrl;?>",
|
104 |
-
data: {"reward_id": reward_id, "customer_id": customer_id},
|
105 |
-
type: 'post',
|
106 |
-
beforeSend: function ()
|
107 |
-
{
|
108 |
-
jQuery('.loading').html('<img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA)."wysiwyg/rewardstream/loading.gif" ?>"/>');
|
109 |
-
},
|
110 |
-
success: function (result)
|
111 |
-
{
|
112 |
-
var errorString = "<?php echo $errorString; ?>";
|
113 |
-
if (result.indexOf(errorString) > -1) {
|
114 |
-
jQuery('.loading').hide();
|
115 |
-
alert(result);
|
116 |
-
}
|
117 |
-
else
|
118 |
-
{
|
119 |
-
window.location.reload(true);
|
120 |
-
}
|
121 |
-
}
|
122 |
-
});
|
123 |
-
});
|
124 |
-
|
125 |
-
</script>
|
126 |
-
<?php } else if ( $currenttime < $expiretime ) { ?>
|
127 |
-
<script type="text/javascript" src="<?php echo $apiUrl ?>/js/spark.v2.min.js?api_key=<?php echo $apiKey ?>&token=<?php echo $accesstoken; ?>"></script>
|
128 |
-
|
129 |
-
<?php echo $this->getLayout()->createBlock( 'cms/block' )->setBlockId( 'refer-a-friend-page-content' )->toHtml(); ?>
|
130 |
-
<?php }
|
131 |
-
}
|
132 |
-
} else {
|
133 |
-
|
134 |
-
$customerData->getFirstname();
|
135 |
-
$customerData->getLastname();
|
136 |
-
$customerData->getEmail();
|
137 |
-
$customerData->getAddress();
|
138 |
-
$address_id = $customerData->getDefaultBilling();
|
139 |
-
|
140 |
-
$addressdata = Mage::getModel( 'customer/address' )->load( $address_id );
|
141 |
-
$addressdata['street'];
|
142 |
-
$addressdata['city'];
|
143 |
-
$addressdata['postcode'];
|
144 |
-
$addressdata['region'];
|
145 |
-
$addressdata['telephone'];
|
146 |
-
?>
|
147 |
-
|
148 |
-
|
149 |
-
<div class="loading"></div>
|
150 |
-
<script type="text/javascript">
|
151 |
-
|
152 |
-
jQuery(document).ready(function () {
|
153 |
-
var customer_id = "<?php echo $id?>";
|
154 |
-
|
155 |
-
jQuery.ajax ({
|
156 |
-
url: "<?php echo $refreshTokenUrl;?>",
|
157 |
-
data: {"customer_id": customer_id},
|
158 |
-
type: 'post',
|
159 |
-
beforeSend: function ()
|
160 |
-
{
|
161 |
-
jQuery('.loading').html('<img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA)."wysiwyg/rewardstream/loading.gif" ?>"/>');
|
162 |
-
},
|
163 |
-
success: function (result)
|
164 |
-
{
|
165 |
-
var errorString = "<?php echo $errorString; ?>";
|
166 |
-
if (result == "Please Contact to Merchant")
|
167 |
-
{
|
168 |
-
jQuery('.loading').hide();
|
169 |
-
alert("Please Contact to Merchant or Store Owner");
|
170 |
-
}
|
171 |
-
// If result message contains "Sorry, the Refer a Friend functionality is currently unavailable."
|
172 |
-
// Display the message
|
173 |
-
else if (result.indexOf(errorString) > -1) {
|
174 |
-
jQuery('.loading').hide();
|
175 |
-
alert(result);
|
176 |
-
}
|
177 |
-
else
|
178 |
-
{
|
179 |
-
window.location.reload(true);
|
180 |
-
}
|
181 |
-
}
|
182 |
-
});
|
183 |
-
});
|
184 |
-
|
185 |
-
</script>
|
186 |
-
|
187 |
-
<?php }?>
|
188 |
-
<?php } else { ?>
|
189 |
-
<div class="before-purchase">
|
190 |
-
<?php echo $this->getLayout()->createBlock( 'cms/block' )->setBlockId( 'refer-a-friend-purchase-required' )->toHtml(); ?>
|
191 |
-
</div>
|
192 |
-
<?php }
|
193 |
-
}
|
194 |
}
|
195 |
} else {
|
196 |
$customerLoginURL = $this->getBaseUrl() . "customer/account/login";
|
197 |
Mage::app()->getFrontController()->getResponse()->setRedirect( $customerLoginURL )->sendResponse();
|
198 |
} ?>
|
199 |
|
200 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
201 |
</div>
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* Beginning section is all data retrieval.
|
4 |
+
* - I don't want to mix php logic with html so I want to gather all the data first before applying them to the view
|
5 |
+
*/
|
6 |
+
$status = Mage::getStoreConfig( 'rewardstream_options/section_one/rewardstream_status' );
|
7 |
+
$title_name = Mage::getStoreConfig( 'rewardstream_options/section_two/rewardstream_refer_title' );
|
8 |
+
$displayFirstPurchaseMessage = true;
|
9 |
+
$pageRefresh = false;
|
10 |
+
|
11 |
+
// If the user hasn't set the menu title name
|
12 |
+
if (empty($title_name)) {
|
13 |
+
$title_name = "Refer A Friend";
|
14 |
+
}
|
15 |
+
|
16 |
+
// If the magento app enabled?
|
17 |
+
if ( $status == 1 ) {
|
18 |
+
if ( Mage::getSingleton( 'customer/session' )->isLoggedIn() ) {
|
19 |
$customer = Mage::getSingleton( 'customer/session' )->getCustomer();
|
20 |
$email = $customer->getEmail();
|
21 |
+
$orderCollection = Mage::getModel( 'sales/order' )->getCollection()
|
22 |
+
->addFieldToFilter( 'customer_email', $email )
|
23 |
+
->addFieldToFilter( 'status', array('complete', 'processing') );
|
24 |
$_orderCnt = $orderCollection->count();
|
25 |
$first_purchase_required = Mage::getStoreConfig( 'rewardstream_options/section_two/rewardstream_first_purchase' );
|
26 |
|
27 |
+
// Show referral platform?
|
28 |
+
if ($first_purchase_required==2 || $_orderCnt > 0) {
|
29 |
+
// Disable display of first purchase
|
30 |
+
$displayFirstPurchaseMessage = false;
|
31 |
+
|
32 |
+
$customerData = Mage::getSingleton( 'customer/session' )->getCustomer();
|
33 |
+
$id = $customerData->getId();
|
34 |
+
$apiUrl = 'https://' . Mage::getStoreConfig( 'rewardstream_options/section_one/rewardstream_api_url' );
|
35 |
+
|
36 |
+
$apiKey = Mage::getStoreConfig( 'rewardstream_options/section_one/rewardstream_api_key' );
|
37 |
+
$collection = Mage::getModel( 'rewardstream/rewardstream' )->load( $id, 'customer_id' );
|
38 |
+
|
39 |
+
$customerid = $collection['customer_id'];
|
40 |
+
$refreshTokenUrl = Mage::getUrl('rewardstream/index/refreshtoken');
|
41 |
+
|
42 |
+
// Does the customer exist in our system already?
|
43 |
+
if ( $customerid == $id ) {
|
44 |
+
$accesstoken = $collection['access_token'];
|
45 |
+
$rewardid = $collection['reward_id'];
|
46 |
+
$activationtime = $collection['activationtime'];
|
47 |
+
$expiretime = date( 'Y-m-d H:i:s', strtotime( '+2 hour', strtotime( $activationtime ) ) );
|
48 |
+
$currenttime = date( 'Y-m-d H:i:s' );
|
49 |
+
|
50 |
+
if ( isset( $accesstoken ) ) {
|
51 |
+
if ( $currenttime > $expiretime || $accesstoken == "" ) {
|
52 |
+
// Need to call backend call to get token
|
53 |
+
$pageRefresh = true;
|
54 |
+
}
|
55 |
+
}
|
56 |
+
} else {
|
57 |
+
// Need to call backend call to get token
|
58 |
+
$pageRefresh = true;
|
59 |
+
}
|
60 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
}
|
62 |
} else {
|
63 |
$customerLoginURL = $this->getBaseUrl() . "customer/account/login";
|
64 |
Mage::app()->getFrontController()->getResponse()->setRedirect( $customerLoginURL )->sendResponse();
|
65 |
} ?>
|
66 |
|
67 |
+
<!--Page Display-->
|
68 |
+
<div class="rewardstream-referafriend">
|
69 |
+
<div class="page-title">
|
70 |
+
<h1><?php echo $title_name;?></h1>
|
71 |
+
</div>
|
72 |
+
|
73 |
+
<div id="content-error" class="error"></div>
|
74 |
+
<div class="loading"></div>
|
75 |
+
|
76 |
+
<!--Display First Purchase Message-->
|
77 |
+
<?php if ($displayFirstPurchaseMessage) { ?>
|
78 |
+
<div class="before-purchase">
|
79 |
+
<?php echo $this->getLayout()->createBlock( 'cms/block' )->setBlockId( 'refer-a-friend-purchase-required' )->toHtml(); ?>
|
80 |
+
</div>
|
81 |
+
|
82 |
+
<!--Display Embedded Referral Site-->
|
83 |
+
<?php } else if (!$pageRefresh) { ?>
|
84 |
+
<!--Load the page-->
|
85 |
+
<div id="refer-a-friend-platform">
|
86 |
+
<script type="text/javascript" src="<?php echo $apiUrl ?>/js/spark.v2.min.js?api_key=<?php echo $apiKey ?>&token=<?php echo $accesstoken ?>"></script>
|
87 |
+
<?php echo $this->getLayout()->createBlock( 'cms/block' )->setBlockId( 'refer-a-friend-page-content' )->toHtml(); ?>
|
88 |
+
</div>
|
89 |
+
<?php } ?>
|
90 |
+
|
91 |
+
<!--Loader and get the data-->
|
92 |
+
<script type="text/javascript">
|
93 |
+
jQuery(document).ready(function () {
|
94 |
+
var reward_id = "<?php echo $rewardid?>";
|
95 |
+
var customer_id = "<?php echo $id?>";
|
96 |
+
var refreshTokenUrl = "<?php echo $refreshTokenUrl;?>";
|
97 |
+
var loaderUrl = "<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA)."wysiwyg/rewardstream/loading.gif" ?>";
|
98 |
+
var refreshPage = "<?php echo $pageRefresh?>";
|
99 |
+
|
100 |
+
if (refreshPage) {
|
101 |
+
RSUtility.refreshToken(reward_id, customer_id, refreshTokenUrl, "content-error", loaderUrl);
|
102 |
+
}
|
103 |
+
});
|
104 |
+
</script>
|
105 |
</div>
|
js/rewardstream/RSUtility.js
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
function RSUtility () {}
|
2 |
+
|
3 |
+
RSUtility.refreshToken = function(reward_id, customer_id, refreshTokenUrl, errorElemId, loaderUrl) {
|
4 |
+
jQuery.ajax({
|
5 |
+
url: refreshTokenUrl,
|
6 |
+
data: {"reward_id": reward_id, "customer_id": customer_id},
|
7 |
+
type: 'post',
|
8 |
+
dataType: 'json',
|
9 |
+
beforeSend: function ()
|
10 |
+
{
|
11 |
+
jQuery('.loading').html('<img src="'+loaderUrl+'"/>');
|
12 |
+
},
|
13 |
+
success: function (result)
|
14 |
+
{
|
15 |
+
var response = JSON.parse(result);
|
16 |
+
if (response.Error) {
|
17 |
+
// Update error handler to display the message
|
18 |
+
var errorMessage = response.Error.Message + " " + response.Error.Reference;
|
19 |
+
jQuery('#'+errorElemId).html(errorMessage);
|
20 |
+
return;
|
21 |
+
}
|
22 |
+
else {
|
23 |
+
window.location.reload(true);
|
24 |
+
}
|
25 |
+
},
|
26 |
+
error: function(error) {
|
27 |
+
var errorMessage = error.responseText;
|
28 |
+
if (errorMessage == '') {
|
29 |
+
errorMessage = "Sorry, the Refer a Friend functionality is currently unavailable. Please try again later.";
|
30 |
+
}
|
31 |
+
jQuery('#'+errorElemId).html(errorMessage);
|
32 |
+
},
|
33 |
+
complete: function() {
|
34 |
+
// Remove the loader after success or error has been called.
|
35 |
+
// Mostly used for when there is an error. I want the message to display but remove the loader
|
36 |
+
jQuery('.loading').html('');
|
37 |
+
}
|
38 |
+
});
|
39 |
+
}
|
media/wysiwyg/rewardstream/rewardstream-magento-store-default-image.jpg
ADDED
Binary file
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>RewardStream_ReferAFriend</name>
|
4 |
-
<version>1.0
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.rewardstream.com/magento/license">RewardStream Software License Agreement</license>
|
7 |
<channel>community</channel>
|
@@ -9,11 +9,11 @@
|
|
9 |
<summary>Get new customers by adding a fully automated word-of-mouth customer referral marketing solution to your store</summary>
|
10 |
<description>Get new sales using the Refer A Friend extension. Launch a fully automated referral marketing program on your store with little-to-no IT. Customers can refer their friends and family to bring you new business. Automatically reward your existing customers for successful referrals and incentivize your new customers with special referral offers. Refer a Friend is a free Magento Extension and requires a paid service account with RewardStream.
|
11 |
</description>
|
12 |
-
<notes>
|
13 |
<authors><author><name>RewardStream</name><user>RewardStream</user><email>plugin-support@rewardstream.com</email></author></authors>
|
14 |
-
<date>
|
15 |
-
<time>01:
|
16 |
-
<contents><target name="magecommunity"><dir name="Rewardstream"><dir name="Referafriend"><dir name="Block"><file name="Button.php" hash="2d412348e526ce8259cb767b5d795fd7"/><dir name="Customer"><dir name="Account"><file name="Navigation.php" hash="18a0c268359658bd7619ce7168159364"/></dir></dir><file name="Getstartedbutton.php" hash="7bfea148b21c68ea5228ff64f4d9991e"/><dir name="Sales"><dir name="Order"><file name="History.php" hash="880e07a11f94ceab5bd5e066a4cfa838"/><file name="Recent.php" hash="8c5c64cd158205a7a5bd053a3c7a3cf0"/></dir></dir><file name="Script.php" hash="13b06afd09fada61b761ea5ff4254ede"/></dir><dir name="Helper"><file name="Data.php" hash="6ac29ba1b21d0ca246df13a216da649e"/></dir><dir name="Model"><file name="Observer.php" hash="8cfe14b1a89190e418074f98f81bee0e"/><file name="Options.php" hash="1c4fa6b3e55cec4b096ebbaedacacb19"/><dir name="Resource"><dir name="Rewardstream"><file name="Collection.php" hash="aeeb1df3e3eb6bdeadce8aa29d98eea5"/></dir><file name="Rewardstream.php" hash="8fe9853ebbad43796b683582db550620"/></dir><file name="Rewardstream.php" hash="884edc2f2bd98d5794c9c2bd6b84b9a8"/></dir><dir name="controllers"><file name="CartController.php" hash="
|
17 |
<compatible/>
|
18 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.5.0.0</min><max>1.9</max></package></required></dependencies>
|
19 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>RewardStream_ReferAFriend</name>
|
4 |
+
<version>1.1.0</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.rewardstream.com/magento/license">RewardStream Software License Agreement</license>
|
7 |
<channel>community</channel>
|
9 |
<summary>Get new customers by adding a fully automated word-of-mouth customer referral marketing solution to your store</summary>
|
10 |
<description>Get new sales using the Refer A Friend extension. Launch a fully automated referral marketing program on your store with little-to-no IT. Customers can refer their friends and family to bring you new business. Automatically reward your existing customers for successful referrals and incentivize your new customers with special referral offers. Refer a Friend is a free Magento Extension and requires a paid service account with RewardStream.
|
11 |
</description>
|
12 |
+
<notes>Content updates for our new interface</notes>
|
13 |
<authors><author><name>RewardStream</name><user>RewardStream</user><email>plugin-support@rewardstream.com</email></author></authors>
|
14 |
+
<date>2017-01-27</date>
|
15 |
+
<time>01:36:01</time>
|
16 |
+
<contents><target name="magecommunity"><dir name="Rewardstream"><dir name="Referafriend"><dir name="Block"><file name="Button.php" hash="2d412348e526ce8259cb767b5d795fd7"/><dir name="Customer"><dir name="Account"><file name="Navigation.php" hash="18a0c268359658bd7619ce7168159364"/></dir></dir><file name="Getstartedbutton.php" hash="7bfea148b21c68ea5228ff64f4d9991e"/><dir name="Sales"><dir name="Order"><file name="History.php" hash="880e07a11f94ceab5bd5e066a4cfa838"/><file name="Recent.php" hash="8c5c64cd158205a7a5bd053a3c7a3cf0"/></dir></dir><file name="Script.php" hash="13b06afd09fada61b761ea5ff4254ede"/></dir><dir name="Helper"><file name="Data.php" hash="6ac29ba1b21d0ca246df13a216da649e"/></dir><dir name="Model"><file name="Observer.php" hash="8cfe14b1a89190e418074f98f81bee0e"/><file name="Options.php" hash="1c4fa6b3e55cec4b096ebbaedacacb19"/><dir name="Resource"><dir name="Rewardstream"><file name="Collection.php" hash="aeeb1df3e3eb6bdeadce8aa29d98eea5"/></dir><file name="Rewardstream.php" hash="8fe9853ebbad43796b683582db550620"/></dir><file name="Rewardstream.php" hash="884edc2f2bd98d5794c9c2bd6b84b9a8"/></dir><dir name="controllers"><file name="CartController.php" hash="e8dd6101f0e36eeb4cde1931dc2e461f"/><file name="IndexController.php" hash="d3429574e292d9c7b9c55c6a060bcb30"/></dir><dir name="data"><dir name="rewardstream_setup"><file name="data-install-0.1.0.php" hash="ffa670c6e00b15f7197e017017aa5ac2"/></dir></dir><dir name="etc"><file name="config.xml" hash="be0f3fefd66b1593a7d6c0d93194a1a7"/><file name="system.xml" hash="4c382d84ff7c7ce434465593057132ba"/></dir><dir name="sql"><dir name="rewardstream_setup"><file name="install-0.1.0.php" hash="2ff36a8226dba730c568ce7bd5328b76"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="rewardstream.xml" hash="4c9a4575f0d44847032614368cf3924e"/></dir><dir name="template"><dir name="rewardstream"><file name="blockreward.phtml" hash="82e9d4d7d5592b40a9ada2ce3c8e1996"/><file name="general_script.phtml" hash="9386936cd1df44ccecb185e510417736"/><file name="rewardstream.phtml" hash="6f628a6916b1fffed4794276cd7c084d"/><file name="script.phtml" hash="a37b6436daeeb70f73c8dd03930ce1f9"/></dir></dir></dir></dir><dir name="rwd"><dir name="default"><dir name="layout"><file name="rewardstream.xml" hash="9453c01a065a609ba6b30e3e7420c97f"/></dir><dir name="template"><dir name="rewardstream"><file name="blockreward.phtml" hash="82e9d4d7d5592b40a9ada2ce3c8e1996"/><file name="general_script.phtml" hash="9386936cd1df44ccecb185e510417736"/><file name="rewardstream.phtml" hash="6f628a6916b1fffed4794276cd7c084d"/><file name="script.phtml" hash="a37b6436daeeb70f73c8dd03930ce1f9"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="RewardStream_ReferAFriend.xml" hash="d08d3aa024b2616e3a3792aeac0bc3cb"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="rewardstream"><dir name="css"><file name="rewardstream.css" hash="14e0164315bb6fec5354b331009b9793"/></dir></dir></dir></dir><dir name="rwd"><dir name="default"><dir name="rewardstream"><dir name="css"><file name="rewardstream.css" hash="14e0164315bb6fec5354b331009b9793"/></dir></dir></dir></dir></dir></target><target name="magemedia"><dir name="wysiwyg"><dir name="rewardstream"><file name="loading.gif" hash="dbd0f12f50cc2b56e2bce7daa36d00d0"/><file name="rewardstream-magento-store-default-image.jpg" hash="66004f46b67bbb30c8d4cd7e5fff1fa1"/><file name="sharing-is-caring.jpg" hash="079db8066ed86203bd78c52b20d6163e"/></dir></dir></target><target name="mageweb"><dir name="js"><dir name="rewardstream"><file name="RSUtility.js" hash="c56b4d2ca75647f8708ad59e6382e300"/><file name="jquery-1.10.2.min.js" hash="841dc30647f93349b7d8ef61deebe411"/><file name="noconflict.js" hash="12f820da0f5ba19abfb4f5fc270bb62c"/></dir></dir></target></contents>
|
17 |
<compatible/>
|
18 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.5.0.0</min><max>1.9</max></package></required></dependencies>
|
19 |
</package>
|
skin/frontend/base/default/rewardstream/css/rewardstream.css
CHANGED
@@ -1,21 +1,17 @@
|
|
1 |
@media (min-width: 771px) {
|
2 |
-
.
|
3 |
float: left;
|
4 |
width: 47%;
|
5 |
padding-right: 10px;
|
6 |
}
|
7 |
-
.
|
8 |
-
float:
|
9 |
width: 53%;
|
10 |
}
|
11 |
}
|
12 |
|
13 |
@media (max-width: 770px) {
|
14 |
-
.
|
15 |
padding-bottom: 10px;
|
16 |
}
|
17 |
-
}
|
18 |
-
|
19 |
-
.spark-refer-embed iframe {
|
20 |
-
height:400px !important
|
21 |
}
|
1 |
@media (min-width: 771px) {
|
2 |
+
.public-referral-page-image {
|
3 |
float: left;
|
4 |
width: 47%;
|
5 |
padding-right: 10px;
|
6 |
}
|
7 |
+
.public-referral-page-instructions {
|
8 |
+
float: left;
|
9 |
width: 53%;
|
10 |
}
|
11 |
}
|
12 |
|
13 |
@media (max-width: 770px) {
|
14 |
+
.public-referral-page-image {
|
15 |
padding-bottom: 10px;
|
16 |
}
|
|
|
|
|
|
|
|
|
17 |
}
|
skin/frontend/rwd/default/rewardstream/css/rewardstream.css
CHANGED
@@ -1,21 +1,17 @@
|
|
1 |
@media (min-width: 771px) {
|
2 |
-
.
|
3 |
float: left;
|
4 |
width: 47%;
|
5 |
padding-right: 10px;
|
6 |
}
|
7 |
-
.
|
8 |
-
float:
|
9 |
width: 53%;
|
10 |
}
|
11 |
}
|
12 |
|
13 |
@media (max-width: 770px) {
|
14 |
-
.
|
15 |
padding-bottom: 10px;
|
16 |
}
|
17 |
-
}
|
18 |
-
|
19 |
-
.spark-refer-embed iframe {
|
20 |
-
height:400px !important
|
21 |
}
|
1 |
@media (min-width: 771px) {
|
2 |
+
.public-referral-page-image {
|
3 |
float: left;
|
4 |
width: 47%;
|
5 |
padding-right: 10px;
|
6 |
}
|
7 |
+
.public-referral-page-instructions {
|
8 |
+
float: left;
|
9 |
width: 53%;
|
10 |
}
|
11 |
}
|
12 |
|
13 |
@media (max-width: 770px) {
|
14 |
+
.public-referral-page-image {
|
15 |
padding-bottom: 10px;
|
16 |
}
|
|
|
|
|
|
|
|
|
17 |
}
|