Version Notes
Add multi-website support for automatic API configuration.
Download this release
Release Info
Developer | Dave Clark |
Extension | LoyaltyLion |
Version | 1.2.1 |
Comparing to | |
See all releases |
Code changes from version 1.1.8 to 1.2.1
- app/code/local/LoyaltyLion/Core/Model/Observer.php +14 -6
- app/code/local/LoyaltyLion/Core/etc/config.xml +1 -1
- app/code/local/LoyaltyLion/CouponImport/Block/Adminhtml/Rule.php +23 -0
- app/code/local/LoyaltyLion/CouponImport/Model/Rule.php +48 -0
- app/code/local/LoyaltyLion/CouponImport/controllers/Adminhtml/QuicksetupController.php +64 -20
- app/code/local/LoyaltyLion/CouponImport/etc/config.xml +11 -1
- app/design/adminhtml/default/default/template/loyaltylion/system/config/button.phtml +36 -29
- package.xml +6 -6
app/code/local/LoyaltyLion/Core/Model/Observer.php
CHANGED
@@ -81,9 +81,7 @@ class LoyaltyLion_Core_Model_Observer {
|
|
81 |
$data['$magento_payload']['order_items'] = $this->getItems($order->getId());
|
82 |
$data['$magento_payload']['order_comments'] = $this->getComments($order->getId());
|
83 |
$data['$magento_payload']['addresses'] = $this->getAddresses($order->getId());
|
84 |
-
$data
|
85 |
-
$data['$magento_platform'] = Mage::getEdition();
|
86 |
-
$data['$magento_module_version'] = (string) Mage::getConfig()->getModuleConfig("LoyaltyLion_Core")->version;
|
87 |
|
88 |
if ($order->getBaseTotalDue() == $order->getBaseGrandTotal()) {
|
89 |
$data['payment_status'] = 'not_paid';
|
@@ -238,9 +236,7 @@ class LoyaltyLion_Core_Model_Observer {
|
|
238 |
$data['$magento_payload']['order_items'] = $this->getItems($order->getId());
|
239 |
$data['$magento_payload']['order_comments'] = $this->getComments($order->getId());
|
240 |
$data['$magento_payload']['addresses'] = $this->getAddresses($order->getId());
|
241 |
-
$data
|
242 |
-
$data['$magento_platform'] = Mage::getEdition();
|
243 |
-
$data['$magento_module_version'] = (string) Mage::getConfig()->getModuleConfig("LoyaltyLion_Core")->version;
|
244 |
|
245 |
$response = $this->client->orders->update($order->getId(), $data);
|
246 |
|
@@ -311,4 +307,16 @@ class LoyaltyLion_Core_Model_Observer {
|
|
311 |
|
312 |
return $values[1];
|
313 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
314 |
}
|
81 |
$data['$magento_payload']['order_items'] = $this->getItems($order->getId());
|
82 |
$data['$magento_payload']['order_comments'] = $this->getComments($order->getId());
|
83 |
$data['$magento_payload']['addresses'] = $this->getAddresses($order->getId());
|
84 |
+
$data = array_merge($data, $this->getVersionInfo());
|
|
|
|
|
85 |
|
86 |
if ($order->getBaseTotalDue() == $order->getBaseGrandTotal()) {
|
87 |
$data['payment_status'] = 'not_paid';
|
236 |
$data['$magento_payload']['order_items'] = $this->getItems($order->getId());
|
237 |
$data['$magento_payload']['order_comments'] = $this->getComments($order->getId());
|
238 |
$data['$magento_payload']['addresses'] = $this->getAddresses($order->getId());
|
239 |
+
$data = array_merge($data, $this->getVersionInfo());
|
|
|
|
|
240 |
|
241 |
$response = $this->client->orders->update($order->getId(), $data);
|
242 |
|
307 |
|
308 |
return $values[1];
|
309 |
}
|
310 |
+
|
311 |
+
private function getVersionInfo() {
|
312 |
+
$version_info = Array();
|
313 |
+
$version_info['$magento_version'] = Mage::getVersion();
|
314 |
+
if (method_exists('Mage', 'getEdition')) {
|
315 |
+
$version_info['$magento_platform'] = Mage::getEdition();
|
316 |
+
} else {
|
317 |
+
$version_info['$magento_platform'] = 'unknown';
|
318 |
+
}
|
319 |
+
$version_info['$magento_module_version'] = (string) Mage::getConfig()->getModuleConfig("LoyaltyLion_Core")->version;
|
320 |
+
return $version_info;
|
321 |
+
}
|
322 |
}
|
app/code/local/LoyaltyLion/Core/etc/config.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<LoyaltyLion_Core>
|
5 |
-
<version>0.0.
|
6 |
</LoyaltyLion_Core>
|
7 |
</modules>
|
8 |
<global>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<LoyaltyLion_Core>
|
5 |
+
<version>0.0.8</version>
|
6 |
</LoyaltyLion_Core>
|
7 |
</modules>
|
8 |
<global>
|
app/code/local/LoyaltyLion/CouponImport/Block/Adminhtml/Rule.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class LoyaltyLion_CouponImport_Block_Adminhtml_Rule extends Mage_Adminhtml_Block_Promo_Quote_Edit_Tab_Main
|
4 |
+
{
|
5 |
+
protected function _prepareForm() {
|
6 |
+
// In magento 1.6, we don't have REST API access, so we just add a bulk import option
|
7 |
+
// to the pricerule UI. It's not pretty, but it will get the job done.
|
8 |
+
parent::_prepareForm();
|
9 |
+
$form = $this->getForm();
|
10 |
+
// For other versions, we should hide this - no need to clutter the UI
|
11 |
+
if (Mage::getVersion() < '1.7') {
|
12 |
+
$fieldset = $form->addFieldset('loyaltylion', array('legend'=>Mage::helper('salesrule')->__('LoyaltyLion Vouchers')));
|
13 |
+
$fieldset->addField('ll_codes', 'textarea', array(
|
14 |
+
'name' => 'll_codes',
|
15 |
+
'label' => Mage::helper('salesrule')->__('Voucher Codes'),
|
16 |
+
'title' => Mage::helper('salesrule')->__('Voucher Codes'),
|
17 |
+
'style' => 'width: 98%; height: 100px;',
|
18 |
+
));
|
19 |
+
$this->setForm($form);
|
20 |
+
}
|
21 |
+
return $form;
|
22 |
+
}
|
23 |
+
}
|
app/code/local/LoyaltyLion/CouponImport/Model/Rule.php
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class LoyaltyLion_CouponImport_Model_Rule extends Mage_SalesRule_Model_Rule
|
4 |
+
{
|
5 |
+
protected $_unsavedCoupons;
|
6 |
+
|
7 |
+
function loadPost(array $rule) {
|
8 |
+
// At this point we can't persist the codes quite yet,
|
9 |
+
// because the rule they belong to might not have been saved.
|
10 |
+
// So we'll keep them until the _afterSave hook.
|
11 |
+
if (isset($rule['ll_codes'])) {
|
12 |
+
$codes = explode("\n", $rule['ll_codes']);
|
13 |
+
foreach($codes as $i => $code) {
|
14 |
+
$codes[$i] = trim($code);
|
15 |
+
}
|
16 |
+
if (count($codes)) {
|
17 |
+
$this->_unsavedCoupons = $codes;
|
18 |
+
}
|
19 |
+
}
|
20 |
+
return parent::loadPost($rule);
|
21 |
+
}
|
22 |
+
|
23 |
+
protected function _afterSave()
|
24 |
+
{
|
25 |
+
if (count($this->_unsavedCoupons)) {
|
26 |
+
$ruleId = $this->getId();
|
27 |
+
if ($ruleId) {
|
28 |
+
$coupon = Mage::getModel('salesrule/coupon');
|
29 |
+
$now = $this->getResource()->formatDate(
|
30 |
+
Mage::getSingleton('core/date')->gmtTimestamp()
|
31 |
+
);
|
32 |
+
$expirationDate = $this->toDate;
|
33 |
+
foreach ($this->_unsavedCoupons as $code) {
|
34 |
+
$code = trim($code);
|
35 |
+
$coupon->setId(null)
|
36 |
+
->setRuleId($ruleId)
|
37 |
+
->setUsageLimit(1)
|
38 |
+
->setUsagePerCustomer(1)
|
39 |
+
->setExpirationDate($expirationDate)
|
40 |
+
->setCreatedAt($now)
|
41 |
+
->setCode($code)
|
42 |
+
->save();
|
43 |
+
}
|
44 |
+
}
|
45 |
+
}
|
46 |
+
return parent::_afterSave();
|
47 |
+
}
|
48 |
+
}
|
app/code/local/LoyaltyLion/CouponImport/controllers/Adminhtml/QuicksetupController.php
CHANGED
@@ -6,6 +6,18 @@ class LoyaltyLion_CouponImport_Adminhtml_QuickSetupController extends Mage_Admin
|
|
6 |
{
|
7 |
public $loyaltyLionURL = 'https://loyaltylion.com';
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
public function generateRestRole($name) {
|
10 |
Mage::log("[LoyaltyLion] creating REST role");
|
11 |
//check "rest role created" flag
|
@@ -63,7 +75,7 @@ class LoyaltyLion_CouponImport_Adminhtml_QuickSetupController extends Mage_Admin
|
|
63 |
}
|
64 |
|
65 |
public function enableAllAttributes() {
|
66 |
-
Mage::log("[LoyaltyLion] Enabling attribute access for
|
67 |
$type = 'admin';
|
68 |
$ruleTree = Mage::getSingleton(
|
69 |
'api2/acl_global_rule_tree',
|
@@ -118,11 +130,19 @@ class LoyaltyLion_CouponImport_Adminhtml_QuickSetupController extends Mage_Admin
|
|
118 |
}
|
119 |
|
120 |
public function getAccessToken($consumer_id, $userID) {
|
121 |
-
$
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
}
|
127 |
|
128 |
public function getOAuthCredentials($id, $userID) {
|
@@ -134,9 +154,9 @@ class LoyaltyLion_CouponImport_Adminhtml_QuickSetupController extends Mage_Admin
|
|
134 |
return array_merge(array('consumer_key' => $oauth['key'], 'consumer_secret' => $oauth['secret']), $accessToken);
|
135 |
}
|
136 |
|
137 |
-
public function submitOAuthCredentials($credentials, $token, $secret) {
|
138 |
if (isset($_SERVER['LOYALTYLION_WEBSITE_BASE'])) {
|
139 |
-
|
140 |
}
|
141 |
Mage::log("[LoyaltyLion] Submitting OAuth credentials to LoyaltyLion site");
|
142 |
|
@@ -145,6 +165,9 @@ class LoyaltyLion_CouponImport_Adminhtml_QuickSetupController extends Mage_Admin
|
|
145 |
$base_url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
146 |
$credentials['base_url'] = $base_url;
|
147 |
$credentials['extension_version'] = (string) Mage::getConfig()->getModuleConfig("LoyaltyLion_Core")->version;
|
|
|
|
|
|
|
148 |
$resp = $connection->post($setup_uri, $credentials);
|
149 |
if (isset($resp->error)) {
|
150 |
Mage::log("[LoyaltyLion] Error submitting credentials:" .' '. $resp->error);
|
@@ -160,34 +183,55 @@ class LoyaltyLion_CouponImport_Adminhtml_QuickSetupController extends Mage_Admin
|
|
160 |
}
|
161 |
}
|
162 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
public function LLAPISetup() {
|
164 |
Mage::log("[LoyaltyLion] Setting up API access");
|
165 |
$currentUser = Mage::getSingleton('admin/session')->getUser()->getId();
|
166 |
-
$roleName = 'LoyaltyLion';
|
167 |
$AppName = 'LoyaltyLion';
|
168 |
|
169 |
$token = $this->getRequest()->getParam('token');
|
170 |
$secret = $this->getRequest()->getParam('secret');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
|
172 |
if (!empty($token) && !empty($secret)) {
|
173 |
Mage::log("[LoyaltyLion] Saving new LoyaltyLion credentials");
|
174 |
-
Mage::getModel('core/config')->saveConfig('loyaltylion/configuration/loyaltylion_token', $token);
|
175 |
-
Mage::getModel('core/config')->saveConfig('loyaltylion/configuration/loyaltylion_secret', $secret);
|
176 |
} else {
|
177 |
$token = Mage::getStoreConfig('loyaltylion/configuration/loyaltylion_token');
|
178 |
$secret = Mage::getStoreConfig('loyaltylion/configuration/loyaltylion_secret');
|
179 |
}
|
180 |
|
181 |
-
$roleID =
|
182 |
-
if (!$roleID) {
|
183 |
-
$roleID = $this->generateRestRole($roleName);
|
184 |
-
Mage::getModel('core/config')->saveConfig('loyaltylion/internals/rest_role_id', $roleID);
|
185 |
-
} else {
|
186 |
-
Mage::log("[LoyaltyLion] Already created REST role, skipping");
|
187 |
-
}
|
188 |
|
189 |
//assigning just overwrites old permissions with "all", so doing it twice is harmless
|
190 |
$assigned = $this->assignToRole($currentUser, $roleID);
|
|
|
191 |
//As with the role assignment, we can do this twice and it's okay.
|
192 |
$this->enableAllAttributes();
|
193 |
|
@@ -206,9 +250,9 @@ class LoyaltyLion_CouponImport_Adminhtml_QuickSetupController extends Mage_Admin
|
|
206 |
$credentials = $this->getOAuthCredentials($OAuthConsumerID, $currentUser);
|
207 |
}
|
208 |
|
209 |
-
$result = $this->submitOAuthCredentials($credentials, $token, $secret);
|
210 |
if ($result == "ok") {
|
211 |
-
Mage::getModel('core/config')->saveConfig('loyaltylion/internals/has_submitted_oauth', 1);
|
212 |
}
|
213 |
return $result;
|
214 |
}
|
6 |
{
|
7 |
public $loyaltyLionURL = 'https://loyaltylion.com';
|
8 |
|
9 |
+
public function getRestRole() {
|
10 |
+
$roleName = 'LoyaltyLion';
|
11 |
+
$roleID = Mage::getStoreConfig('loyaltylion/internals/rest_role_id');
|
12 |
+
if ($roleID) {
|
13 |
+
Mage::log("[LoyaltyLion] Already created REST role, skipping");
|
14 |
+
return $roleID;
|
15 |
+
}
|
16 |
+
$roleID = $this->generateRestRole($roleName);
|
17 |
+
Mage::getModel('core/config')->saveConfig('loyaltylion/internals/rest_role_id', $roleID);
|
18 |
+
return $roleID;
|
19 |
+
}
|
20 |
+
|
21 |
public function generateRestRole($name) {
|
22 |
Mage::log("[LoyaltyLion] creating REST role");
|
23 |
//check "rest role created" flag
|
75 |
}
|
76 |
|
77 |
public function enableAllAttributes() {
|
78 |
+
Mage::log("[LoyaltyLion] Enabling attribute access for admin role");
|
79 |
$type = 'admin';
|
80 |
$ruleTree = Mage::getSingleton(
|
81 |
'api2/acl_global_rule_tree',
|
130 |
}
|
131 |
|
132 |
public function getAccessToken($consumer_id, $userID) {
|
133 |
+
$tokenId = Mage::getStoreConfig('loyaltylion/internals/oauth_token_id');
|
134 |
+
if ($tokenId) {
|
135 |
+
$requestToken = Mage::getModel('oauth/token')->load($tokenId);
|
136 |
+
$tokenData = $requestToken->getData();
|
137 |
+
} else {
|
138 |
+
$requestToken = Mage::getModel('oauth/token')->createRequestToken($consumer_id, "https://loyaltylion.com/");
|
139 |
+
$requestToken->authorize($userID, 'admin');
|
140 |
+
$accessToken = $requestToken->convertToAccess();
|
141 |
+
$tokenData = $accessToken->getData();
|
142 |
+
Mage::getModel('core/config')
|
143 |
+
->saveConfig('loyaltylion/internals/oauth_token_id', $tokenData['entity_id']);
|
144 |
+
}
|
145 |
+
return array('access_token' => $tokenData['token'], 'access_secret' => $tokenData['secret']);
|
146 |
}
|
147 |
|
148 |
public function getOAuthCredentials($id, $userID) {
|
154 |
return array_merge(array('consumer_key' => $oauth['key'], 'consumer_secret' => $oauth['secret']), $accessToken);
|
155 |
}
|
156 |
|
157 |
+
public function submitOAuthCredentials($credentials, $token, $secret, $websiteId) {
|
158 |
if (isset($_SERVER['LOYALTYLION_WEBSITE_BASE'])) {
|
159 |
+
$this->loyaltyLionURL = $_SERVER['LOYALTYLION_WEBSITE_BASE'];
|
160 |
}
|
161 |
Mage::log("[LoyaltyLion] Submitting OAuth credentials to LoyaltyLion site");
|
162 |
|
165 |
$base_url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
166 |
$credentials['base_url'] = $base_url;
|
167 |
$credentials['extension_version'] = (string) Mage::getConfig()->getModuleConfig("LoyaltyLion_Core")->version;
|
168 |
+
if ($websiteId > 0) {
|
169 |
+
$credentials['website_id'] = $websiteId;
|
170 |
+
}
|
171 |
$resp = $connection->post($setup_uri, $credentials);
|
172 |
if (isset($resp->error)) {
|
173 |
Mage::log("[LoyaltyLion] Error submitting credentials:" .' '. $resp->error);
|
183 |
}
|
184 |
}
|
185 |
|
186 |
+
public function getFirstWebsite() {
|
187 |
+
$websites = Mage::getModel('core/website')->getCollection();
|
188 |
+
foreach($websites as $website) {
|
189 |
+
$id = $website->getId();
|
190 |
+
return $id;
|
191 |
+
}
|
192 |
+
return 0;
|
193 |
+
}
|
194 |
+
|
195 |
public function LLAPISetup() {
|
196 |
Mage::log("[LoyaltyLion] Setting up API access");
|
197 |
$currentUser = Mage::getSingleton('admin/session')->getUser()->getId();
|
|
|
198 |
$AppName = 'LoyaltyLion';
|
199 |
|
200 |
$token = $this->getRequest()->getParam('token');
|
201 |
$secret = $this->getRequest()->getParam('secret');
|
202 |
+
$code = $this->getRequest()->getParam('code');
|
203 |
+
|
204 |
+
$websiteId = 0;
|
205 |
+
$scope = 'default';
|
206 |
+
$scopeId = 0;
|
207 |
+
|
208 |
+
if (!empty($code)) {
|
209 |
+
// having this means this config is scoped to a particular website, rather than the root 'default' scope
|
210 |
+
$website = Mage::getModel('core/website')->load($code);
|
211 |
+
$websiteId = $website->getId();
|
212 |
+
$scope = 'websites';
|
213 |
+
$scopeId = $websiteId;
|
214 |
+
} else {
|
215 |
+
// LL is being configured in the `default` scope.
|
216 |
+
// We'll still report a guess at a websiteId; this could be wrong
|
217 |
+
// but knowing the default website is probably better than nothing.
|
218 |
+
$websiteId = $this->getFirstWebsite();
|
219 |
+
}
|
220 |
|
221 |
if (!empty($token) && !empty($secret)) {
|
222 |
Mage::log("[LoyaltyLion] Saving new LoyaltyLion credentials");
|
223 |
+
Mage::getModel('core/config')->saveConfig('loyaltylion/configuration/loyaltylion_token', $token, $scope, $scopeId);
|
224 |
+
Mage::getModel('core/config')->saveConfig('loyaltylion/configuration/loyaltylion_secret', $secret, $scope, $scopeId);
|
225 |
} else {
|
226 |
$token = Mage::getStoreConfig('loyaltylion/configuration/loyaltylion_token');
|
227 |
$secret = Mage::getStoreConfig('loyaltylion/configuration/loyaltylion_secret');
|
228 |
}
|
229 |
|
230 |
+
$roleID = $this->getRestRole();
|
|
|
|
|
|
|
|
|
|
|
|
|
231 |
|
232 |
//assigning just overwrites old permissions with "all", so doing it twice is harmless
|
233 |
$assigned = $this->assignToRole($currentUser, $roleID);
|
234 |
+
|
235 |
//As with the role assignment, we can do this twice and it's okay.
|
236 |
$this->enableAllAttributes();
|
237 |
|
250 |
$credentials = $this->getOAuthCredentials($OAuthConsumerID, $currentUser);
|
251 |
}
|
252 |
|
253 |
+
$result = $this->submitOAuthCredentials($credentials, $token, $secret, $websiteId);
|
254 |
if ($result == "ok") {
|
255 |
+
Mage::getModel('core/config')->saveConfig('loyaltylion/internals/has_submitted_oauth', 1, $scope, $scopeId);
|
256 |
}
|
257 |
return $result;
|
258 |
}
|
app/code/local/LoyaltyLion/CouponImport/etc/config.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<LoyaltyLion_CouponImport>
|
5 |
-
<version>0.1
|
6 |
</LoyaltyLion_CouponImport>
|
7 |
</modules>
|
8 |
<global>
|
@@ -10,11 +10,21 @@
|
|
10 |
<couponimport>
|
11 |
<class>LoyaltyLion_CouponImport_Model</class>
|
12 |
</couponimport>
|
|
|
|
|
|
|
|
|
|
|
13 |
</models>
|
14 |
<blocks>
|
15 |
<couponimport>
|
16 |
<class>LoyaltyLion_CouponImport_Block</class>
|
17 |
</couponimport>
|
|
|
|
|
|
|
|
|
|
|
18 |
</blocks>
|
19 |
</global>
|
20 |
<admin>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<LoyaltyLion_CouponImport>
|
5 |
+
<version>0.2.1</version>
|
6 |
</LoyaltyLion_CouponImport>
|
7 |
</modules>
|
8 |
<global>
|
10 |
<couponimport>
|
11 |
<class>LoyaltyLion_CouponImport_Model</class>
|
12 |
</couponimport>
|
13 |
+
<salesrule>
|
14 |
+
<rewrite>
|
15 |
+
<rule>LoyaltyLion_CouponImport_Model_Rule</rule>
|
16 |
+
</rewrite>
|
17 |
+
</salesrule>
|
18 |
</models>
|
19 |
<blocks>
|
20 |
<couponimport>
|
21 |
<class>LoyaltyLion_CouponImport_Block</class>
|
22 |
</couponimport>
|
23 |
+
<adminhtml>
|
24 |
+
<rewrite>
|
25 |
+
<promo_quote_edit_tab_main>LoyaltyLion_CouponImport_Block_Adminhtml_Rule</promo_quote_edit_tab_main>
|
26 |
+
</rewrite>
|
27 |
+
</adminhtml>
|
28 |
</blocks>
|
29 |
</global>
|
30 |
<admin>
|
app/design/adminhtml/default/default/template/loyaltylion/system/config/button.phtml
CHANGED
@@ -1,34 +1,41 @@
|
|
1 |
<script type="text/javascript">
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
|
|
|
|
26 |
button.removeClassName('success').addClassName('fail');
|
27 |
-
button.update("Error");
|
28 |
}
|
29 |
-
}
|
30 |
-
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
32 |
</script>
|
33 |
-
|
34 |
<?php echo $this->getButtonHtml() ?>
|
1 |
<script type="text/javascript">
|
2 |
+
//<![CDATA[
|
3 |
+
function doSetup() {
|
4 |
+
var button = $('loyaltylion_setup_button');
|
5 |
+
var token = $('loyaltylion_configuration_loyaltylion_token').value
|
6 |
+
var secret = $('loyaltylion_configuration_loyaltylion_secret').value
|
7 |
+
var path_components = window.location.pathname.split('/')
|
8 |
+
var website_pos = path_components.indexOf('website') + 1
|
9 |
+
var code = ''
|
10 |
+
if (website_pos) {
|
11 |
+
var code = path_components[website_pos]
|
12 |
+
}
|
13 |
+
|
14 |
+
new Ajax.Request('<?php echo $this->getAjaxSetupUrl() ?>', {
|
15 |
+
method: 'get',
|
16 |
+
parameters: { 'token': token, 'secret': secret, 'code': code },
|
17 |
+
onSuccess: function(transport){
|
18 |
+
switch (transport.responseText) {
|
19 |
+
case "ok":
|
20 |
+
button.removeClassName('fail').addClassName('success');
|
21 |
+
button.update("Success");
|
22 |
+
break;
|
23 |
+
case "not-configured-yet":
|
24 |
+
button.removeClassName('fail').removeClassName('success');
|
25 |
+
button.update("Please enter your Token / Secret first");
|
26 |
+
break;
|
27 |
+
default:
|
28 |
button.removeClassName('success').addClassName('fail');
|
29 |
+
button.update("Error - are you sure you entered the right Token / Secret?");
|
30 |
}
|
31 |
+
},
|
32 |
+
onError: function(transport){
|
33 |
+
button.removeClassName('success').addClassName('fail');
|
34 |
+
button.update("Error");
|
35 |
+
}
|
36 |
+
});
|
37 |
+
}
|
38 |
+
//]]>
|
39 |
</script>
|
40 |
+
|
41 |
<?php echo $this->getButtonHtml() ?>
|
package.xml
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>LoyaltyLion</name>
|
4 |
-
<version>1.1
|
5 |
<stability>stable</stability>
|
6 |
<license>MIT</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Use LoyaltyLion to add your own loyalty program in minutes and gain valuable customer insights.</summary>
|
10 |
-
<description>Increase activity and customer happiness by offering points for signups, purchases, visits and referrals. Your customers will collect points and redeem them for rewards to use at your
|
11 |
-
<notes>
|
12 |
<authors><author><name>Dave Clark</name><user>clarkdave_ll</user><email>dave@loyaltylion.com</email></author><author><name>Patrick Molgaard</name><user>draaglom</user><email>patrick@loyaltylion.com</email></author></authors>
|
13 |
-
<date>2016-
|
14 |
-
<time>
|
15 |
-
<contents><target name="magelocal"><dir name="LoyaltyLion"><dir><dir name="Core"><dir name="Block"><file name="Sdk.php" hash="0f1269720db26f76acf791b3e944567b"/></dir><dir name="Helper"><file name="Data.php" hash="3ac59332d4eb3469869d84a07f949d17"/></dir><dir name="Model"><file name="Observer.php" hash="
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.3.0</min><max>7.0.0</max></php></required></dependencies>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>LoyaltyLion</name>
|
4 |
+
<version>1.2.1</version>
|
5 |
<stability>stable</stability>
|
6 |
<license>MIT</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Use LoyaltyLion to add your own loyalty program in minutes and gain valuable customer insights.</summary>
|
10 |
+
<description>Increase activity and customer happiness by offering points for signups, purchases, visits and referrals. Your customers will collect points and redeem them for rewards to use at your store, which encourages repeat visits and long term loyalty.</description>
|
11 |
+
<notes>Add multi-website support for automatic API configuration.</notes>
|
12 |
<authors><author><name>Dave Clark</name><user>clarkdave_ll</user><email>dave@loyaltylion.com</email></author><author><name>Patrick Molgaard</name><user>draaglom</user><email>patrick@loyaltylion.com</email></author></authors>
|
13 |
+
<date>2016-06-28</date>
|
14 |
+
<time>16:25:30</time>
|
15 |
+
<contents><target name="magelocal"><dir name="LoyaltyLion"><dir><dir name="Core"><dir name="Block"><file name="Sdk.php" hash="0f1269720db26f76acf791b3e944567b"/></dir><dir name="Helper"><file name="Data.php" hash="3ac59332d4eb3469869d84a07f949d17"/></dir><dir name="Model"><file name="Observer.php" hash="26b13eb01926b6f9269c15fca603df99"/></dir><dir name="etc"><file name="config.xml" hash="f94760b90c1d49d255cbb3e3d984365e"/><file name="system.xml" hash="37d1b84b3ca2dbdc78b7194b91191de5"/></dir><dir name="lib"><dir name="loyaltylion-client"><dir name="lib"><file name="connection.php" hash="56f73205995ca0925a1b4cb6b2deb56c"/></dir><file name="main.php" hash="2dc4f4fc1caf2ece19417b44c48e21fa"/></dir></dir></dir><dir name="CouponImport"><dir name="Block"><dir name="Adminhtml"><file name="Button.php" hash="3fe32ef718f21cdbed71bd023158960a"/><file name="Rule.php" hash="05ae099e2a7d71116e2ece3bc07a6501"/></dir></dir><dir name="Model"><dir name="Api2"><dir name="Coupon"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="ed9a42c0d8945b69c7dc3436609911d1"/></dir></dir></dir><file name="Coupon.php" hash="bbaf6c59b4b132eb54a72e0688f3fab1"/><file name="PriceRule.php" hash="4b8d85f224fd5f121727977066c50cd1"/><dir name="Pricerule"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="72c2f66b0de2996a612c7509cbbd82f2"/></dir></dir></dir></dir><file name="Rule.php" hash="6ed65686220c97efbbc7316a76571305"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="QuicksetupController.php" hash="c0f2f805a309ff891e70aee205047f1f"/></dir></dir><dir name="etc"><file name="api2.xml" hash="e8ec47daccbb43584239fe3aeac9c122"/><file name="config.xml" hash="34e1654a09f5f7ee6c42b12d915e9c4f"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="loyaltylion"><dir><dir name="core"><file name="sdk.phtml" hash="5e159702c28c50236887eb31b488539a"/></dir></dir></dir></dir><dir name="layout"><file name="loyaltylion.xml" hash="f2c14ac8327d4eea6d8da6dfd61ede4c"/></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="loyaltylion"><dir><dir name="system"><dir name="config"><file name="button.phtml" hash="caa9c44d6b504f6c625f2f0aaa9a21c2"/></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="LoyaltyLion_Core.xml" hash="33446455fb634c28776a0fe45095a459"/><file name="LoyaltyLion_CouponImport.xml" hash="ff6ba2c149886ab7ee7de418619bb734"/></dir></target></contents>
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.3.0</min><max>7.0.0</max></php></required></dependencies>
|
18 |
</package>
|