recapture - Version 1.2.0

Version Notes

Updated version to 1.2.0

Download this release

Release Info

Developer David Webber
Extension recapture
Version 1.2.0
Comparing to
See all releases


Code changes from version 1.1.7 to 1.2.0

Files changed (23) hide show
  1. app/code/local/Recapture/Connector/Block/Adminhtml/System/Config/Authenticate.php +18 -18
  2. app/code/local/Recapture/Connector/Block/Adminhtml/System/Config/Key.php +10 -10
  3. app/code/local/Recapture/Connector/Block/Adminhtml/System/Config/Status.php +18 -18
  4. app/code/local/Recapture/Connector/Block/Client.php +44 -40
  5. app/code/local/Recapture/Connector/Block/Client/Page.php +5 -0
  6. app/code/local/Recapture/Connector/Block/Client/Product.php +5 -0
  7. app/code/local/Recapture/Connector/Helper/Data.php +254 -219
  8. app/code/local/Recapture/Connector/Helper/Transport.php +27 -27
  9. app/code/local/Recapture/Connector/Model/Landing.php +17 -17
  10. app/code/local/Recapture/Connector/Model/Observer.php +225 -233
  11. app/code/local/Recapture/Connector/controllers/CartController.php +75 -75
  12. app/code/local/Recapture/Connector/controllers/EmailController.php +27 -0
  13. app/code/local/Recapture/Connector/controllers/IndexController.php +14 -14
  14. app/code/local/Recapture/Connector/controllers/RecaptureController.php +0 -5
  15. app/code/local/Recapture/Connector/controllers/Recaptureadmin/AuthenticateController.php +79 -78
  16. app/code/local/Recapture/Connector/etc/config.xml +140 -140
  17. app/code/local/Recapture/Connector/etc/system.xml +119 -119
  18. app/design/frontend/base/default/layout/recapture.xml +19 -9
  19. app/design/frontend/base/default/template/recapture/client.phtml +0 -8
  20. app/design/frontend/base/default/template/recapture/client/page.phtml +10 -0
  21. app/design/frontend/base/default/template/recapture/client/product.phtml +9 -0
  22. app/etc/modules/Recapture_Connector.xml +8 -8
  23. package.xml +5 -5
app/code/local/Recapture/Connector/Block/Adminhtml/System/Config/Authenticate.php CHANGED
@@ -1,19 +1,19 @@
1
- <?php
2
- class Recapture_Connector_Block_Adminhtml_System_Config_Authenticate extends Mage_Adminhtml_Block_System_Config_Form_Field
3
- implements Varien_Data_Form_Element_Renderer_Interface {
4
-
5
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element){
6
-
7
- $buttonBlock = Mage::app()->getLayout()->createBlock('adminhtml/widget_button');
8
-
9
- $data = array(
10
- 'label' => Mage::helper('adminhtml')->__('Authenticate Account'),
11
- 'onclick' => 'setLocation(\''.Mage::helper('adminhtml')->getUrl("adminhtml/recaptureadmin_authenticate", Mage::helper('recapture')->getScopeForUrl()) . '\' )',
12
- 'class' => '',
13
- );
14
-
15
- $html = $buttonBlock->setData($data)->toHtml();
16
-
17
- return $html;
18
- }
19
  }
1
+ <?php
2
+ class Recapture_Connector_Block_Adminhtml_System_Config_Authenticate extends Mage_Adminhtml_Block_System_Config_Form_Field
3
+ implements Varien_Data_Form_Element_Renderer_Interface {
4
+
5
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element){
6
+
7
+ $buttonBlock = Mage::app()->getLayout()->createBlock('adminhtml/widget_button');
8
+
9
+ $data = array(
10
+ 'label' => Mage::helper('adminhtml')->__('Authenticate Account'),
11
+ 'onclick' => 'setLocation(\''.Mage::helper('adminhtml')->getUrl("adminhtml/recaptureadmin_authenticate", Mage::helper('recapture')->getScopeForUrl()) . '\' )',
12
+ 'class' => '',
13
+ );
14
+
15
+ $html = $buttonBlock->setData($data)->toHtml();
16
+
17
+ return $html;
18
+ }
19
  }
app/code/local/Recapture/Connector/Block/Adminhtml/System/Config/Key.php CHANGED
@@ -1,11 +1,11 @@
1
- <?php
2
-
3
- class Recapture_Connector_Block_Adminhtml_System_Config_Key extends Mage_Adminhtml_Block_System_Config_Form_Field {
4
-
5
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
6
-
7
- return parent::_getElementHtml($element);
8
-
9
- }
10
-
11
  }
1
+ <?php
2
+
3
+ class Recapture_Connector_Block_Adminhtml_System_Config_Key extends Mage_Adminhtml_Block_System_Config_Form_Field {
4
+
5
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
6
+
7
+ return parent::_getElementHtml($element);
8
+
9
+ }
10
+
11
  }
app/code/local/Recapture/Connector/Block/Adminhtml/System/Config/Status.php CHANGED
@@ -1,19 +1,19 @@
1
- <?php
2
-
3
- class Recapture_Connector_Block_Adminhtml_System_Config_Status extends Mage_Adminhtml_Block_System_Config_Form_Field {
4
-
5
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
6
-
7
- $authenticated = Mage::getStoreConfig('recapture/configuration/authenticated', Mage::helper('recapture')->getScopeStoreId());
8
-
9
- $image = $this->getSkinUrl('images/' . ($authenticated ? 'success' : 'error') . '_msg_icon.gif');
10
- $text = '<img style="float: left; margin-right: 6px;" src="' . $image . '" /> ';
11
- $text .= '<span class="' . ($authenticated ? 'success' : 'error') . '">';
12
- $text .= $authenticated ? 'Authenticated!' : 'Not Authenticated';
13
- $text .= '</span>';
14
-
15
- return $text;
16
-
17
- }
18
-
19
  }
1
+ <?php
2
+
3
+ class Recapture_Connector_Block_Adminhtml_System_Config_Status extends Mage_Adminhtml_Block_System_Config_Form_Field {
4
+
5
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
6
+
7
+ $authenticated = Mage::getStoreConfig('recapture/configuration/authenticated', Mage::helper('recapture')->getScopeStoreId());
8
+
9
+ $image = $this->getSkinUrl('images/' . ($authenticated ? 'success' : 'error') . '_msg_icon.gif');
10
+ $text = '<img style="float: left; margin-right: 6px;" src="' . $image . '" /> ';
11
+ $text .= '<span class="' . ($authenticated ? 'success' : 'error') . '">';
12
+ $text .= $authenticated ? 'Authenticated!' : 'Not Authenticated';
13
+ $text .= '</span>';
14
+
15
+ return $text;
16
+
17
+ }
18
+
19
  }
app/code/local/Recapture/Connector/Block/Client.php CHANGED
@@ -1,41 +1,45 @@
1
- <?php
2
-
3
- class Recapture_Connector_Block_Client extends Mage_Core_Block_Template {
4
-
5
- private $_cartId = null;
6
-
7
- public function shouldTrack(){
8
-
9
- if (!Mage::helper('recapture')->isEnabled()) return false;
10
- if (!Mage::helper('recapture')->canTrackEmail()) return false;
11
-
12
- $apiKey = $this->getApiKey();
13
- if (empty($apiKey)) return false;
14
-
15
- $cartId = $this->getCartId();
16
- if (empty($cartId)) return false;
17
-
18
- return true;
19
-
20
- }
21
-
22
- public function getApiKey(){
23
-
24
- return Mage::helper('recapture')->getApiKey();
25
-
26
- }
27
-
28
- public function getCartId(){
29
-
30
- if (empty($this->_cartId)){
31
-
32
- $cart = Mage::getModel('checkout/cart')->getQuote();
33
- $this->_cartId = $cart->getId();
34
-
35
- }
36
-
37
- return $this->_cartId;
38
-
39
- }
40
-
 
 
 
 
41
  }
1
+ <?php
2
+
3
+ class Recapture_Connector_Block_Client extends Mage_Core_Block_Template {
4
+
5
+ private $_cartId = null;
6
+
7
+ public function shouldTrack(){
8
+
9
+ if (!Mage::helper('recapture')->isEnabled()) return false;
10
+
11
+ $apiKey = $this->getApiKey();
12
+ if (empty($apiKey)) return false;
13
+
14
+ return true;
15
+
16
+ }
17
+
18
+ public function shouldTrackEmail(){
19
+
20
+ if (!$this->shouldTrack()) return false;
21
+ if (!Mage::helper('recapture')->canTrackEmail()) return false;
22
+
23
+ return true;
24
+
25
+ }
26
+
27
+ public function getApiKey(){
28
+
29
+ return Mage::helper('recapture')->getApiKey();
30
+
31
+ }
32
+
33
+ public function getQueueUrl(){
34
+
35
+ $queueUrl = Mage::getStoreConfig('recapture/configuration/dev_queue_url');
36
+ if (!$queueUrl) $queueUrl = '//cdn.recapture.io/sdk/v1/ra-queue.min.js';
37
+
38
+ //append a timestamp that changes every 10 minutes
39
+ $queueUrl .= '?v=' . round(time() / (60 * 10));
40
+
41
+ return $queueUrl;
42
+
43
+ }
44
+
45
  }
app/code/local/Recapture/Connector/Block/Client/Page.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+
3
+ class Recapture_Connector_Block_Client_Page extends Recapture_Connector_Block_Client {
4
+
5
+ }
app/code/local/Recapture/Connector/Block/Client/Product.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+
3
+ class Recapture_Connector_Block_Client_Product extends Recapture_Connector_Block_Client {
4
+
5
+ }
app/code/local/Recapture/Connector/Helper/Data.php CHANGED
@@ -1,219 +1,254 @@
1
- <?php
2
-
3
- class Recapture_Connector_Helper_Data extends Mage_Core_Helper_Abstract {
4
-
5
- private $_registry = array();
6
-
7
- public function isEnabled(){
8
-
9
- return Mage::getStoreConfig('recapture/configuration/enabled');
10
-
11
- }
12
-
13
- public function shouldCaptureSubscriber(){
14
-
15
- return Mage::getStoreConfig('recapture/abandoned_carts/capture_subscriber');
16
-
17
- }
18
-
19
- public function canTrackEmail(){
20
-
21
- return Mage::getStoreConfig('recapture/abandoned_carts/track_email');
22
-
23
- }
24
-
25
- public function getReturnLanding(){
26
-
27
- return Mage::getStoreConfig('recapture/abandoned_carts/return_landing');
28
-
29
- }
30
-
31
- public function getApiKey(){
32
-
33
- return Mage::getStoreConfig('recapture/configuration/api_key');
34
-
35
- }
36
-
37
- public function getScopeStoreId(){
38
-
39
- $website = Mage::app()->getRequest()->getParam('website');
40
- $website = !empty($website) ? $website : Mage::getSingleton('adminhtml/config_data')->getWebsite();
41
-
42
- $store = Mage::app()->getRequest()->getParam('store');
43
- $store = !empty($store) ? $store : Mage::getSingleton('adminhtml/config_data')->getStore();
44
-
45
- if (!$website && !$store) return '0';
46
-
47
- if ($store) return Mage::getModel('core/store')->load($store)->getId();
48
- if ($website) return Mage::getModel('core/website')->load($website)->getDefaultGroup()->getDefaultStoreId();
49
-
50
-
51
-
52
- }
53
-
54
- public function getCurrentScope(){
55
-
56
- $website = Mage::app()->getRequest()->getParam('website');
57
- $website = !empty($website) ? $website : Mage::getSingleton('adminhtml/config_data')->getWebsite();
58
-
59
- $store = Mage::app()->getRequest()->getParam('store');
60
- $store = !empty($store) ? $store : Mage::getSingleton('adminhtml/config_data')->getStore();
61
-
62
- if (!$website && !$store) return 'default';
63
-
64
- if ($store) return 'stores';
65
- if ($website) return 'websites';
66
-
67
- }
68
-
69
- public function getScopeForUrl(){
70
-
71
- $website = Mage::app()->getRequest()->getParam('website');
72
- $website = !empty($website) ? $website : Mage::getSingleton('adminhtml/config_data')->getWebsite();
73
-
74
- $store = Mage::app()->getRequest()->getParam('store');
75
- $store = !empty($store) ? $store : Mage::getSingleton('adminhtml/config_data')->getStore();
76
-
77
- if (!$website && !$store) return array();
78
-
79
- if ($store) return array('website' => $website, 'store' => $store);
80
- if ($website) return array('website' => $website);
81
-
82
- }
83
-
84
- public function getCurrentScopeId(){
85
-
86
- $website = Mage::app()->getRequest()->getParam('website');
87
- $website = !empty($website) ? $website : Mage::getSingleton('adminhtml/config_data')->getWebsite();
88
-
89
- $store = Mage::app()->getRequest()->getParam('store');
90
- $store = !empty($store) ? $store : Mage::getSingleton('adminhtml/config_data')->getStore();
91
-
92
- if (!$website && !$store) return 0;
93
-
94
- if ($store) return Mage::getModel('core/store')->load($store)->getId();
95
- if ($website) return Mage::getModel('core/website')->load($website)->getId();
96
-
97
- }
98
-
99
- public function translateCartHash($hash = ''){
100
-
101
- if (empty($hash)) return false;
102
-
103
- $result = Mage::helper('recapture/transport')->dispatch('cart/retrieve', array(
104
- 'hash' => $hash
105
- ));
106
-
107
- $body = @json_decode($result->getBody());
108
-
109
- if ($body->status == 'success'){
110
-
111
- return $body->data->cart_id;
112
-
113
- } else return false;
114
-
115
- }
116
-
117
- public function associateCartToMe($cartId = null){
118
-
119
- if (empty($cartId)) return false;
120
-
121
- $session = Mage::getSingleton('checkout/session');
122
-
123
- $session->clear();
124
- $session->setQuoteId($cartId);
125
-
126
- $quote = $session->getQuote();
127
-
128
- //if this cart somehow was already converted, we're not going to be able to load it. as such, we can't associate it.
129
- if ($quote->getId() != $cartId) return false;
130
-
131
- return true;
132
-
133
- }
134
-
135
- public function getCustomerFirstname(Mage_Sales_Model_Quote $quote){
136
-
137
- //we first check the quote model itself
138
- $customerFirstname = $quote->getCustomerFirstname();
139
- if (!empty($customerFirstname)) return $customerFirstname;
140
-
141
- //if not on the quote model, we check the billing address
142
- $billingAddress = $quote->getBillingAddress();
143
- if ($billingAddress){
144
-
145
- $customerFirstname = $billingAddress->getFirstname();
146
- if (!empty($customerFirstname)) return $customerFirstname;
147
-
148
- }
149
-
150
- //if not in the billing address, last resort we check the shipping address
151
- $shippingAddress = $quote->getShippingAddress();
152
- if ($shippingAddress){
153
-
154
- $customerFirstname = $shippingAddress->getFirstname();
155
- if (!empty($customerFirstname)) return $customerFirstname;
156
-
157
- }
158
-
159
- return null;
160
-
161
- }
162
-
163
- public function getCustomerLastname(Mage_Sales_Model_Quote $quote){
164
-
165
- //we first check the quote model itself
166
- $customerLastname = $quote->getCustomerLastname();
167
- if (!empty($customerLastname)) return $customerLastname;
168
-
169
- //if not on the quote model, we check the billing address
170
- $billingAddress = $quote->getBillingAddress();
171
- if ($billingAddress){
172
-
173
- $customerLastname = $billingAddress->getLastname();
174
- if (!empty($customerLastname)) return $customerLastname;
175
-
176
- }
177
-
178
- //if not in the billing address, last resort we check the shipping address
179
- $shippingAddress = $quote->getShippingAddress();
180
- if ($shippingAddress){
181
-
182
- $customerLastname = $shippingAddress->getLastname();
183
- if (!empty($customerLastname)) return $customerLastname;
184
-
185
- }
186
-
187
- return null;
188
-
189
- }
190
-
191
- public function getCustomerEmail(Mage_Sales_Model_Quote $quote){
192
-
193
- //we first check the quote model itself
194
- $customerEmail = $quote->getCustomerEmail();
195
- if (!empty($customerEmail)) return $customerEmail;
196
-
197
- //if not on the quote model, we check the billing address
198
- $billingAddress = $quote->getBillingAddress();
199
- if ($billingAddress){
200
-
201
- $customerEmail = $billingAddress->getEmail();
202
- if (!empty($customerEmail)) return $customerEmail;
203
-
204
- }
205
-
206
- //if not in the billing address, last resort we check the shipping address
207
- $shippingAddress = $quote->getShippingAddress();
208
- if ($shippingAddress){
209
-
210
- $customerEmail = $shippingAddress->getEmail();
211
- if (!empty($customerEmail)) return $customerEmail;
212
-
213
- }
214
-
215
- return null;
216
-
217
- }
218
-
219
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Recapture_Connector_Helper_Data extends Mage_Core_Helper_Abstract {
4
+
5
+ private $_registry = array();
6
+
7
+ public function isEnabled(){
8
+
9
+ return Mage::getStoreConfig('recapture/configuration/enabled');
10
+
11
+ }
12
+
13
+ public function shouldCaptureSubscriber(){
14
+
15
+ return Mage::getStoreConfig('recapture/abandoned_carts/capture_subscriber');
16
+
17
+ }
18
+
19
+ public function getHomeUrl($path){
20
+
21
+ $baseUrl = Mage::getStoreConfig('recapture/configuration/dev_base_url');
22
+ if (!$baseUrl) $baseUrl = 'http://www.recapture.io/';
23
+
24
+ return $baseUrl . $path;
25
+
26
+ }
27
+
28
+ public function canTrackEmail(){
29
+
30
+ return Mage::getStoreConfig('recapture/abandoned_carts/track_email');
31
+
32
+ }
33
+
34
+ public function getReturnLanding(){
35
+
36
+ return Mage::getStoreConfig('recapture/abandoned_carts/return_landing');
37
+
38
+ }
39
+
40
+ public function getApiKey(){
41
+
42
+ return Mage::getStoreConfig('recapture/configuration/api_key');
43
+
44
+ }
45
+
46
+ public function getScopeStoreId(){
47
+
48
+ $website = Mage::app()->getRequest()->getParam('website');
49
+ $website = !empty($website) ? $website : Mage::getSingleton('adminhtml/config_data')->getWebsite();
50
+
51
+ $store = Mage::app()->getRequest()->getParam('store');
52
+ $store = !empty($store) ? $store : Mage::getSingleton('adminhtml/config_data')->getStore();
53
+
54
+ if (!$website && !$store) return '0';
55
+
56
+ if ($store) return Mage::getModel('core/store')->load($store)->getId();
57
+ if ($website) return Mage::getModel('core/website')->load($website)->getDefaultGroup()->getDefaultStoreId();
58
+
59
+
60
+
61
+ }
62
+
63
+ public function getCurrentScope(){
64
+
65
+ $website = Mage::app()->getRequest()->getParam('website');
66
+ $website = !empty($website) ? $website : Mage::getSingleton('adminhtml/config_data')->getWebsite();
67
+
68
+ $store = Mage::app()->getRequest()->getParam('store');
69
+ $store = !empty($store) ? $store : Mage::getSingleton('adminhtml/config_data')->getStore();
70
+
71
+ if (!$website && !$store) return 'default';
72
+
73
+ if ($store) return 'stores';
74
+ if ($website) return 'websites';
75
+
76
+ }
77
+
78
+ public function getScopeForUrl(){
79
+
80
+ $website = Mage::app()->getRequest()->getParam('website');
81
+ $website = !empty($website) ? $website : Mage::getSingleton('adminhtml/config_data')->getWebsite();
82
+
83
+ $store = Mage::app()->getRequest()->getParam('store');
84
+ $store = !empty($store) ? $store : Mage::getSingleton('adminhtml/config_data')->getStore();
85
+
86
+ if (!$website && !$store) return array();
87
+
88
+ if ($store) return array('website' => $website, 'store' => $store);
89
+ if ($website) return array('website' => $website);
90
+
91
+ }
92
+
93
+ public function getCurrentScopeId(){
94
+
95
+ $website = Mage::app()->getRequest()->getParam('website');
96
+ $website = !empty($website) ? $website : Mage::getSingleton('adminhtml/config_data')->getWebsite();
97
+
98
+ $store = Mage::app()->getRequest()->getParam('store');
99
+ $store = !empty($store) ? $store : Mage::getSingleton('adminhtml/config_data')->getStore();
100
+
101
+ if (!$website && !$store) return 0;
102
+
103
+ if ($store) return Mage::getModel('core/store')->load($store)->getId();
104
+ if ($website) return Mage::getModel('core/website')->load($website)->getId();
105
+
106
+ }
107
+
108
+ public function translateCartHash($hash = ''){
109
+
110
+ if (empty($hash)) return false;
111
+
112
+ $result = Mage::helper('recapture/transport')->dispatch('cart/retrieve', array(
113
+ 'hash' => $hash
114
+ ));
115
+
116
+ $body = @json_decode($result->getBody());
117
+
118
+ if ($body->status == 'success'){
119
+
120
+ return $body->data->cart_id;
121
+
122
+ } else return false;
123
+
124
+ }
125
+
126
+ public function associateCartToMe($cartId = null){
127
+
128
+ if (empty($cartId)) return false;
129
+
130
+ $session = Mage::getSingleton('checkout/session');
131
+
132
+ $session->clear();
133
+ $session->setQuoteId($cartId);
134
+
135
+ $quote = $session->getQuote();
136
+
137
+ //if this cart somehow was already converted, we're not going to be able to load it. as such, we can't associate it.
138
+ if ($quote->getId() != $cartId) return false;
139
+
140
+ return true;
141
+
142
+ }
143
+
144
+ public function getCustomerFirstname(Mage_Sales_Model_Quote $quote){
145
+
146
+ //we first check the quote model itself
147
+ $customerFirstname = $quote->getCustomerFirstname();
148
+ if (!empty($customerFirstname)) return $customerFirstname;
149
+
150
+ //if not on the quote model, we check the billing address
151
+ $billingAddress = $quote->getBillingAddress();
152
+ if ($billingAddress){
153
+
154
+ $customerFirstname = $billingAddress->getFirstname();
155
+ if (!empty($customerFirstname)) return $customerFirstname;
156
+
157
+ }
158
+
159
+ //if not in the billing address, last resort we check the shipping address
160
+ $shippingAddress = $quote->getShippingAddress();
161
+ if ($shippingAddress){
162
+
163
+ $customerFirstname = $shippingAddress->getFirstname();
164
+ if (!empty($customerFirstname)) return $customerFirstname;
165
+
166
+ }
167
+
168
+ return null;
169
+
170
+ }
171
+
172
+ public function getCustomerLastname(Mage_Sales_Model_Quote $quote){
173
+
174
+ //we first check the quote model itself
175
+ $customerLastname = $quote->getCustomerLastname();
176
+ if (!empty($customerLastname)) return $customerLastname;
177
+
178
+ //if not on the quote model, we check the billing address
179
+ $billingAddress = $quote->getBillingAddress();
180
+ if ($billingAddress){
181
+
182
+ $customerLastname = $billingAddress->getLastname();
183
+ if (!empty($customerLastname)) return $customerLastname;
184
+
185
+ }
186
+
187
+ //if not in the billing address, last resort we check the shipping address
188
+ $shippingAddress = $quote->getShippingAddress();
189
+ if ($shippingAddress){
190
+
191
+ $customerLastname = $shippingAddress->getLastname();
192
+ if (!empty($customerLastname)) return $customerLastname;
193
+
194
+ }
195
+
196
+ return null;
197
+
198
+ }
199
+
200
+ public function getCustomerEmail(Mage_Sales_Model_Quote $quote){
201
+
202
+ //we first check the quote model itself
203
+ $customerEmail = $quote->getCustomerEmail();
204
+ if (!empty($customerEmail)) return $customerEmail;
205
+
206
+ //if not on the quote model, we check the billing address
207
+ $billingAddress = $quote->getBillingAddress();
208
+ if ($billingAddress){
209
+
210
+ $customerEmail = $billingAddress->getEmail();
211
+ if (!empty($customerEmail)) return $customerEmail;
212
+
213
+ }
214
+
215
+ //if not in the billing address, last resort we check the shipping address
216
+ $shippingAddress = $quote->getShippingAddress();
217
+ if ($shippingAddress){
218
+
219
+ $customerEmail = $shippingAddress->getEmail();
220
+ if (!empty($customerEmail)) return $customerEmail;
221
+
222
+ }
223
+
224
+ return null;
225
+
226
+ }
227
+
228
+
229
+ public function getCustomerHash(){
230
+
231
+ return isset($_COOKIE['ra_customer_id']) ? $_COOKIE['ra_customer_id'] : null;
232
+
233
+ }
234
+
235
+
236
+ public function translateEmailHashes($hashes = array()){
237
+
238
+ if (empty($hashes)) return false;
239
+
240
+ $result = Mage::helper('recapture/transport')->dispatch('email/retrieve', array(
241
+ 'hashes' => $hashes
242
+ ));
243
+
244
+ $body = @json_decode($result->getBody());
245
+
246
+ if ($body->status == 'success'){
247
+
248
+ return $body->data->emails;
249
+
250
+ } else return false;
251
+
252
+ }
253
+
254
+ }
app/code/local/Recapture/Connector/Helper/Transport.php CHANGED
@@ -1,27 +1,27 @@
1
- <?php
2
-
3
- class Recapture_Connector_Helper_Transport extends Mage_Core_Helper_Abstract {
4
-
5
- public function dispatch($route = '', $data = array()){
6
-
7
- if (!Mage::helper('recapture')->isEnabled()) return false;
8
- if (empty($route)) return false;
9
-
10
- $adapter = new Zend_Http_Client_Adapter_Curl();
11
- $client = new Zend_Http_Client('http://www.recapture.io/beacon/' . $route, array(
12
- 'timeout' => 1
13
- ));
14
-
15
- //this is the users publicly accessible session ID
16
- $data['session'] = Mage::getSingleton('core/session')->getEncryptedSessionId();
17
-
18
- $client->setParameterPost($data);
19
- $client->setAdapter($adapter);
20
- $client->setHeaders('Api-Key', Mage::helper('recapture')->getApiKey());
21
- $response = $client->request('POST');
22
-
23
- return $response;
24
-
25
- }
26
-
27
- }
1
+ <?php
2
+
3
+ class Recapture_Connector_Helper_Transport extends Mage_Core_Helper_Abstract {
4
+
5
+ public function dispatch($route = '', $data = array()){
6
+
7
+ if (!Mage::helper('recapture')->isEnabled()) return false;
8
+ if (empty($route)) return false;
9
+
10
+ $adapter = new Zend_Http_Client_Adapter_Curl();
11
+ $client = new Zend_Http_Client(Mage::helper('recapture')->getHomeUrl('beacon/' . $route), array(
12
+ 'timeout' => 1
13
+ ));
14
+
15
+ //this is the users publicly accessible session ID
16
+ $data['customer'] = Mage::helper('recapture')->getCustomerHash();
17
+
18
+ $client->setParameterPost($data);
19
+ $client->setAdapter($adapter);
20
+ $client->setHeaders('Api-Key', Mage::helper('recapture')->getApiKey());
21
+ $response = $client->request('POST');
22
+
23
+ return $response;
24
+
25
+ }
26
+
27
+ }
app/code/local/Recapture/Connector/Model/Landing.php CHANGED
@@ -1,18 +1,18 @@
1
- <?php
2
-
3
- class Recapture_Connector_Model_Landing {
4
-
5
- const REDIRECT_HOME = 'home';
6
- const REDIRECT_CART = 'cart';
7
- const REDIRECT_CHECKOUT = 'checkout';
8
-
9
- public function toOptionArray(){
10
-
11
- return array(
12
- array('value' => self::REDIRECT_HOME, 'label' => Mage::helper('recapture')->__('Home Page')),
13
- array('value' => self::REDIRECT_CART, 'label' => Mage::helper('recapture')->__('Cart Page')),
14
- array('value' => self::REDIRECT_CHECKOUT, 'label' => Mage::helper('recapture')->__('Checkout Page')),
15
- );
16
- }
17
-
18
  }
1
+ <?php
2
+
3
+ class Recapture_Connector_Model_Landing {
4
+
5
+ const REDIRECT_HOME = 'home';
6
+ const REDIRECT_CART = 'cart';
7
+ const REDIRECT_CHECKOUT = 'checkout';
8
+
9
+ public function toOptionArray(){
10
+
11
+ return array(
12
+ array('value' => self::REDIRECT_HOME, 'label' => Mage::helper('recapture')->__('Home Page')),
13
+ array('value' => self::REDIRECT_CART, 'label' => Mage::helper('recapture')->__('Cart Page')),
14
+ array('value' => self::REDIRECT_CHECKOUT, 'label' => Mage::helper('recapture')->__('Checkout Page')),
15
+ );
16
+ }
17
+
18
  }
app/code/local/Recapture/Connector/Model/Observer.php CHANGED
@@ -1,234 +1,226 @@
1
- <?php
2
-
3
- class Recapture_Connector_Model_Observer {
4
-
5
- public function itemUpdate($observer){
6
-
7
- if (!Mage::helper('recapture')->isEnabled()) return $this;
8
-
9
- try {
10
-
11
- $this->_updateQuote($observer->getEvent()->getQuoteItem()->getQuote());
12
-
13
- } catch (Exception $e){
14
-
15
- Mage::log($e->getMessage());
16
-
17
- }
18
-
19
- return $this;
20
-
21
- }
22
-
23
- public function quoteUpdate($observer){
24
-
25
- if (!Mage::helper('recapture')->isEnabled()) return $this;
26
-
27
- try {
28
-
29
- $this->_updateQuote($observer->getEvent()->getQuote());
30
-
31
- } catch (Exception $e){
32
-
33
- Mage::log($e->getMessage());
34
-
35
- }
36
-
37
- return $this;
38
-
39
- }
40
-
41
- protected function _updateQuote(Mage_Sales_Model_Quote $quote){
42
-
43
- if (!$quote->getId()) return;
44
-
45
- //sales_quote_save_before gets called like 5 times on some page loads, we don't want to do 5 updates per page load
46
- if (Mage::registry('recapture_has_posted')) return;
47
-
48
- Mage::register('recapture_has_posted', true, true);
49
-
50
- $mediaConfig = Mage::getModel('catalog/product_media_config');
51
- $storeId = Mage::app()->getStore();
52
-
53
- $totalWithTax = Mage::getStoreConfig('recapture/abandoned_carts/include_tax_with_products');
54
-
55
- $transportData = array(
56
- 'first_name' => Mage::helper('recapture')->getCustomerFirstname($quote),
57
- 'last_name' => Mage::helper('recapture')->getCustomerLastname($quote),
58
- 'email' => Mage::helper('recapture')->getCustomerEmail($quote),
59
- 'external_id' => $quote->getId(),
60
- 'grand_total' => $quote->getGrandTotal(),
61
- 'products' => array(),
62
- 'totals' => array()
63
- );
64
-
65
- $cartItems = $quote->getAllVisibleItems();
66
-
67
- foreach ($cartItems as $item){
68
-
69
- $productModel = $item->getProduct();
70
-
71
- $productImage = false;
72
-
73
- $image = Mage::getResourceModel('catalog/product')->getAttributeRawValue($productModel->getId(), 'thumbnail', $storeId);
74
- if ($image && $image != 'no_selection') $productImage = $mediaConfig->getMediaUrl($image);
75
-
76
- //check configurable first
77
- if ($item->getProductType() == 'configurable'){
78
-
79
- if (Mage::getStoreConfig('checkout/cart/configurable_product_image') == 'itself'){
80
-
81
- $child = $productModel->getIdBySku($item->getSku());
82
-
83
- $image = Mage::getResourceModel('catalog/product')->getAttributeRawValue($child, 'thumbnail', $storeId);
84
- if ($image && $image != 'no_selection') $productImage = $mediaConfig->getMediaUrl($image);
85
-
86
- }
87
- }
88
-
89
- //then check grouped
90
- if (Mage::getStoreConfig('checkout/cart/grouped_product_image') == 'parent'){
91
-
92
- $options = $productModel->getTypeInstance(true)->getOrderOptions($productModel);
93
-
94
- if (isset($options['super_product_config']) && $options['super_product_config']['product_type'] == 'grouped'){
95
-
96
- $parent = $options['super_product_config']['product_id'];
97
- $image = Mage::getResourceModel('catalog/product')->getAttributeRawValue($parent, 'thumbnail', $storeId);
98
-
99
- if ($image && $image != 'no_selection') $productImage = $mediaConfig->getMediaUrl($image);
100
-
101
- }
102
- }
103
-
104
- //if after all that, we still don't have a product image, we get the placeholder image
105
- if (!$productImage) {
106
-
107
- $productImage = $mediaConfig->getMediaUrl('placeholder/' . Mage::getStoreConfig("catalog/placeholder/image_placeholder"));
108
-
109
- }
110
-
111
- $optionsHelper = Mage::helper('catalog/product_configuration');
112
-
113
- if ($item->getProductType() == 'configurable'){
114
-
115
- $visibleOptions = $optionsHelper->getConfigurableOptions($item);
116
-
117
- } else {
118
-
119
- $visibleOptions = $optionsHelper->getCustomOptions($item);
120
-
121
- }
122
-
123
- $product = array(
124
- 'name' => $item->getName(),
125
- 'sku' => $item->getSku(),
126
- 'price' => $totalWithTax ? $item->getPriceInclTax() : $item->getPrice(),
127
- 'qty' => $item->getQty(),
128
- 'image' => $productImage,
129
- 'options' => $visibleOptions
130
- );
131
-
132
- $transportData['products'][] = $product;
133
-
134
- }
135
-
136
- $totals = $quote->getTotals();
137
-
138
- foreach ($totals as $total){
139
-
140
- //we pass grand total on the top level
141
- if ($total->getCode() == 'grand_total') continue;
142
-
143
- $total = array(
144
- 'name' => $total->getTitle(),
145
- 'amount' => $total->getValue()
146
- );
147
-
148
- $transportData['totals'][] = $total;
149
-
150
- }
151
-
152
- Mage::helper('recapture/transport')->dispatch('cart', $transportData);
153
-
154
- return $this;
155
-
156
- }
157
-
158
- public function quoteDelete($observer){
159
-
160
- if (!Mage::helper('recapture')->isEnabled()) return $this;
161
-
162
- try {
163
-
164
- $quote = $observer->getEvent()->getQuote();
165
-
166
- $transportData = array(
167
- 'external_id' => $quote->getId()
168
- );
169
-
170
- Mage::helper('recapture/transport')->dispatch('cart/remove', $transportData);
171
-
172
- } catch (Exception $e){
173
-
174
- Mage::log($e->getMessage());
175
-
176
- }
177
-
178
- return $this;
179
-
180
- }
181
-
182
- public function cartConversion($observer){
183
-
184
- if (!Mage::helper('recapture')->isEnabled()) return $this;
185
-
186
- try {
187
-
188
- $order = $observer->getEvent()->getOrder();
189
-
190
- $transportData = array(
191
- 'external_id' => $order->getQuoteId()
192
- );
193
-
194
- Mage::helper('recapture/transport')->dispatch('conversion', $transportData);
195
-
196
- } catch (Exception $e){
197
-
198
- Mage::log($e->getMessage());
199
-
200
- }
201
-
202
- return $this;
203
-
204
- }
205
-
206
- public function newsletterSubscriber($observer){
207
-
208
- if (!Mage::helper('recapture')->isEnabled()) return $this;
209
- if (!Mage::helper('recapture')->shouldCaptureSubscriber()) return $this;
210
-
211
- try {
212
-
213
- $subscriber = $observer->getEvent()->getSubscriber();
214
- $email = $subscriber->getSubscriberEmail();
215
-
216
- $quote = Mage::getSingleton('checkout/session')->getQuote();
217
- $quote->setCustomerEmail($email);
218
- $quote->save();
219
-
220
- //we do this in case the customer didn't have a cart to begin with
221
- Mage::helper('recapture')->associateCartToMe($quote->getId());
222
-
223
- } catch (Exception $e){
224
-
225
- Mage::log($e->getMessage());
226
-
227
- }
228
-
229
- return $this;
230
-
231
-
232
- }
233
-
234
  }
1
+ <?php
2
+
3
+ class Recapture_Connector_Model_Observer {
4
+
5
+ public function quoteUpdate($observer){
6
+
7
+ if (!Mage::helper('recapture')->isEnabled()) return $this;
8
+
9
+ try {
10
+
11
+ return $this->_updateQuote($observer->getEvent()->getQuote());
12
+
13
+ } catch (Exception $e){
14
+
15
+ Mage::log($e->getMessage());
16
+
17
+ }
18
+
19
+ return $this;
20
+
21
+ }
22
+
23
+ protected function _updateQuote(Mage_Sales_Model_Quote $quote){
24
+
25
+ if (!Mage::helper('recapture')->isEnabled()) return $this;
26
+
27
+ if (!$quote->getId()) return;
28
+
29
+ //sales_quote_save_before gets called like 5 times on some page loads, we don't want to do 5 updates per page load
30
+ if (Mage::registry('recapture_has_posted')) return;
31
+
32
+ Mage::register('recapture_has_posted', true);
33
+
34
+ $mediaConfig = Mage::getModel('catalog/product_media_config');
35
+ $storeId = Mage::app()->getStore();
36
+
37
+ $totalWithTax = Mage::getStoreConfig('recapture/abandoned_carts/include_tax_with_products');
38
+
39
+ $transportData = array(
40
+ 'first_name' => Mage::helper('recapture')->getCustomerFirstname($quote),
41
+ 'last_name' => Mage::helper('recapture')->getCustomerLastname($quote),
42
+ 'email' => Mage::helper('recapture')->getCustomerEmail($quote),
43
+ 'external_id' => $quote->getId(),
44
+ 'grand_total' => $quote->getBaseGrandTotal(),
45
+ 'grand_total_display' => Mage::helper('core')->currency($quote->getGrandTotal(), true, false),
46
+ 'products' => array(),
47
+ 'totals' => array()
48
+ );
49
+
50
+ $cartItems = $quote->getAllVisibleItems();
51
+
52
+ foreach ($cartItems as $item){
53
+
54
+ $productModel = $item->getProduct();
55
+
56
+ $productImage = false;
57
+
58
+ $image = Mage::getResourceModel('catalog/product')->getAttributeRawValue($productModel->getId(), 'thumbnail', $storeId);
59
+ if ($image && $image != 'no_selection') $productImage = $mediaConfig->getMediaUrl($image);
60
+
61
+ //check configurable first
62
+ if ($item->getProductType() == 'configurable'){
63
+
64
+ if (Mage::getStoreConfig('checkout/cart/configurable_product_image') == 'itself'){
65
+
66
+ $child = $productModel->getIdBySku($item->getSku());
67
+
68
+ $image = Mage::getResourceModel('catalog/product')->getAttributeRawValue($child, 'thumbnail', $storeId);
69
+ if ($image && $image != 'no_selection') $productImage = $mediaConfig->getMediaUrl($image);
70
+
71
+ }
72
+ }
73
+
74
+ //then check grouped
75
+ if (Mage::getStoreConfig('checkout/cart/grouped_product_image') == 'parent'){
76
+
77
+ $options = $productModel->getTypeInstance(true)->getOrderOptions($productModel);
78
+
79
+ if (isset($options['super_product_config']) && $options['super_product_config']['product_type'] == 'grouped'){
80
+
81
+ $parent = $options['super_product_config']['product_id'];
82
+ $image = Mage::getResourceModel('catalog/product')->getAttributeRawValue($parent, 'thumbnail', $storeId);
83
+
84
+ if ($image && $image != 'no_selection') $productImage = $mediaConfig->getMediaUrl($image);
85
+
86
+ }
87
+ }
88
+
89
+ //if after all that, we still don't have a product image, we get the placeholder image
90
+ if (!$productImage) {
91
+
92
+ $productImage = $mediaConfig->getMediaUrl('placeholder/' . Mage::getStoreConfig("catalog/placeholder/image_placeholder"));
93
+
94
+ }
95
+
96
+ $optionsHelper = Mage::helper('catalog/product_configuration');
97
+
98
+ if ($item->getProductType() == 'configurable'){
99
+
100
+ $visibleOptions = $optionsHelper->getConfigurableOptions($item);
101
+
102
+ } else {
103
+
104
+ $visibleOptions = $optionsHelper->getCustomOptions($item);
105
+
106
+ }
107
+
108
+ $product = array(
109
+ 'name' => $item->getName(),
110
+ 'sku' => $item->getSku(),
111
+ 'price' => $totalWithTax ? $item->getBasePriceInclTax() : $item->getBasePrice(),
112
+ 'price_display' => Mage::helper('core')->currency($totalWithTax ? $item->getPriceInclTax() : $item->getPrice(), true, false),
113
+ 'qty' => $item->getQty(),
114
+ 'image' => $productImage,
115
+ 'options' => $visibleOptions
116
+ );
117
+
118
+ $transportData['products'][] = $product;
119
+
120
+ }
121
+
122
+ $totals = $quote->getTotals();
123
+
124
+ foreach ($totals as $total){
125
+
126
+ //we pass grand total on the top level
127
+ if ($total->getCode() == 'grand_total') continue;
128
+
129
+ $total = array(
130
+ 'name' => $total->getTitle(),
131
+ 'amount' => $total->getValue()
132
+ );
133
+
134
+ $transportData['totals'][] = $total;
135
+
136
+ }
137
+
138
+ Mage::helper('recapture/transport')->dispatch('cart', $transportData);
139
+
140
+ return $this;
141
+
142
+ }
143
+
144
+ public function quoteDelete($observer){
145
+
146
+ if (!Mage::helper('recapture')->isEnabled()) return $this;
147
+
148
+ try {
149
+
150
+ $quote = $observer->getEvent()->getQuote();
151
+
152
+ $transportData = array(
153
+ 'external_id' => $quote->getId()
154
+ );
155
+
156
+ Mage::helper('recapture/transport')->dispatch('cart/remove', $transportData);
157
+
158
+ } catch (Exception $e){
159
+
160
+ Mage::log($e->getMessage());
161
+
162
+ }
163
+
164
+ return $this;
165
+
166
+ }
167
+
168
+ public function cartConversion($observer){
169
+
170
+ if (!Mage::helper('recapture')->isEnabled()) return $this;
171
+
172
+ try {
173
+
174
+ $order = $observer->getEvent()->getOrder();
175
+
176
+ $transportData = array(
177
+ 'external_id' => $order->getQuoteId()
178
+ );
179
+
180
+ Mage::helper('recapture/transport')->dispatch('conversion', $transportData);
181
+
182
+ } catch (Exception $e){
183
+
184
+ Mage::log($e->getMessage());
185
+
186
+ }
187
+
188
+ return $this;
189
+
190
+ }
191
+
192
+ public function newsletterSubscriber($observer){
193
+
194
+ if (!Mage::helper('recapture')->isEnabled()) return $this;
195
+ if (!Mage::helper('recapture')->shouldCaptureSubscriber()) return $this;
196
+
197
+ //if we can't identify this customer, we return out
198
+ if (!Mage::helper('recapture')->getCustomerHash()) return $this;
199
+
200
+ try {
201
+
202
+ $subscriber = $observer->getEvent()->getSubscriber();
203
+
204
+ $email = $subscriber->getSubscriberEmail();
205
+
206
+ if (Zend_Validate::is($email, 'EmailAddress')){
207
+
208
+ $transportData = array(
209
+ 'email' => $email
210
+ );
211
+
212
+ Mage::helper('recapture/transport')->dispatch('email/subscribe', $transportData);
213
+
214
+ }
215
+
216
+ } catch (Exception $e){
217
+
218
+ Mage::log($e->getMessage());
219
+
220
+ }
221
+
222
+ return $this;
223
+
224
+ }
225
+
 
 
 
 
 
 
 
 
226
  }
app/code/local/Recapture/Connector/controllers/CartController.php CHANGED
@@ -1,75 +1,75 @@
1
- <?php
2
-
3
- class Recapture_Connector_CartController extends Mage_Core_Controller_Front_Action {
4
-
5
- public function indexAction(){
6
-
7
- $helper = Mage::helper('recapture');
8
- if (!$helper->isEnabled() || !$helper->getApiKey()) return $this->_redirect('/');
9
-
10
- $hash = $this->getRequest()->getParam('hash');
11
-
12
- try {
13
-
14
- $cartId = $helper->translateCartHash($hash);
15
-
16
- } catch (Exception $e){
17
-
18
- Mage::log($e, null, 'recapture.log');
19
-
20
- }
21
-
22
- if (!$cartId){
23
-
24
- Mage::getSingleton('core/session')->addError('There was an error retrieving your cart.');
25
- return $this->_redirect('/');
26
-
27
- }
28
-
29
- try {
30
-
31
- $result = $helper->associateCartToMe($cartId);
32
-
33
- } catch (Exception $e){
34
-
35
- Mage::log($e, null, 'recapture.log');
36
-
37
- }
38
-
39
- if (!$result){
40
-
41
- Mage::getSingleton('core/session')->addError('There was an error retrieving your cart.');
42
- return $this->_redirect('/');
43
-
44
- } else {
45
-
46
- $cart = Mage::getModel('checkout/cart')->getQuote();
47
-
48
- $redirectSection = $helper->getReturnLanding();
49
-
50
- switch ($redirectSection){
51
-
52
- case Recapture_Connector_Model_Landing::REDIRECT_HOME:
53
-
54
- return $this->_redirect('/');
55
-
56
- case Recapture_Connector_Model_Landing::REDIRECT_CHECKOUT:
57
-
58
- return $this->getResponse()->setRedirect(Mage::helper('checkout/url')->getCheckoutUrl());
59
-
60
- case Recapture_Connector_Model_Landing::REDIRECT_CART:
61
- default:
62
-
63
- return $this->_redirect('checkout/cart');
64
-
65
- }
66
-
67
- return $this->_redirect('/');
68
-
69
-
70
-
71
- }
72
-
73
- }
74
-
75
- }
1
+ <?php
2
+
3
+ class Recapture_Connector_CartController extends Mage_Core_Controller_Front_Action {
4
+
5
+ public function indexAction(){
6
+
7
+ $helper = Mage::helper('recapture');
8
+ if (!$helper->isEnabled() || !$helper->getApiKey()) return $this->_redirect('/');
9
+
10
+ $hash = $this->getRequest()->getParam('hash');
11
+
12
+ try {
13
+
14
+ $cartId = $helper->translateCartHash($hash);
15
+
16
+ } catch (Exception $e){
17
+
18
+ Mage::log($e->getMessage());
19
+
20
+ }
21
+
22
+ if (!$cartId){
23
+
24
+ Mage::getSingleton('core/session')->addError('There was an error retrieving your cart.');
25
+ return $this->_redirect('/');
26
+
27
+ }
28
+
29
+ try {
30
+
31
+ $result = $helper->associateCartToMe($cartId);
32
+
33
+ } catch (Exception $e){
34
+
35
+ Mage::log($e->getMessage());
36
+
37
+ }
38
+
39
+ if (!$result){
40
+
41
+ Mage::getSingleton('core/session')->addError('There was an error retrieving your cart.');
42
+ return $this->_redirect('/');
43
+
44
+ } else {
45
+
46
+ $cart = Mage::getModel('checkout/cart')->getQuote();
47
+
48
+ $redirectSection = $helper->getReturnLanding();
49
+
50
+ switch ($redirectSection){
51
+
52
+ case Recapture_Connector_Model_Landing::REDIRECT_HOME:
53
+
54
+ return $this->_redirect('/');
55
+
56
+ case Recapture_Connector_Model_Landing::REDIRECT_CHECKOUT:
57
+
58
+ return $this->getResponse()->setRedirect(Mage::helper('checkout/url')->getCheckoutUrl());
59
+
60
+ case Recapture_Connector_Model_Landing::REDIRECT_CART:
61
+ default:
62
+
63
+ return $this->_redirect('checkout/cart');
64
+
65
+ }
66
+
67
+ return $this->_redirect('/');
68
+
69
+
70
+
71
+ }
72
+
73
+ }
74
+
75
+ }
app/code/local/Recapture/Connector/controllers/EmailController.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Recapture_Connector_EmailController extends Mage_Core_Controller_Front_Action {
4
+
5
+ public function subscribeAction(){
6
+
7
+ $emailHashes = $this->getRequest()->getParam('hashes');
8
+
9
+ $emails = Mage::helper('recapture')->translateEmailHashes($emailHashes);
10
+
11
+ foreach ($emails as $emailAddress){
12
+
13
+ Mage::getModel('newsletter/subscriber')->setImportMode(true)->subscribe($emailAddress);
14
+
15
+ $subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($emailAddress);
16
+ $subscriber->setStatus(Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED);
17
+ $subscriber->save();
18
+
19
+ }
20
+
21
+ $response = array('status' => 'success');
22
+
23
+ $this->getResponse()->clearHeaders()->setHeader('Content-type','application/json',true);
24
+ $this->getResponse()->setBody(json_encode($response));
25
+
26
+ }
27
+ }
app/code/local/Recapture/Connector/controllers/IndexController.php CHANGED
@@ -1,15 +1,15 @@
1
- <?php
2
-
3
- class Recapture_Connector_IndexController extends Mage_Core_Controller_Front_Action {
4
-
5
- public function versionAction(){
6
-
7
- $version = (string)Mage::getConfig()->getModuleConfig("Recapture_Connector")->version;
8
- $response = array('version' => $version);
9
-
10
- $this->getResponse()->clearHeaders()->setHeader('Content-type','application/json',true);
11
- $this->getResponse()->setBody(json_encode($response));
12
-
13
- }
14
-
15
  }
1
+ <?php
2
+
3
+ class Recapture_Connector_IndexController extends Mage_Core_Controller_Front_Action {
4
+
5
+ public function versionAction(){
6
+
7
+ $version = (string)Mage::getConfig()->getModuleConfig("Recapture_Connector")->version;
8
+ $response = array('version' => $version);
9
+
10
+ $this->getResponse()->clearHeaders()->setHeader('Content-type','application/json',true);
11
+ $this->getResponse()->setBody(json_encode($response));
12
+
13
+ }
14
+
15
  }
app/code/local/Recapture/Connector/controllers/RecaptureController.php DELETED
@@ -1,5 +0,0 @@
1
- <?php
2
-
3
- class Recapture_Connector_RecaptureController extends Mage_Core_Controller_Front_Action {
4
-
5
- }
 
 
 
 
 
app/code/local/Recapture/Connector/controllers/Recaptureadmin/AuthenticateController.php CHANGED
@@ -1,78 +1,79 @@
1
- <?php
2
-
3
- class Recapture_Connector_Recaptureadmin_AuthenticateController extends Mage_Adminhtml_Controller_Action {
4
-
5
- public function indexAction(){
6
-
7
- if (Mage::helper('recapture')->getCurrentScope() == 'default'){
8
-
9
- Mage::getSingleton('adminhtml/session')->addError('You cannot authenticate the Default Config scope. Please change the Current Configuration Scope on the left to a specific website before authenticating.');
10
-
11
- return $this->_redirect('adminhtml/system_config/edit', array('section' => 'recapture'));
12
-
13
- }
14
-
15
- $scope = Mage::helper('recapture')->getScopeForUrl();
16
-
17
- $returnCancel = Mage::helper('adminhtml')->getUrl('adminhtml/recaptureadmin_authenticate/cancel', $scope);
18
-
19
- $scope['response_key'] = 'API_KEY';
20
-
21
- $returnConfirm = Mage::helper('adminhtml')->getUrl('adminhtml/recaptureadmin_authenticate/return', $scope);
22
- $recaptureUrl = Mage::getUrl('recapture/cart/index', array('hash' => 'CART_HASH', '_store' => Mage::helper('recapture')->getScopeStoreId()));
23
-
24
- $query = http_build_query(array(
25
- 'return' => $returnConfirm,
26
- 'return_cancel' => $returnCancel,
27
- 'recapture' => $recaptureUrl
28
- ));
29
-
30
- $authenticateUrl = 'https://recapture.io/account/auth?' . $query;
31
- return $this->_redirectUrl($authenticateUrl);
32
-
33
- }
34
-
35
- public function returnAction(){
36
-
37
- $apiKey = $this->getRequest()->getParam('response_key');
38
-
39
- $helper = Mage::helper('recapture');
40
- $scope = $helper->getCurrentScope();
41
- $scopeId = $helper->getCurrentScopeId();
42
-
43
- if ($apiKey){
44
-
45
- $config = new Mage_Core_Model_Config();
46
- $config->saveConfig('recapture/configuration/authenticated', true, $scope, $scopeId);
47
- $config->saveConfig('recapture/configuration/api_key', $apiKey, $scope, $scopeId);
48
- $config->saveConfig('recapture/configuration/enabled', true, $scope, $scopeId);
49
-
50
- Mage::app()->getCacheInstance()->cleanType('config');
51
-
52
- Mage::getSingleton('adminhtml/session')->addSuccess('Your account has been authenticated successfully!');
53
-
54
- } else {
55
-
56
- Mage::getSingleton('adminhtml/session')->addError('Unable to authenticate your account. Please ensure you are logged in to your Recapture account.');
57
-
58
- }
59
-
60
- $scope = Mage::helper('recapture')->getScopeForUrl();
61
- $scope['section'] = 'recapture';
62
-
63
- return $this->_redirect('adminhtml/system_config/edit', $scope);
64
-
65
- }
66
-
67
- public function cancelAction(){
68
-
69
- Mage::getSingleton('adminhtml/session')->addError('Authentication has been cancelled.');
70
-
71
- $scope = Mage::helper('recapture')->getScopeForUrl();
72
- $scope['section'] = 'recapture';
73
-
74
- return $this->_redirect('adminhtml/system_config/edit', $scope);
75
-
76
- }
77
-
78
- }
 
1
+ <?php
2
+
3
+ class Recapture_Connector_Recaptureadmin_AuthenticateController extends Mage_Adminhtml_Controller_Action {
4
+
5
+ public function indexAction(){
6
+
7
+ if (Mage::helper('recapture')->getCurrentScope() == 'default'){
8
+
9
+ Mage::getSingleton('adminhtml/session')->addError('You cannot authenticate the Default Config scope. Please change the Current Configuration Scope on the left to a specific website before authenticating.');
10
+
11
+ return $this->_redirect('adminhtml/system_config/edit', array('section' => 'recapture'));
12
+
13
+ }
14
+
15
+ $scope = Mage::helper('recapture')->getScopeForUrl();
16
+
17
+ $returnCancel = Mage::helper('adminhtml')->getUrl('adminhtml/recaptureadmin_authenticate/cancel', $scope);
18
+
19
+ $scope['response_key'] = 'API_KEY';
20
+
21
+ $returnConfirm = Mage::helper('adminhtml')->getUrl('adminhtml/recaptureadmin_authenticate/return', $scope);
22
+ $baseUrl = Mage::getUrl('recapture', array('_store' => Mage::helper('recapture')->getScopeStoreId()));
23
+
24
+ $query = http_build_query(array(
25
+ 'return' => $returnConfirm,
26
+ 'return_cancel' => $returnCancel,
27
+ 'base' => $baseUrl,
28
+ 'currency' => Mage::app()->getStore()->getBaseCurrencyCode()
29
+ ));
30
+
31
+ $authenticateUrl = Mage::helper('recapture')->getHomeUrl('account/auth?' . $query);
32
+ return $this->_redirectUrl($authenticateUrl);
33
+
34
+ }
35
+
36
+ public function returnAction(){
37
+
38
+ $apiKey = $this->getRequest()->getParam('response_key');
39
+
40
+ $helper = Mage::helper('recapture');
41
+ $scope = $helper->getCurrentScope();
42
+ $scopeId = $helper->getCurrentScopeId();
43
+
44
+ if ($apiKey){
45
+
46
+ $config = new Mage_Core_Model_Config();
47
+ $config->saveConfig('recapture/configuration/authenticated', true, $scope, $scopeId);
48
+ $config->saveConfig('recapture/configuration/api_key', $apiKey, $scope, $scopeId);
49
+ $config->saveConfig('recapture/configuration/enabled', true, $scope, $scopeId);
50
+
51
+ Mage::app()->getCacheInstance()->cleanType('config');
52
+
53
+ Mage::getSingleton('adminhtml/session')->addSuccess('Your account has been authenticated successfully!');
54
+
55
+ } else {
56
+
57
+ Mage::getSingleton('adminhtml/session')->addError('Unable to authenticate your account. Please ensure you are logged in to your Recapture account.');
58
+
59
+ }
60
+
61
+ $scope = Mage::helper('recapture')->getScopeForUrl();
62
+ $scope['section'] = 'recapture';
63
+
64
+ return $this->_redirect('adminhtml/system_config/edit', $scope);
65
+
66
+ }
67
+
68
+ public function cancelAction(){
69
+
70
+ Mage::getSingleton('adminhtml/session')->addError('Authentication has been cancelled.');
71
+
72
+ $scope = Mage::helper('recapture')->getScopeForUrl();
73
+ $scope['section'] = 'recapture';
74
+
75
+ return $this->_redirect('adminhtml/system_config/edit', $scope);
76
+
77
+ }
78
+
79
+ }
app/code/local/Recapture/Connector/etc/config.xml CHANGED
@@ -1,140 +1,140 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <modules>
4
- <Recapture_Connector>
5
- <version>1.1.6</version>
6
- </Recapture_Connector>
7
- </modules>
8
-
9
- <global>
10
-
11
- <blocks>
12
- <recapture>
13
- <class>Recapture_Connector_Block</class>
14
- </recapture>
15
- </blocks>
16
-
17
- <helpers>
18
- <recapture>
19
- <class>Recapture_Connector_Helper</class>
20
- </recapture>
21
- </helpers>
22
-
23
- <models>
24
- <recapture>
25
- <class>Recapture_Connector_Model</class>
26
- </recapture>
27
- </models>
28
-
29
- <events>
30
-
31
- <sales_quote_save_after>
32
- <observers>
33
- <recapture_cart_update>
34
- <type>singleton</type>
35
- <class>Recapture_Connector_Model_Observer</class>
36
- <method>quoteUpdate</method>
37
- </recapture_cart_update>
38
- </observers>
39
- </sales_quote_save_after>
40
-
41
- <sales_quote_delete_after>
42
- <observers>
43
- <recapture_cart_update>
44
- <type>singleton</type>
45
- <class>Recapture_Connector_Model_Observer</class>
46
- <method>quoteDelete</method>
47
- </recapture_cart_update>
48
- </observers>
49
- </sales_quote_delete_after>
50
-
51
- <sales_order_place_after>
52
- <observers>
53
- <recapture_cart_conversion>
54
- <type>singleton</type>
55
- <class>Recapture_Connector_Model_Observer</class>
56
- <method>cartConversion</method>
57
- </recapture_cart_conversion>
58
- </observers>
59
- </sales_order_place_after>
60
-
61
- <newsletter_subscriber_save_after>
62
- <observers>
63
- <recapture_cart_subscriber>
64
- <type>singleton</type>
65
- <class>Recapture_Connector_Model_Observer</class>
66
- <method>newsletterSubscriber</method>
67
- </recapture_cart_subscriber>
68
- </observers>
69
- </newsletter_subscriber_save_after>
70
-
71
- </events>
72
-
73
- </global>
74
-
75
- <frontend>
76
- <routers>
77
- <recapture>
78
- <use>standard</use>
79
- <args>
80
- <module>Recapture_Connector</module>
81
- <frontName>recapture</frontName>
82
- </args>
83
- </recapture>
84
- </routers>
85
- <layout>
86
- <updates>
87
- <recapture>
88
- <file>recapture.xml</file>
89
- </recapture>
90
- </updates>
91
- </layout>
92
- </frontend>
93
-
94
- <admin>
95
- <routers>
96
- <adminhtml>
97
- <args>
98
- <modules>
99
- <recaptureadmin after="Mage_Adminhtml">Recapture_Connector</recaptureadmin>
100
- </modules>
101
- </args>
102
- </adminhtml>
103
- </routers>
104
- </admin>
105
-
106
- <adminhtml>
107
- <acl>
108
- <resources>
109
- <all>
110
- <title>Allow Everything</title>
111
- </all>
112
- <admin>
113
- <children>
114
- <system>
115
- <children>
116
- <config>
117
- <children>
118
- <recapture>
119
- <title>Recapture Connector - All</title>
120
- </recapture>
121
- </children>
122
- </config>
123
- </children>
124
- </system>
125
- </children>
126
- </admin>
127
- </resources>
128
- </acl>
129
- </adminhtml>
130
-
131
- <default>
132
- <recapture>
133
- <abandoned_carts>
134
- <return_landing>cart</return_landing>
135
- <include_tax_with_products>0</include_tax_with_products>
136
- </abandoned_carts>
137
- </recapture>
138
- </default>
139
-
140
- </config>
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Recapture_Connector>
5
+ <version>1.2.0</version>
6
+ </Recapture_Connector>
7
+ </modules>
8
+
9
+ <global>
10
+
11
+ <blocks>
12
+ <recapture>
13
+ <class>Recapture_Connector_Block</class>
14
+ </recapture>
15
+ </blocks>
16
+
17
+ <helpers>
18
+ <recapture>
19
+ <class>Recapture_Connector_Helper</class>
20
+ </recapture>
21
+ </helpers>
22
+
23
+ <models>
24
+ <recapture>
25
+ <class>Recapture_Connector_Model</class>
26
+ </recapture>
27
+ </models>
28
+
29
+ <events>
30
+
31
+ <sales_quote_save_after>
32
+ <observers>
33
+ <recapture_cart_update>
34
+ <type>singleton</type>
35
+ <class>Recapture_Connector_Model_Observer</class>
36
+ <method>quoteUpdate</method>
37
+ </recapture_cart_update>
38
+ </observers>
39
+ </sales_quote_save_after>
40
+
41
+ <sales_quote_delete_after>
42
+ <observers>
43
+ <recapture_cart_update>
44
+ <type>singleton</type>
45
+ <class>Recapture_Connector_Model_Observer</class>
46
+ <method>quoteDelete</method>
47
+ </recapture_cart_update>
48
+ </observers>
49
+ </sales_quote_delete_after>
50
+
51
+ <sales_order_place_after>
52
+ <observers>
53
+ <recapture_cart_conversion>
54
+ <type>singleton</type>
55
+ <class>Recapture_Connector_Model_Observer</class>
56
+ <method>cartConversion</method>
57
+ </recapture_cart_conversion>
58
+ </observers>
59
+ </sales_order_place_after>
60
+
61
+ <newsletter_subscriber_save_before>
62
+ <observers>
63
+ <recapture_cart_subscriber>
64
+ <type>singleton</type>
65
+ <class>Recapture_Connector_Model_Observer</class>
66
+ <method>newsletterSubscriber</method>
67
+ </recapture_cart_subscriber>
68
+ </observers>
69
+ </newsletter_subscriber_save_before>
70
+
71
+ </events>
72
+
73
+ </global>
74
+
75
+ <frontend>
76
+ <routers>
77
+ <recapture>
78
+ <use>standard</use>
79
+ <args>
80
+ <module>Recapture_Connector</module>
81
+ <frontName>recapture</frontName>
82
+ </args>
83
+ </recapture>
84
+ </routers>
85
+ <layout>
86
+ <updates>
87
+ <recapture>
88
+ <file>recapture.xml</file>
89
+ </recapture>
90
+ </updates>
91
+ </layout>
92
+ </frontend>
93
+
94
+ <admin>
95
+ <routers>
96
+ <adminhtml>
97
+ <args>
98
+ <modules>
99
+ <recaptureadmin after="Mage_Adminhtml">Recapture_Connector</recaptureadmin>
100
+ </modules>
101
+ </args>
102
+ </adminhtml>
103
+ </routers>
104
+ </admin>
105
+
106
+ <adminhtml>
107
+ <acl>
108
+ <resources>
109
+ <all>
110
+ <title>Allow Everything</title>
111
+ </all>
112
+ <admin>
113
+ <children>
114
+ <system>
115
+ <children>
116
+ <config>
117
+ <children>
118
+ <recapture>
119
+ <title>Recapture Connector - All</title>
120
+ </recapture>
121
+ </children>
122
+ </config>
123
+ </children>
124
+ </system>
125
+ </children>
126
+ </admin>
127
+ </resources>
128
+ </acl>
129
+ </adminhtml>
130
+
131
+ <default>
132
+ <recapture>
133
+ <abandoned_carts>
134
+ <return_landing>cart</return_landing>
135
+ <include_tax_with_products>0</include_tax_with_products>
136
+ </abandoned_carts>
137
+ </recapture>
138
+ </default>
139
+
140
+ </config>
app/code/local/Recapture/Connector/etc/system.xml CHANGED
@@ -1,120 +1,120 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <config>
3
- <tabs>
4
- <recapture translate="label" module="recapture">
5
- <label>Recapture Connector</label>
6
- <sort_order>100</sort_order>
7
- </recapture>
8
- </tabs>
9
- <sections>
10
- <recapture translate="label" module="recapture">
11
- <label>Extension Options</label>
12
- <tab>recapture</tab>
13
- <sort_order>1000</sort_order>
14
- <show_in_default>1</show_in_default>
15
- <show_in_website>1</show_in_website>
16
- <show_in_store>1</show_in_store>
17
-
18
- <groups>
19
- <configuration translate="label" module="recapture">
20
- <label>Authentication</label>
21
- <frontend_type>text</frontend_type>
22
- <sort_order>10</sort_order>
23
- <show_in_default>1</show_in_default>
24
- <show_in_website>1</show_in_website>
25
- <show_in_store>1</show_in_store>
26
-
27
- <fields>
28
- <status translate="label">
29
- <label>Authentication Status</label>
30
- <sort_order>0</sort_order>
31
- <type>text</type>
32
- <show_in_default>1</show_in_default>
33
- <show_in_website>1</show_in_website>
34
- <show_in_store>1</show_in_store>
35
- <frontend_model>recapture/adminhtml_system_config_status</frontend_model>
36
- </status>
37
- <authenticate translate="label">
38
- <label>Authenticate Account</label>
39
- <sort_order>1</sort_order>
40
- <type>button</type>
41
- <show_in_default>1</show_in_default>
42
- <show_in_website>1</show_in_website>
43
- <show_in_store>0</show_in_store>
44
- <frontend_model>recapture/adminhtml_system_config_authenticate</frontend_model>
45
- </authenticate>
46
- <enabled translate="label">
47
- <label>Enabled</label>
48
- <frontend_type>select</frontend_type>
49
- <sort_order>2</sort_order>
50
- <show_in_default>1</show_in_default>
51
- <show_in_website>1</show_in_website>
52
- <show_in_store>0</show_in_store>
53
- <source_model>adminhtml/system_config_source_yesno</source_model>
54
- </enabled>
55
- <api_key translate="label">
56
- <label>API Key</label>
57
- <frontend_type>text</frontend_type>
58
- <frontend_model>recapture/adminhtml_system_config_key</frontend_model>
59
- <sort_order>20</sort_order>
60
- <show_in_default>1</show_in_default>
61
- <show_in_website>1</show_in_website>
62
- <show_in_store>0</show_in_store>
63
- </api_key>
64
- </fields>
65
- </configuration>
66
- <abandoned_carts translate="label" module="recapture">
67
- <label>Abandoned Carts Configuration</label>
68
- <frontend_type>text</frontend_type>
69
- <sort_order>20</sort_order>
70
- <show_in_default>1</show_in_default>
71
- <show_in_website>1</show_in_website>
72
- <show_in_store>1</show_in_store>
73
-
74
- <fields>
75
- <track_email translate="label">
76
- <label>Enable Pre-submit Email Capturing</label>
77
- <frontend_type>select</frontend_type>
78
- <sort_order>10</sort_order>
79
- <show_in_default>1</show_in_default>
80
- <show_in_website>1</show_in_website>
81
- <show_in_store>0</show_in_store>
82
- <source_model>adminhtml/system_config_source_yesno</source_model>
83
- <comment>When enabled, this will immediately capture typed email addresses anywhere on your site, without requiring the customer to submit any type of form. Useful on checkouts like One Step Checkout.</comment>
84
- </track_email>
85
- <capture_subscriber translate="label">
86
- <label>Enable Newsletter Subscription Capturing</label>
87
- <frontend_type>select</frontend_type>
88
- <sort_order>10</sort_order>
89
- <show_in_default>1</show_in_default>
90
- <show_in_website>1</show_in_website>
91
- <show_in_store>0</show_in_store>
92
- <source_model>adminhtml/system_config_source_yesno</source_model>
93
- <comment>When enabled, this will capture any emails that are subscribed to your newsletter.</comment>
94
- </capture_subscriber>
95
- <return_landing translate="label">
96
- <label>Click Through Landing</label>
97
- <frontend_type>select</frontend_type>
98
- <sort_order>20</sort_order>
99
- <show_in_default>1</show_in_default>
100
- <show_in_website>1</show_in_website>
101
- <show_in_store>0</show_in_store>
102
- <source_model>recapture/landing</source_model>
103
- <comment>What page do you want the customer to land on when they click a link in any abandoned cart emails we send?</comment>
104
- </return_landing>
105
- <include_tax_with_products translate="label">
106
- <label>Include Tax with Product Totals</label>
107
- <frontend_type>select</frontend_type>
108
- <sort_order>30</sort_order>
109
- <show_in_default>1</show_in_default>
110
- <show_in_website>1</show_in_website>
111
- <show_in_store>0</show_in_store>
112
- <source_model>adminhtml/system_config_source_yesno</source_model>
113
- <comment>Whether not to include tax in the product total.</comment>
114
- </include_tax_with_products>
115
- </fields>
116
- </abandoned_carts>
117
- </groups>
118
- </recapture>
119
- </sections>
120
  </config>
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <tabs>
4
+ <recapture translate="label" module="recapture">
5
+ <label>Recapture Connector</label>
6
+ <sort_order>100</sort_order>
7
+ </recapture>
8
+ </tabs>
9
+ <sections>
10
+ <recapture translate="label" module="recapture">
11
+ <label>Extension Options</label>
12
+ <tab>recapture</tab>
13
+ <sort_order>1000</sort_order>
14
+ <show_in_default>1</show_in_default>
15
+ <show_in_website>1</show_in_website>
16
+ <show_in_store>1</show_in_store>
17
+
18
+ <groups>
19
+ <configuration translate="label" module="recapture">
20
+ <label>Authentication</label>
21
+ <frontend_type>text</frontend_type>
22
+ <sort_order>10</sort_order>
23
+ <show_in_default>1</show_in_default>
24
+ <show_in_website>1</show_in_website>
25
+ <show_in_store>1</show_in_store>
26
+
27
+ <fields>
28
+ <status translate="label">
29
+ <label>Authentication Status</label>
30
+ <sort_order>0</sort_order>
31
+ <type>text</type>
32
+ <show_in_default>1</show_in_default>
33
+ <show_in_website>1</show_in_website>
34
+ <show_in_store>1</show_in_store>
35
+ <frontend_model>recapture/adminhtml_system_config_status</frontend_model>
36
+ </status>
37
+ <authenticate translate="label">
38
+ <label>Authenticate Account</label>
39
+ <sort_order>1</sort_order>
40
+ <type>button</type>
41
+ <show_in_default>1</show_in_default>
42
+ <show_in_website>1</show_in_website>
43
+ <show_in_store>0</show_in_store>
44
+ <frontend_model>recapture/adminhtml_system_config_authenticate</frontend_model>
45
+ </authenticate>
46
+ <enabled translate="label">
47
+ <label>Enabled</label>
48
+ <frontend_type>select</frontend_type>
49
+ <sort_order>2</sort_order>
50
+ <show_in_default>1</show_in_default>
51
+ <show_in_website>1</show_in_website>
52
+ <show_in_store>0</show_in_store>
53
+ <source_model>adminhtml/system_config_source_yesno</source_model>
54
+ </enabled>
55
+ <api_key translate="label">
56
+ <label>API Key</label>
57
+ <frontend_type>text</frontend_type>
58
+ <frontend_model>recapture/adminhtml_system_config_key</frontend_model>
59
+ <sort_order>20</sort_order>
60
+ <show_in_default>1</show_in_default>
61
+ <show_in_website>1</show_in_website>
62
+ <show_in_store>0</show_in_store>
63
+ </api_key>
64
+ </fields>
65
+ </configuration>
66
+ <abandoned_carts translate="label" module="recapture">
67
+ <label>Abandoned Carts Configuration</label>
68
+ <frontend_type>text</frontend_type>
69
+ <sort_order>20</sort_order>
70
+ <show_in_default>1</show_in_default>
71
+ <show_in_website>1</show_in_website>
72
+ <show_in_store>1</show_in_store>
73
+
74
+ <fields>
75
+ <track_email translate="label">
76
+ <label>Enable Pre-submit Email Capturing</label>
77
+ <frontend_type>select</frontend_type>
78
+ <sort_order>10</sort_order>
79
+ <show_in_default>1</show_in_default>
80
+ <show_in_website>1</show_in_website>
81
+ <show_in_store>0</show_in_store>
82
+ <source_model>adminhtml/system_config_source_yesno</source_model>
83
+ <comment>When enabled, this will immediately capture typed email addresses anywhere on your site, without requiring the customer to submit any type of form. Useful on checkouts like One Step Checkout.</comment>
84
+ </track_email>
85
+ <capture_subscriber translate="label">
86
+ <label>Enable Newsletter Subscription Capturing</label>
87
+ <frontend_type>select</frontend_type>
88
+ <sort_order>10</sort_order>
89
+ <show_in_default>1</show_in_default>
90
+ <show_in_website>1</show_in_website>
91
+ <show_in_store>0</show_in_store>
92
+ <source_model>adminhtml/system_config_source_yesno</source_model>
93
+ <comment>When enabled, this will capture any emails that are subscribed to your newsletter.</comment>
94
+ </capture_subscriber>
95
+ <return_landing translate="label">
96
+ <label>Click Through Landing</label>
97
+ <frontend_type>select</frontend_type>
98
+ <sort_order>20</sort_order>
99
+ <show_in_default>1</show_in_default>
100
+ <show_in_website>1</show_in_website>
101
+ <show_in_store>0</show_in_store>
102
+ <source_model>recapture/landing</source_model>
103
+ <comment>What page do you want the customer to land on when they click a link in any abandoned cart emails we send?</comment>
104
+ </return_landing>
105
+ <include_tax_with_products translate="label">
106
+ <label>Include Tax with Product Totals</label>
107
+ <frontend_type>select</frontend_type>
108
+ <sort_order>30</sort_order>
109
+ <show_in_default>1</show_in_default>
110
+ <show_in_website>1</show_in_website>
111
+ <show_in_store>0</show_in_store>
112
+ <source_model>adminhtml/system_config_source_yesno</source_model>
113
+ <comment>Whether or not to include tax in the product total.</comment>
114
+ </include_tax_with_products>
115
+ </fields>
116
+ </abandoned_carts>
117
+ </groups>
118
+ </recapture>
119
+ </sections>
120
  </config>
app/design/frontend/base/default/layout/recapture.xml CHANGED
@@ -1,10 +1,20 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <layout>
3
-
4
- <default>
5
- <reference name="before_body_end">
6
- <block type="recapture/client" template="recapture/client.phtml" />
7
- </reference>
8
- </default>
9
-
 
 
 
 
 
 
 
 
 
 
10
  </layout>
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <layout>
3
+
4
+ <default>
5
+ <reference name="before_body_end">
6
+ <block type="recapture/client_page" name="recapture.client" template="recapture/client/page.phtml">
7
+ <action method="setCacheLifetime" />
8
+ </block>
9
+ </reference>
10
+ </default>
11
+
12
+ <catalog_product_view>
13
+ <reference name="before_body_end">
14
+ <reference name="recapture.client">
15
+ <action method="setTemplate"><template>recapture/client/product.phtml</template></action>
16
+ </reference>
17
+ </reference>
18
+ </catalog_product_view>
19
+
20
  </layout>
app/design/frontend/base/default/template/recapture/client.phtml DELETED
@@ -1,8 +0,0 @@
1
- <?php if ($this->shouldTrack()){ ?>
2
-
3
- <script type="text/javascript" src="//cdn.recapture.io/loader.min.js"></script>
4
- <script>
5
- recapture.init('<?php echo $this->getApiKey() ?>', '<?php echo $this->getCartId() ?>', {autoDetectEmail: true});
6
- </script>
7
-
8
- <?php } ?>
 
 
 
 
 
 
 
 
app/design/frontend/base/default/template/recapture/client/page.phtml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php if ($this->shouldTrack()){ ?>
2
+ <script type="text/javascript" src="<?php echo $this->getQueueUrl() ?>"></script>
3
+ <script type="text/javascript">
4
+ ra('init', ['<?php echo $this->getApiKey() ?>']);
5
+ ra('page');
6
+ <?php if ($this->shouldTrackEmail()){ ?>
7
+ ra('email');
8
+ <?php } ?>
9
+ </script>
10
+ <?php } ?>
app/design/frontend/base/default/template/recapture/client/product.phtml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php if ($this->shouldTrack()){ ?>
2
+ <script type="text/javascript" src="<?php echo $this->getQueueUrl() ?>"></script>
3
+ <script>
4
+ ra('init', ['<?php echo $this->getApiKey() ?>']);
5
+ ra('product', [{
6
+ sku: '<?php echo Mage::registry('current_product')->getSku() ?>'
7
+ }]);
8
+ </script>
9
+ <?php } ?>
app/etc/modules/Recapture_Connector.xml CHANGED
@@ -1,9 +1,9 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <modules>
4
- <Recapture_Connector>
5
- <active>true</active>
6
- <codePool>local</codePool>
7
- </Recapture_Connector>
8
- </modules>
9
  </config>
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Recapture_Connector>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </Recapture_Connector>
8
+ </modules>
9
  </config>
package.xml CHANGED
@@ -1,18 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>recapture</name>
4
- <version>1.1.7</version>
5
  <stability>stable</stability>
6
  <license>OSL</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Free analytics dashboard for abandoned carts. Set up automated cart recovery email campaigns in minutes.</summary>
10
  <description>Free analytics dashboard for abandoned carts. Set up automated cart recovery email campaigns in minutes.</description>
11
- <notes>Updated version to 1.1.7</notes>
12
  <authors><author><name>David Webber</name><user>Recapture</user><email>hello@recapture.io</email></author></authors>
13
- <date>2015-12-04</date>
14
- <time>23:48:53</time>
15
- <contents><target name="magelocal"><dir name="Recapture"><dir name="Connector"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><file name="Authenticate.php" hash="3452dbf00cdf4a87199eae62873a5706"/><file name="Key.php" hash="adf516740c9e1a392fd7f81c4fb1927e"/><file name="Status.php" hash="f19858c8bb476b05e7e86cbdce403323"/></dir></dir></dir><file name="Client.php" hash="91f04f33fc71e6bbe006d15a49bb6bb2"/></dir><dir name="controllers"><file name="CartController.php" hash="438f39a0c47b852e4e82c9b0505f3d80"/><file name="IndexController.php" hash="3b1bb4f397617f696ac89e688c4dc1ae"/><dir name="Recaptureadmin"><file name="AuthenticateController.php" hash="f49e6525739325f65da0b30e40d4ef5c"/></dir><file name="RecaptureController.php" hash="987215ca928935afc9d4f9ce4fdf670c"/></dir><dir name="etc"><file name="config.xml" hash="ec3dc8d57c89d18dc43387ac6d944c68"/><file name="system.xml" hash="af0be04272df4919869f0d100528954d"/></dir><dir name="Helper"><file name="Data.php" hash="3779ea73875887b10e8ceee0782c8648"/><file name="Transport.php" hash="7bdbdbf7c3cee4841fe7ce42371f5951"/></dir><dir name="Model"><file name="Landing.php" hash="5a9ee53115f4caa835e3e381fd9ba937"/><file name="Observer.php" hash="95591a026c6ad62d049a411f10423405"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Recapture_Connector.xml" hash="e8fea9dc4237af6b34219c7f52bd02d8"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="recapture.xml" hash="5a91899f12df162c706b17db79fb7f72"/></dir><dir name="template"><dir name="recapture"><file name="client.phtml" hash="50b49c48d393cf2566ab42b561bcf277"/></dir></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>recapture</name>
4
+ <version>1.2.0</version>
5
  <stability>stable</stability>
6
  <license>OSL</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Free analytics dashboard for abandoned carts. Set up automated cart recovery email campaigns in minutes.</summary>
10
  <description>Free analytics dashboard for abandoned carts. Set up automated cart recovery email campaigns in minutes.</description>
11
+ <notes>Updated version to 1.2.0</notes>
12
  <authors><author><name>David Webber</name><user>Recapture</user><email>hello@recapture.io</email></author></authors>
13
+ <date>2015-12-28</date>
14
+ <time>13:10:21</time>
15
+ <contents><target name="magelocal"><dir name="Recapture"><dir name="Connector"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><file name="Authenticate.php" hash="2447363f87e72e922841760980b11942"/><file name="Key.php" hash="edc94e9fa84251d875e4a176f067f3fb"/><file name="Status.php" hash="eb53daf1bacc3d994b79506e6eff0d82"/></dir></dir></dir><dir name="Client"><file name="Page.php" hash="16cc42ba69dae1dc572230fe1fea1f9e"/><file name="Product.php" hash="ea2312b5ef50c49324b1b50cd17cb209"/></dir><file name="Client.php" hash="8780534cb8b8b4b6a88d5aeb4725c2c8"/></dir><dir name="Helper"><file name="Data.php" hash="4100aaba15822e103d63f19e548f9027"/><file name="Transport.php" hash="1219b8da93905496e383b3d358e0c1e2"/></dir><dir name="Model"><file name="Landing.php" hash="b50b47fb13f6bfef79fba6a6efd926c8"/><file name="Observer.php" hash="c1846c885264346b9d994b2a3f6fc0cd"/></dir><dir name="controllers"><file name="CartController.php" hash="fc341ddef155031b8aba22504d85b197"/><file name="EmailController.php" hash="4248cbc84fca095697e1c1185d516ffb"/><file name="IndexController.php" hash="cb6747d719c1080cd8ca485255cbdbf0"/><dir name="Recaptureadmin"><file name="AuthenticateController.php" hash="e1ae384a0b93f155934000205ee393d7"/></dir></dir><dir name="etc"><file name="config.xml" hash="784654592548f0c49dcca43a2108842e"/><file name="system.xml" hash="5cd5494936e54186e7180ddc37b9c56a"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Recapture_Connector.xml" hash="9d4118bc5293b3d732a353a8e402316a"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="recapture.xml" hash="db6abfffb58287c0a9c13ef8ceccbcc8"/></dir><dir name="template"><dir name="recapture"><dir name="client"><file name="page.phtml" hash="b09e356b874e5e3cf5ead473f0215036"/><file name="product.phtml" hash="ea01d5c7bde14881157e65c6571f68a3"/></dir></dir></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>