Iterable_Plugin - Version 1.7.0

Version Notes

Changes the Transactional Email section to allow for rewriting any Magento email template to an Iterable event or campaign.

Download this release

Release Info

Developer Ilya Brin
Extension Iterable_Plugin
Version 1.7.0
Comparing to
See all releases


Code changes from version 1.6.0 to 1.7.0

app/code/community/Iterable/TrackOrderPlaced/Block/Adminhtml/System/Config/Form/Field/Campaigns.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Iterable_TrackOrderPlaced_Block_Adminhtml_System_Config_Form_Field_Campaigns
5
+ extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
6
+ {
7
+ public function __construct()
8
+ {
9
+ $this->addColumn('template', array(
10
+ 'label' => Mage::helper('trackorderplaced')->__('Template Name'),
11
+ 'style' => 'width:300px',
12
+ ));
13
+ $this->addColumn('campaign_id', array(
14
+ 'label' => Mage::helper('trackorderplaced')->__('Campaign ID'),
15
+ 'style' => 'width:300px',
16
+ ));
17
+ $this->_addAfter = false;
18
+ $this->_addButtonLabel = Mage::helper('trackorderplaced')->__('Add New');
19
+ parent::__construct();
20
+ }
21
+ }
app/code/community/Iterable/TrackOrderPlaced/Block/Adminhtml/System/Config/Form/Field/Events.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Iterable_TrackOrderPlaced_Block_Adminhtml_System_Config_Form_Field_Events
5
+ extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
6
+ {
7
+ public function __construct()
8
+ {
9
+ $this->addColumn('template', array(
10
+ 'label' => Mage::helper('trackorderplaced')->__('Template Name'),
11
+ 'style' => 'width:200px',
12
+ ));
13
+ $this->addColumn('event_name', array(
14
+ 'label' => Mage::helper('trackorderplaced')->__('Event Name'),
15
+ 'style' => 'width:300px',
16
+ ));
17
+ $this->_addAfter = false;
18
+ $this->_addButtonLabel = Mage::helper('trackorderplaced')->__('Add New');
19
+ parent::__construct();
20
+ }
21
+ }
app/code/community/Iterable/TrackOrderPlaced/Helper/Data.php CHANGED
@@ -1,106 +1,71 @@
1
  <?php
2
 
3
- class Iterable_TrackOrderPlaced_Helper_Data extends Mage_Core_Helper_Abstract {
4
-
 
5
  const XML_PATH_ITERABLE_API_KEY = 'api_options/api_key_options/api_key';
6
  const XML_PATH_ENABLED_EVENTS = 'advanced_options/tracking_options/enabled_events';
7
 
8
- /** transactional email xml config */
9
-
10
- // account created
11
- const XML_PATH_TRANSACTIONAL_ACCOUNT_CREATED_ENABLED = 'transactional_email_options/account_created/is_enabled';
12
- const XML_PATH_TRANSACTIONAL_ACCOUNT_CREATED_CAMPAIGN_ID = 'transactional_email_options/account_created/campaign_id';
13
- const XML_PATH_TRANSACTIONAL_FORGOT_PASSWORD_ENABLED = 'transactional_email_options/forgot_password/is_enabled';
14
- const XML_PATH_TRANSACTIONAL_FORGOT_PASSWORD_CAMPAIGN_ID = 'transactional_email_options/forgot_password/campaign_id';
15
- const XML_PATH_TRANSACTIONAL_NEWSLETTER_SUBSCRIBE_ENABLED = 'transactional_email_options/newsletter_subscribe/is_enabled';
16
- const XML_PATH_TRANSACTIONAL_NEWSLETTER_SUBSCRIBE_CAMPAIGN_ID = 'transactional_email_options/newsletter_subscribe/campaign_id';
17
- const XML_PATH_TRANSACTIONAL_NEWSLETTER_UNSUBSCRIBE_ENABLED = 'transactional_email_options/newsletter_unsubscribe/is_enabled';
18
- const XML_PATH_TRANSACTIONAL_NEWSLETTER_UNSUBSCRIBE_CAMPAIGN_ID = 'transactional_email_options/newsletter_unsubscribe/campaign_id';
19
-
20
- // disabled section
21
- const XML_PATH_TRANSACTIONAL_ORDER_CONFIRM_DISABLED = 'transactional_email_options/order_confirm/is_disabled';
22
-
23
- /** end transactional email xml config */
24
-
25
- /** @var array Map of templateName -> (enabled, campaignId) */
26
- private static $EMAIL_TEMPLATE_NAMES_TO_TRANSACTIONAL_EMAIL_OPTIONS = array(
27
- 'customer_create_account_email_template' => array(
28
- self::XML_PATH_TRANSACTIONAL_ACCOUNT_CREATED_ENABLED,
29
- self::XML_PATH_TRANSACTIONAL_ACCOUNT_CREATED_CAMPAIGN_ID
30
- ),
31
- 'customer_password_forgot_email_template' => array(
32
- self::XML_PATH_TRANSACTIONAL_FORGOT_PASSWORD_ENABLED,
33
- self::XML_PATH_TRANSACTIONAL_FORGOT_PASSWORD_CAMPAIGN_ID
34
- ),
35
- 'newsletter_subscription_success_email_template' => array(
36
- self::XML_PATH_TRANSACTIONAL_NEWSLETTER_SUBSCRIBE_ENABLED,
37
- self::XML_PATH_TRANSACTIONAL_NEWSLETTER_SUBSCRIBE_CAMPAIGN_ID
38
- ),
39
- 'newsletter_subscription_un_email_template' => array(
40
- self::XML_PATH_TRANSACTIONAL_NEWSLETTER_UNSUBSCRIBE_ENABLED,
41
- self::XML_PATH_TRANSACTIONAL_NEWSLETTER_UNSUBSCRIBE_CAMPAIGN_ID
42
- )
43
- );
44
-
45
- public static function getTransactionalEmailConfig() {
46
- return self::$EMAIL_TEMPLATE_NAMES_TO_TRANSACTIONAL_EMAIL_OPTIONS;
47
- }
48
-
49
- private static $EMAIL_TEMPLATE_NAMES_TO_DISABLED_OPTIONS = array(
50
- 'sales_email_order_template' => self::XML_PATH_TRANSACTIONAL_ORDER_CONFIRM_DISABLED
51
- );
52
-
53
- public static function getDefaultEmailDisabledConfig() {
54
- return self::$EMAIL_TEMPLATE_NAMES_TO_DISABLED_OPTIONS;
55
- }
56
-
57
- private function getDecodedMagentoApiToken() {
58
  $magentoApiKey = Mage::getStoreConfig(self::XML_PATH_ITERABLE_API_KEY);
 
59
  return json_decode(base64_decode($magentoApiKey));
60
  }
61
 
62
- private function getIterableApiToken() {
 
63
  $apiKeyJson = $this->getDecodedMagentoApiToken();
64
- if ($apiKeyJson == NULL) {
65
- return NULL;
66
  }
 
67
  return $apiKeyJson->t;
68
  }
69
-
70
- public function getNewsletterEmailListId() {
 
71
  $apiKeyJson = $this->getDecodedMagentoApiToken();
72
- if ($apiKeyJson == NULL) {
73
- return NULL;
74
  }
 
75
  return $apiKeyJson->n;
76
  }
77
 
78
- public function getAccountEmailListId() {
 
79
  $apiKeyJson = $this->getDecodedMagentoApiToken();
80
- if ($apiKeyJson == NULL) {
81
- return NULL;
82
  }
 
83
  return $apiKeyJson->u;
84
  }
85
 
86
- private function callIterableApi($event, $endpoint, $params) {
87
- $eventsToTrack = Mage::getStoreConfig(self::XML_PATH_ENABLED_EVENTS);
88
- $eventsToTrack = explode(",", $eventsToTrack);
89
- if (!in_array($event, $eventsToTrack)) {
90
- Mage::log("Iterable: tracking disabled for event " . $event);
91
- // TODO - maybe run this before gathering data about the cart
92
- return null;
 
 
 
 
93
  }
94
  $apiKey = $this->getIterableApiToken();
95
- if ($apiKey == NULL) {
96
  return null;
97
  }
98
  $url = "https://api.iterable.com/{$endpoint}?api_key={$apiKey}";
99
  // $url = "http://localhost:9000{$endpoint}?api_key={$apiKey}";
100
  try {
101
  $client = new Zend_Http_Client($url);
102
- } catch(Exception $e) {
103
  Mage::log("Warning: unable to create http client with url {$url} ({$e->getMessage()})");
 
104
  return null;
105
  }
106
  $client->setMethod(Zend_Http_Client::POST);
@@ -111,40 +76,52 @@ class Iterable_TrackOrderPlaced_Helper_Data extends Mage_Core_Helper_Abstract {
111
  $response = $client->request();
112
  $status = $response->getStatus();
113
  if ($status != 200) {
114
- Mage::log("Iterable Tracker: Unable to track event at {$endpoint} with params {$json}; got status {$status} with body {$response->getBody()}");
 
 
115
  }
 
116
  return $response;
117
- } catch(Exception $e) {
118
- Mage::log("Warning: unable to send event at {$endpoint} with params {$json} to Iterable ({$e->getMessage()})");
 
 
 
119
  return null;
120
  }
121
  }
122
 
123
- public function getIp() {
 
124
  return Mage::helper('core/http')->getRemoteAddr(false);
125
  }
126
 
127
- public function setCurrentIp(&$dataFields) {
 
128
  if (!array_key_exists('ip', $dataFields)) {
129
  $dataFields['ip'] = $this->getIp();
130
  }
131
  }
132
 
133
- public function updateUser($email, $dataFields=array(), $eventNameHint=null) {
 
134
  $endpoint = '/api/users/update';
135
  $params = array(
136
  'email' => $email
137
  );
138
  $this->setCurrentIp($dataFields);
139
  $params['dataFields'] = $dataFields;
140
- $eventName = isset($eventNameHint) ? $eventNameHint : Iterable_TrackOrderPlaced_Model_Trackingeventtypes::EVENT_TYPE_USER;
 
 
141
  return $this->callIterableApi($eventName, $endpoint, $params);
142
  }
143
-
144
- public function subscribeEmailToList($email, $listId, $dataFields=array(), $resubscribe=False) {
 
145
  $endpoint = '/api/lists/subscribe';
146
  $params = array(
147
- 'listId' => $listId,
148
  'subscribers' => array(
149
  array(
150
  'email' => $email
@@ -155,13 +132,17 @@ class Iterable_TrackOrderPlaced_Helper_Data extends Mage_Core_Helper_Abstract {
155
  if (!empty($dataFields)) {
156
  $params['subscribers'][0]['dataFields'] = $dataFields;
157
  }
158
- return $this->callIterableApi(Iterable_TrackOrderPlaced_Model_Trackingeventtypes::EVENT_TYPE_NEWSLETTER_SUBSCRIBE, $endpoint, $params);
 
 
 
159
  }
160
-
161
- public function unsubscribeEmailFromList($email, $listId) {
 
162
  $endpoint = '/api/lists/unsubscribe';
163
  $params = array(
164
- 'listId' => $listId,
165
  'subscribers' => array(
166
  array(
167
  'email' => $email
@@ -169,25 +150,49 @@ class Iterable_TrackOrderPlaced_Helper_Data extends Mage_Core_Helper_Abstract {
169
  )
170
  // 'campaignId' => iterableCid cookie?
171
  );
172
- return $this->callIterableApi(Iterable_TrackOrderPlaced_Model_Trackingeventtypes::EVENT_TYPE_NEWSLETTER_UNSUBSCRIBE, $endpoint, $params);
 
 
 
173
  }
174
 
175
- public function track($event, $email, $dataFields=array()) {
 
 
176
  $endpoint = '/api/events/track';
177
  $params = array(
178
- 'email' => $email,
179
  'eventName' => $event
180
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
181
  if (!empty($dataFields)) {
182
  $params['dataFields'] = $dataFields;
183
  }
184
- return $this->callIterableApi($event, $endpoint, $params);
 
185
  }
186
 
187
- public function updateCart($email, $items, $dataFields=array()) {
 
188
  $endpoint = '/api/commerce/updateCart';
189
  $params = array(
190
- 'user' => array(
191
  'email' => $email
192
  ),
193
  'items' => $items
@@ -195,13 +200,19 @@ class Iterable_TrackOrderPlaced_Helper_Data extends Mage_Core_Helper_Abstract {
195
  if (!empty($dataFields)) {
196
  $params['user']['dataFields'] = $dataFields;
197
  }
198
- return $this->callIterableApi(Iterable_TrackOrderPlaced_Model_Trackingeventtypes::EVENT_TYPE_CART_UPDATED, $endpoint, $params);
 
 
 
199
  }
200
 
201
- public function trackPurchase($email, $items, $total, $campaignId=NULL, $templateId=NULL, $dataFields=array(), $customerDataFields=array()) {
 
 
 
202
  $endpoint = '/api/commerce/trackPurchase';
203
  $params = array(
204
- 'user' => array(
205
  'email' => $email
206
  ),
207
  'items' => $items,
@@ -213,28 +224,47 @@ class Iterable_TrackOrderPlaced_Helper_Data extends Mage_Core_Helper_Abstract {
213
  if (!empty($customerDataFields)) {
214
  $params['user']['dataFields'] = $customerDataFields;
215
  }
216
- if ($campaignId != NULL) {
 
 
 
 
 
 
217
  $params['campaignId'] = $campaignId;
218
  }
219
- if ($templateId != NULL) {
 
 
 
 
 
220
  $params['templateId'] = $templateId;
221
  }
222
- return $this->callIterableApi(Iterable_TrackOrderPlaced_Model_Trackingeventtypes::EVENT_TYPE_ORDER, $endpoint, $params);
 
 
 
223
  }
224
 
225
- public function triggerCampaign($email, $campaignId, $dataFields=NULL) {
 
226
  $endpoint = '/api/email/target';
227
  $params = array(
228
  'recipientEmail' => $email,
229
- 'campaignId' => $campaignId
230
  );
231
- if (! is_null($dataFields)) {
232
  $params['dataFields'] = $dataFields;
233
  }
234
- return $this->callIterableApi(Iterable_TrackOrderPlaced_Model_Trackingeventtypes::EVENT_TYPE_TRIGGER_EMAIL, $endpoint, $params);
 
 
 
235
  }
236
 
237
- public function trackShipment($email, $shipment) {
 
238
  return $this->track(Iterable_TrackOrderPlaced_Model_Trackingeventtypes::EVENT_TYPE_SHIPMENT, $email, $shipment);
239
  }
240
 
@@ -245,8 +275,10 @@ class Iterable_TrackOrderPlaced_Helper_Data extends Mage_Core_Helper_Abstract {
245
 
246
  public function trackWishlist($email, $wishlist)
247
  {
248
- return $this->updateUser($email, array(
 
249
  'wishlist' => $wishlist
250
- ), Iterable_TrackOrderPlaced_Model_Trackingeventtypes::EVENT_TYPE_WISHLIST_ADD_PRODUCT);
 
251
  }
252
  }
1
  <?php
2
 
3
+ class Iterable_TrackOrderPlaced_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
  const XML_PATH_ITERABLE_API_KEY = 'api_options/api_key_options/api_key';
7
  const XML_PATH_ENABLED_EVENTS = 'advanced_options/tracking_options/enabled_events';
8
 
9
+ private function getDecodedMagentoApiToken()
10
+ {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  $magentoApiKey = Mage::getStoreConfig(self::XML_PATH_ITERABLE_API_KEY);
12
+
13
  return json_decode(base64_decode($magentoApiKey));
14
  }
15
 
16
+ private function getIterableApiToken()
17
+ {
18
  $apiKeyJson = $this->getDecodedMagentoApiToken();
19
+ if ($apiKeyJson == null) {
20
+ return null;
21
  }
22
+
23
  return $apiKeyJson->t;
24
  }
25
+
26
+ public function getNewsletterEmailListId()
27
+ {
28
  $apiKeyJson = $this->getDecodedMagentoApiToken();
29
+ if ($apiKeyJson == null) {
30
+ return null;
31
  }
32
+
33
  return $apiKeyJson->n;
34
  }
35
 
36
+ public function getAccountEmailListId()
37
+ {
38
  $apiKeyJson = $this->getDecodedMagentoApiToken();
39
+ if ($apiKeyJson == null) {
40
+ return null;
41
  }
42
+
43
  return $apiKeyJson->u;
44
  }
45
 
46
+ private function callIterableApi($event, $endpoint, $params, $skipTrackCheck = false)
47
+ {
48
+ if ($skipTrackCheck == false) {
49
+ $eventsToTrack = Mage::getStoreConfig(self::XML_PATH_ENABLED_EVENTS);
50
+ $eventsToTrack = explode(",", $eventsToTrack);
51
+ if (!in_array($event, $eventsToTrack)) {
52
+ Mage::log("Iterable: tracking disabled for event " . $event);
53
+
54
+ // TODO - maybe run this before gathering data about the cart
55
+ return null;
56
+ }
57
  }
58
  $apiKey = $this->getIterableApiToken();
59
+ if ($apiKey == null) {
60
  return null;
61
  }
62
  $url = "https://api.iterable.com/{$endpoint}?api_key={$apiKey}";
63
  // $url = "http://localhost:9000{$endpoint}?api_key={$apiKey}";
64
  try {
65
  $client = new Zend_Http_Client($url);
66
+ } catch (Exception $e) {
67
  Mage::log("Warning: unable to create http client with url {$url} ({$e->getMessage()})");
68
+
69
  return null;
70
  }
71
  $client->setMethod(Zend_Http_Client::POST);
76
  $response = $client->request();
77
  $status = $response->getStatus();
78
  if ($status != 200) {
79
+ Mage::log(
80
+ "Iterable Tracker: Unable to track event at {$endpoint} with params {$json}; got status {$status} with body {$response->getBody()}"
81
+ );
82
  }
83
+
84
  return $response;
85
+ } catch (Exception $e) {
86
+ Mage::log(
87
+ "Warning: unable to send event at {$endpoint} with params {$json} to Iterable ({$e->getMessage()})"
88
+ );
89
+
90
  return null;
91
  }
92
  }
93
 
94
+ public function getIp()
95
+ {
96
  return Mage::helper('core/http')->getRemoteAddr(false);
97
  }
98
 
99
+ public function setCurrentIp(&$dataFields)
100
+ {
101
  if (!array_key_exists('ip', $dataFields)) {
102
  $dataFields['ip'] = $this->getIp();
103
  }
104
  }
105
 
106
+ public function updateUser($email, $dataFields = array(), $eventNameHint = null)
107
+ {
108
  $endpoint = '/api/users/update';
109
  $params = array(
110
  'email' => $email
111
  );
112
  $this->setCurrentIp($dataFields);
113
  $params['dataFields'] = $dataFields;
114
+ $eventName = isset($eventNameHint) ? $eventNameHint
115
+ : Iterable_TrackOrderPlaced_Model_Trackingeventtypes::EVENT_TYPE_USER;
116
+
117
  return $this->callIterableApi($eventName, $endpoint, $params);
118
  }
119
+
120
+ public function subscribeEmailToList($email, $listId, $dataFields = array(), $resubscribe = false)
121
+ {
122
  $endpoint = '/api/lists/subscribe';
123
  $params = array(
124
+ 'listId' => $listId,
125
  'subscribers' => array(
126
  array(
127
  'email' => $email
132
  if (!empty($dataFields)) {
133
  $params['subscribers'][0]['dataFields'] = $dataFields;
134
  }
135
+
136
+ return $this->callIterableApi(
137
+ Iterable_TrackOrderPlaced_Model_Trackingeventtypes::EVENT_TYPE_NEWSLETTER_SUBSCRIBE, $endpoint, $params
138
+ );
139
  }
140
+
141
+ public function unsubscribeEmailFromList($email, $listId)
142
+ {
143
  $endpoint = '/api/lists/unsubscribe';
144
  $params = array(
145
+ 'listId' => $listId,
146
  'subscribers' => array(
147
  array(
148
  'email' => $email
150
  )
151
  // 'campaignId' => iterableCid cookie?
152
  );
153
+
154
+ return $this->callIterableApi(
155
+ Iterable_TrackOrderPlaced_Model_Trackingeventtypes::EVENT_TYPE_NEWSLETTER_UNSUBSCRIBE, $endpoint, $params
156
+ );
157
  }
158
 
159
+ public function track(
160
+ $event, $email, $dataFields = array(), $campaignId = null, $templateId = null, $skipTrackCheck = false
161
+ ) {
162
  $endpoint = '/api/events/track';
163
  $params = array(
164
+ 'email' => $email,
165
  'eventName' => $event
166
+ );
167
+
168
+ $cookieModel = Mage::getModel('core/cookie');
169
+ if ($campaignId == null) {
170
+ $campaignId = $cookieModel->get('iterableEmailCampaignId');
171
+ $campaignId = empty($campaignId) ? null: intval($campaignId);
172
+ }
173
+ if ($campaignId != null) {
174
+ $params['campaignId'] = $campaignId;
175
+ }
176
+
177
+ if ($templateId == null) {
178
+ $templateId = $cookieModel->get('iterableTemplateId');
179
+ $templateId = empty($templateId) ? null : intval($templateId);
180
+ }
181
+ if ($templateId != null) {
182
+ $params['templateId'] = $templateId;
183
+ }
184
  if (!empty($dataFields)) {
185
  $params['dataFields'] = $dataFields;
186
  }
187
+
188
+ return $this->callIterableApi($event, $endpoint, $params, $skipTrackCheck);
189
  }
190
 
191
+ public function updateCart($email, $items, $dataFields = array())
192
+ {
193
  $endpoint = '/api/commerce/updateCart';
194
  $params = array(
195
+ 'user' => array(
196
  'email' => $email
197
  ),
198
  'items' => $items
200
  if (!empty($dataFields)) {
201
  $params['user']['dataFields'] = $dataFields;
202
  }
203
+
204
+ return $this->callIterableApi(
205
+ Iterable_TrackOrderPlaced_Model_Trackingeventtypes::EVENT_TYPE_CART_UPDATED, $endpoint, $params
206
+ );
207
  }
208
 
209
+ public function trackPurchase(
210
+ $email, $items, $total, $campaignId = null, $templateId = null, $dataFields = array(),
211
+ $customerDataFields = array()
212
+ ) {
213
  $endpoint = '/api/commerce/trackPurchase';
214
  $params = array(
215
+ 'user' => array(
216
  'email' => $email
217
  ),
218
  'items' => $items,
224
  if (!empty($customerDataFields)) {
225
  $params['user']['dataFields'] = $customerDataFields;
226
  }
227
+
228
+ $cookieModel = Mage::getModel('core/cookie');
229
+ if ($campaignId == null) {
230
+ $campaignId = $cookieModel->get('iterableEmailCampaignId');
231
+ $campaignId = empty($campaignId) ? null: intval($campaignId);
232
+ }
233
+ if ($campaignId != null) {
234
  $params['campaignId'] = $campaignId;
235
  }
236
+
237
+ if ($templateId == null) {
238
+ $templateId = $cookieModel->get('iterableTemplateId');
239
+ $templateId = empty($templateId) ? null : intval($templateId);
240
+ }
241
+ if ($templateId != null) {
242
  $params['templateId'] = $templateId;
243
  }
244
+
245
+ return $this->callIterableApi(
246
+ Iterable_TrackOrderPlaced_Model_Trackingeventtypes::EVENT_TYPE_ORDER, $endpoint, $params
247
+ );
248
  }
249
 
250
+ public function triggerCampaign($email, $campaignId, $dataFields = null)
251
+ {
252
  $endpoint = '/api/email/target';
253
  $params = array(
254
  'recipientEmail' => $email,
255
+ 'campaignId' => $campaignId
256
  );
257
+ if (!is_null($dataFields)) {
258
  $params['dataFields'] = $dataFields;
259
  }
260
+
261
+ return $this->callIterableApi(
262
+ Iterable_TrackOrderPlaced_Model_Trackingeventtypes::EVENT_TYPE_TRIGGER_EMAIL, $endpoint, $params
263
+ );
264
  }
265
 
266
+ public function trackShipment($email, $shipment)
267
+ {
268
  return $this->track(Iterable_TrackOrderPlaced_Model_Trackingeventtypes::EVENT_TYPE_SHIPMENT, $email, $shipment);
269
  }
270
 
275
 
276
  public function trackWishlist($email, $wishlist)
277
  {
278
+ return $this->updateUser(
279
+ $email, array(
280
  'wishlist' => $wishlist
281
+ ), Iterable_TrackOrderPlaced_Model_Trackingeventtypes::EVENT_TYPE_WISHLIST_ADD_PRODUCT
282
+ );
283
  }
284
  }
app/code/community/Iterable/TrackOrderPlaced/Model/Email/Template.php CHANGED
@@ -1,74 +1,161 @@
1
  <?php
 
2
  /**
3
  * This class overwrites Magento's default send functionality by routing all
4
  * emails through Iterable using the Send API call.
5
- *
6
- * @author Iterable
7
  */
8
- class Iterable_TrackOrderPlaced_Model_Email_Template extends Mage_Core_Model_Email_Template {
9
-
10
- private function getIterableCampaignIdForTemplateName($templateName) {
11
- $transactionalEmailConfig = Mage::helper('trackorderplaced')->getTransactionalEmailConfig();
12
- if (array_key_exists($templateName, $transactionalEmailConfig)) {
13
- // if there's something for this template, check whether it's enabled and return the id if so
14
- list($enabled_cfg, $iterable_campaign_id_cfg) = $transactionalEmailConfig[$templateName];
15
- return Mage::getStoreConfig($enabled_cfg) ? intval(Mage::getStoreConfig($iterable_campaign_id_cfg)): null;
16
- } else {
17
- // if there's nothing for this template don't send through Iterable
18
- return null;
19
- }
20
- }
21
 
22
- private function isDefaultSendingDisabledForTemplateName($templateName) {
23
- $disabledTemplateConfig = Mage::helper('trackorderplaced')->getDefaultEmailDisabledConfig();
24
- return
25
- array_key_exists($templateName, $disabledTemplateConfig) &&
26
- intval(Mage::getStoreConfig($disabledTemplateConfig[$templateName]));
27
- }
28
 
29
  /**
30
  * Send mail to recipient
31
  *
32
- * @param array|string $email E-mail(s)
33
- * @param array|string|null $name receiver name(s)
34
- * @param array $variables template variables
 
35
  * @return boolean
36
  **/
37
- public function send($email, $name = null, array $variables = array())
38
  {
39
- $helper = Mage::helper('trackorderplaced');
40
 
41
- $template_name = $this->getId();
42
- if ($this->isDefaultSendingDisabledForTemplateName($template_name)) {
43
- // Mage::log("Suppressing default email for " . $template_name . " due to Iterable config");
44
- return true;
 
 
 
 
 
 
45
  }
46
- $iterable_campaign_id = $this->getIterableCampaignIdForTemplateName($template_name);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
 
48
- if (empty($iterable_campaign_id)) {
49
- // Mage::log("Not sending " . $template_name . " through Iterable");
50
- return parent::send($email, $name, $variables);
51
  }
52
 
53
- // email and name can be either arrays or strings; we don't care about the name though
54
- $emails = array_values((array)$email);
 
55
 
56
- $anyFailures = false;
57
- foreach ($emails as $email) {
58
- try {
59
- $response = $helper->triggerCampaign($email, $iterable_campaign_id);
60
- if (is_null($response) || ($response->getStatus() != 200)) {
61
- Mage::log("Unable to trigger Iterable email for user " . $email . " and campaign " . $iterable_campaign_id . "; sending default Magento email");
62
- parent::send($email, null, $variables);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  }
64
- } catch (Exception $e) {
65
- Mage::logException($e);
66
- $anyFailures = true;
67
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  }
69
 
70
- return ! $anyFailures;
71
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
 
73
  }
74
- ?>
1
  <?php
2
+
3
  /**
4
  * This class overwrites Magento's default send functionality by routing all
5
  * emails through Iterable using the Send API call.
6
+ *
 
7
  */
8
+ class Iterable_TrackOrderPlaced_Model_Email_Template extends Mage_Core_Model_Email_Template
9
+ {
 
 
 
 
 
 
 
 
 
 
 
10
 
11
+ protected $_helper;
 
 
 
 
 
12
 
13
  /**
14
  * Send mail to recipient
15
  *
16
+ * @param array|string $email E-mail(s)
17
+ * @param array|string|null $name receiver name(s)
18
+ * @param array $variables template variables
19
+ *
20
  * @return boolean
21
  **/
22
+ public function send($email, $name = null, array $variables = array())
23
  {
24
+ $this->_helper = Mage::helper('trackorderplaced');
25
 
26
+ // events take precedence.
27
+
28
+ $templateCode = ($this->getTemplateCode()) ? $this->getTemplateCode() : $this->getTemplateId();
29
+
30
+ $intercept = unserialize(Mage::getStoreConfig('transactional_email_options/events/intercept'));
31
+ $cleanMap = array();
32
+ if (is_array($intercept) && count($intercept) > 0) {
33
+ foreach ($intercept as $map) {
34
+ $cleanMap[$map['template']] = $map['event_name'];
35
+ }
36
  }
37
+ if (array_key_exists($templateCode, $cleanMap)) {
38
+ $result = $this->_sendAsEvent($email, $name, $variables, $cleanMap);
39
+ if (!is_null($result)) {
40
+ return $result;
41
+ }
42
+ } else {
43
+ $intercept = unserialize(Mage::getStoreConfig('transactional_email_options/campaigns/intercept'));
44
+ $cleanMap = array();
45
+ if (is_array($intercept) && count($intercept) > 0) {
46
+ foreach ($intercept as $map) {
47
+ $cleanMap[$map['template']] = $map['campaign_id'];
48
+ }
49
+ }
50
+ if (array_key_exists($templateCode, $cleanMap)) {
51
+ $result = $this->_sendAsCampaign($email, $cleanMap[$templateCode], $name, $variables);
52
+ if (!is_null($result)) {
53
+ return $result;
54
+ }
55
 
56
+ }
 
 
57
  }
58
 
59
+ // the fallback default
60
+
61
+ return parent::send($email, $name, $variables);
62
 
63
+ }
64
+
65
+
66
+ /**
67
+ * Email intercepted to event
68
+ *
69
+ * @param array|string $email E-mail(s)
70
+ * @param array|string|null $name receiver name(s)
71
+ * @param array $variables template variables
72
+ * @param array $cleanMap admin config data
73
+ *
74
+ * @return bool
75
+ */
76
+ private function _sendAsEvent($email, $name = null, array $variables = array(), $cleanMap = array())
77
+ {
78
+ try {
79
+ // the default event name is the template code
80
+ $eventName = ($this->getTemplateCode()) ? $this->getTemplateCode() : $this->getTemplateId();
81
+ if ($cleanMap[$eventName] != null) {
82
+ $eventName = $cleanMap[$eventName];
83
+ }
84
+ $variables['name'] = $name;
85
+ unset($variables['store']);
86
+ $data = array();
87
+ foreach($variables as $key => $value){
88
+ if($value instanceof Varien_Object) {
89
+ $data = array_merge($data, $value->getData());
90
+ unset($variables[$key]);
91
+ } elseif(is_array($value)) {
92
+ $data = array_merge($data, $value);
93
+ unset($variables[$key]);
94
  }
 
 
 
95
  }
96
+ $extraData = mage::registry('additional_iterable_vars');
97
+ if(is_array($extraData)) {
98
+ $data = array_merge($data, $extraData);
99
+ }
100
+ $dataFields = array_merge($variables, $data);
101
+ unset($dataFields['data']);
102
+
103
+ return $this->_helper->track($eventName, $email, $dataFields, null, null, true);
104
+
105
+ } catch (Exception $e) {
106
+ mage::logException($e);
107
+
108
+ return parent::send($email, $name, $variables);
109
  }
110
 
111
+ return true;
112
+ }
113
+
114
+
115
+ /**
116
+ * EMail intercepted as campaign
117
+ *
118
+ * @param array|string $email E-mail(s)
119
+ * @param string|int $campaignId campaign id
120
+ * @param array|string|null $name receiver name(s)
121
+ * @param array $variables template variables
122
+ *
123
+ * @return bool
124
+ */
125
+ private function _sendAsCampaign($email, $campaignId, $name = null, array $variables = array())
126
+ {
127
+ try {
128
+ $campaignId = (int)$campaignId;
129
+
130
+ if (empty($campaignId)) {
131
+ return parent::send($email, $name, $variables);
132
+ }
133
+
134
+ // email and name can be either arrays or strings; we don't care about the name though
135
+ $emails = array_values((array)$email);
136
+
137
+ $anyFailures = false;
138
+ foreach ($emails as $email) {
139
+ try {
140
+ $response = $this->_helper->triggerCampaign($email, $campaignId, $variables);
141
+ if (is_null($response) || ($response->getStatus() != 200)) {
142
+ Mage::log(
143
+ "Unable to trigger Iterable email for user " . $email . " and campaign "
144
+ . $campaignId
145
+ . "; sending default Magento email"
146
+ );
147
+ parent::send($email, null, $variables);
148
+ }
149
+ } catch (Exception $e) {
150
+ Mage::logException($e);
151
+ $anyFailures = true;
152
+ }
153
+ }
154
+
155
+ return !$anyFailures;
156
+ } catch (Exception $e) {
157
+ mage::logException($e);
158
+ }
159
+ }
160
 
161
  }
 
app/code/community/Iterable/TrackOrderPlaced/Model/Observer.php CHANGED
@@ -64,12 +64,12 @@ class Iterable_TrackOrderPlaced_Model_Observer
64
  $product = Mage::getModel('catalog/product')->load($item->getProductId());
65
  }
66
  $typeId = $product->getTypeId();
67
-
68
  if ($isOrder) {
69
  $price = $item->getPrice();
70
  $quantity = $item->getQtyOrdered();
71
  } elseif ($isQuote) {
72
- $price = $item->getCalculationPrice();
73
  $quantity = $item->getQty();
74
  } else {
75
  $price = ($typeId == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) ?
@@ -78,7 +78,7 @@ class Iterable_TrackOrderPlaced_Model_Observer
78
  $product->getPrice();
79
  $quantity = intval($product->getCartQty());
80
  }
81
-
82
  $imageUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/product/'.$product->getImage();
83
  $thumbnailUrl = Mage::getModel('catalog/product_media_config')->getMediaUrl($product->getThumbnail());
84
  $categoryNames = array();
@@ -103,7 +103,7 @@ class Iterable_TrackOrderPlaced_Model_Observer
103
  }
104
 
105
  public function getItemsFromQuote($quote=NULL, $includeConfigurableSubproducts=TRUE)
106
- {
107
  if ($quote == NULL) {
108
  $quote = Mage::getSingleton('checkout/session')->getQuote();
109
  }
@@ -139,7 +139,7 @@ class Iterable_TrackOrderPlaced_Model_Observer
139
  }
140
  $customer = Mage::getSingleton('customer/session')->getCustomer();
141
  $helper = Mage::helper('trackorderplaced');
142
- $helper->updateCart($customer->getEmail(), $items);
143
  }
144
 
145
  /**
@@ -151,7 +151,7 @@ class Iterable_TrackOrderPlaced_Model_Observer
151
  $quote = $observer->getEvent()->getQuoteItem()->getQuote();
152
  $quote->collectTotals();
153
  $quote->save();
154
-
155
  $this->sendCartUpdated();
156
  }
157
 
@@ -175,7 +175,7 @@ class Iterable_TrackOrderPlaced_Model_Observer
175
  $this->sendCartUpdated();
176
  }
177
 
178
- /**
179
  * Called when something is removed from the cart (for example via the trash can symbol on cart page)
180
  * Unforunately it also gets called on updateItems with quantity = 0, or when you reconfigure a configurable product with different options (so we'll get a few extra events)
181
  */
@@ -183,7 +183,7 @@ class Iterable_TrackOrderPlaced_Model_Observer
183
  {
184
  $this->sendCartUpdated();
185
  }
186
-
187
  /**
188
  * Gets fired before the quote is saved. Seems to happen on changes to cart, in addition to whenever we view it
189
  * There doesn't seem to be any event called when the user clicks "Clear Shopping Cart", so hook into this and check what they clicked
@@ -273,13 +273,6 @@ class Iterable_TrackOrderPlaced_Model_Observer
273
  $items = array_values($orderItems);
274
  $email = $order->getCustomerEmail();
275
 
276
- $cookieModel = Mage::getModel('core/cookie');
277
- // $iterableUid = $cookieModel->get('iterable_uid');
278
- $campaignId = $cookieModel->get('iterableEmailCampaignId');
279
- $campaignId = empty($campaignId) ? NULL: intval($campaignId);
280
- $templateId = $cookieModel->get('iterableTemplateId');
281
- $templateId = empty($templateId) ? NULL: intval($templateId);
282
-
283
  $subtotal = $order->getSubtotal();
284
  $dataFields = array(
285
  'subtotal' => $subtotal,
@@ -326,7 +319,7 @@ class Iterable_TrackOrderPlaced_Model_Observer
326
  'lastName' => $order->getCustomerLastname()
327
  );
328
  $helper = Mage::helper('trackorderplaced');
329
- $helper->trackPurchase($email, $items, $subtotal, $campaignId, $templateId, $dataFields, $customerDataFields);
330
 
331
  // don't need to clear cart, server does it automatically
332
  }
@@ -335,10 +328,10 @@ class Iterable_TrackOrderPlaced_Model_Observer
335
  * Gets called when a customer saves their data
336
  * Also seems to get called at several other times (after an order, etc)
337
  */
338
- public function customerSaveAfter(Varien_Event_Observer $observer)
339
  {
340
  $customer = $observer->getCustomer();
341
-
342
  $email = $customer->getEmail();
343
 
344
  $dataFields = $customer->getData();
@@ -353,7 +346,7 @@ class Iterable_TrackOrderPlaced_Model_Observer
353
  $defaultBilling = $customer->getDefaultBillingAddress();
354
  if ($defaultBilling) { $dataFields['defaultBilling'] = $defaultBilling->getData(); }
355
  // unset password/conf... unset created_at because that never changes, and it's in a bad format to boot
356
- $fieldsToUnset = array('password', 'password_hash', 'confirmation', 'subscriber_confirm_code', 'created_at');
357
  foreach ($fieldsToUnset as $fieldToUnset) {
358
  if (array_key_exists($fieldToUnset, $dataFields)) {
359
  unset($dataFields[$fieldToUnset]);
@@ -372,7 +365,7 @@ class Iterable_TrackOrderPlaced_Model_Observer
372
  if (!$customer->getOrigData()) {
373
  $listId = $helper->getAccountEmailListId();
374
  if ($listId != NULL) {
375
- $helper->subscribeEmailToList($email, $listId, $dataFields);
376
  }
377
  }
378
  }
@@ -431,7 +424,7 @@ class Iterable_TrackOrderPlaced_Model_Observer
431
  }
432
  */
433
 
434
- /**
435
  * Called whenever a newsletter subscriber is saved
436
  */
437
  public function newsletterSubscriberSaveAfter(Varien_Event_Observer $observer)
64
  $product = Mage::getModel('catalog/product')->load($item->getProductId());
65
  }
66
  $typeId = $product->getTypeId();
67
+
68
  if ($isOrder) {
69
  $price = $item->getPrice();
70
  $quantity = $item->getQtyOrdered();
71
  } elseif ($isQuote) {
72
+ $price = $item->getCalculationPrice();
73
  $quantity = $item->getQty();
74
  } else {
75
  $price = ($typeId == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) ?
78
  $product->getPrice();
79
  $quantity = intval($product->getCartQty());
80
  }
81
+
82
  $imageUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/product/'.$product->getImage();
83
  $thumbnailUrl = Mage::getModel('catalog/product_media_config')->getMediaUrl($product->getThumbnail());
84
  $categoryNames = array();
103
  }
104
 
105
  public function getItemsFromQuote($quote=NULL, $includeConfigurableSubproducts=TRUE)
106
+ {
107
  if ($quote == NULL) {
108
  $quote = Mage::getSingleton('checkout/session')->getQuote();
109
  }
139
  }
140
  $customer = Mage::getSingleton('customer/session')->getCustomer();
141
  $helper = Mage::helper('trackorderplaced');
142
+ $helper->updateCart($customer->getEmail(), $items);
143
  }
144
 
145
  /**
151
  $quote = $observer->getEvent()->getQuoteItem()->getQuote();
152
  $quote->collectTotals();
153
  $quote->save();
154
+
155
  $this->sendCartUpdated();
156
  }
157
 
175
  $this->sendCartUpdated();
176
  }
177
 
178
+ /**
179
  * Called when something is removed from the cart (for example via the trash can symbol on cart page)
180
  * Unforunately it also gets called on updateItems with quantity = 0, or when you reconfigure a configurable product with different options (so we'll get a few extra events)
181
  */
183
  {
184
  $this->sendCartUpdated();
185
  }
186
+
187
  /**
188
  * Gets fired before the quote is saved. Seems to happen on changes to cart, in addition to whenever we view it
189
  * There doesn't seem to be any event called when the user clicks "Clear Shopping Cart", so hook into this and check what they clicked
273
  $items = array_values($orderItems);
274
  $email = $order->getCustomerEmail();
275
 
 
 
 
 
 
 
 
276
  $subtotal = $order->getSubtotal();
277
  $dataFields = array(
278
  'subtotal' => $subtotal,
319
  'lastName' => $order->getCustomerLastname()
320
  );
321
  $helper = Mage::helper('trackorderplaced');
322
+ $helper->trackPurchase($email, $items, $subtotal, null, null, $dataFields, $customerDataFields);
323
 
324
  // don't need to clear cart, server does it automatically
325
  }
328
  * Gets called when a customer saves their data
329
  * Also seems to get called at several other times (after an order, etc)
330
  */
331
+ public function customerSaveAfter(Varien_Event_Observer $observer)
332
  {
333
  $customer = $observer->getCustomer();
334
+
335
  $email = $customer->getEmail();
336
 
337
  $dataFields = $customer->getData();
346
  $defaultBilling = $customer->getDefaultBillingAddress();
347
  if ($defaultBilling) { $dataFields['defaultBilling'] = $defaultBilling->getData(); }
348
  // unset password/conf... unset created_at because that never changes, and it's in a bad format to boot
349
+ $fieldsToUnset = array('password', 'password_hash', 'confirmation', 'subscriber_confirm_code', 'created_at');
350
  foreach ($fieldsToUnset as $fieldToUnset) {
351
  if (array_key_exists($fieldToUnset, $dataFields)) {
352
  unset($dataFields[$fieldToUnset]);
365
  if (!$customer->getOrigData()) {
366
  $listId = $helper->getAccountEmailListId();
367
  if ($listId != NULL) {
368
+ $helper->subscribeEmailToList($email, $listId, $dataFields);
369
  }
370
  }
371
  }
424
  }
425
  */
426
 
427
+ /**
428
  * Called whenever a newsletter subscriber is saved
429
  */
430
  public function newsletterSubscriberSaveAfter(Varien_Event_Observer $observer)
app/code/community/Iterable/TrackOrderPlaced/etc/config.xml CHANGED
@@ -20,7 +20,7 @@
20
  -->
21
  <Iterable_TrackOrderPlaced>
22
  <!-- The version of our module, starting at 0.0.1 -->
23
- <version>1.6.0</version>
24
  </Iterable_TrackOrderPlaced>
25
  </modules>
26
 
@@ -33,18 +33,27 @@
33
  </trackorderplaced>
34
  </helpers>
35
 
 
 
 
 
 
 
36
  <models>
37
  <iterable_trackorderplaced>
38
  <class>Iterable_TrackOrderPlaced_Model</class>
39
  </iterable_trackorderplaced>
40
 
41
- <!-- disabled for now for Memebox; clashes with CustomSMTP
 
 
42
  <core>
43
  <rewrite>
44
  <email_template>Iterable_TrackOrderPlaced_Model_Email_Template</email_template>
45
  </rewrite>
46
  </core>
47
  -->
 
48
  </models>
49
 
50
  <!-- Defining an event observer -->
20
  -->
21
  <Iterable_TrackOrderPlaced>
22
  <!-- The version of our module, starting at 0.0.1 -->
23
+ <version>1.7.0</version>
24
  </Iterable_TrackOrderPlaced>
25
  </modules>
26
 
33
  </trackorderplaced>
34
  </helpers>
35
 
36
+ <blocks>
37
+ <trackorderplaced>
38
+ <class>Iterable_TrackOrderPlaced_Block</class>
39
+ </trackorderplaced>
40
+ </blocks>
41
+
42
  <models>
43
  <iterable_trackorderplaced>
44
  <class>Iterable_TrackOrderPlaced_Model</class>
45
  </iterable_trackorderplaced>
46
 
47
+ <!--
48
+ Provides email rewriting functionality.
49
+ Be sure to resolve rewrite conflicts with other module that rewrite email_template before enabling it
50
  <core>
51
  <rewrite>
52
  <email_template>Iterable_TrackOrderPlaced_Model_Email_Template</email_template>
53
  </rewrite>
54
  </core>
55
  -->
56
+
57
  </models>
58
 
59
  <!-- Defining an event observer -->
app/code/community/Iterable/TrackOrderPlaced/etc/system.xml CHANGED
@@ -3,7 +3,8 @@
3
  <iterableconfig translate="label" module="trackorderplaced">
4
  <label><![CDATA[<div>Iterable</div>]]></label>
5
  <class>iterable-section</class>
6
- <sort_order>101</sort_order> <!-- General is 100, from app/code/core/Mage/Core/etc/system.xml -->
 
7
  </iterableconfig>
8
  </tabs>
9
  <sections> <!-- each section defined here is a subcategory of a heading from tabs. EACH SECTION NEEDS AN ACL DEFINED IN CONFIG.XML -->
@@ -47,146 +48,46 @@
47
  <show_in_website>1</show_in_website>
48
  <show_in_store>1</show_in_store>
49
  <groups>
50
- <account_created translate="label">
51
- <label>Account Created</label>
52
- <frontend_type>text</frontend_type>
53
- <sort_order>1</sort_order>
54
- <show_in_default>1</show_in_default>
55
- <show_in_website>1</show_in_website>
56
- <show_in_store>1</show_in_store>
57
- <fields>
58
- <is_enabled>
59
- <label>Enabled</label>
60
- <comment>Send account creation emails through Iterable</comment>
61
- <frontend_type>select</frontend_type>
62
- <source_model>adminhtml/system_config_source_yesno</source_model>
63
- <sort_order>1</sort_order>
64
- <show_in_default>1</show_in_default>
65
- <show_in_website>1</show_in_website>
66
- <show_in_store>1</show_in_store>
67
- </is_enabled>
68
- <campaign_id>
69
- <label>Triggered Campaign Id</label>
70
- <comment>Id of the Triggered Email Campaign to send when a user creates an account</comment>
71
- <frontend_type>text</frontend_type>
72
- <validate>validate-number</validate>
73
- <sort_order>2</sort_order>
74
- <show_in_default>1</show_in_default>
75
- <show_in_website>1</show_in_website>
76
- <show_in_store>1</show_in_store>
77
- </campaign_id>
78
- </fields>
79
- </account_created>
80
- <forgot_password translate="label">
81
- <label>Forgot Password</label>
82
  <frontend_type>text</frontend_type>
83
  <sort_order>2</sort_order>
84
  <show_in_default>1</show_in_default>
85
  <show_in_website>1</show_in_website>
86
  <show_in_store>1</show_in_store>
87
  <fields>
88
- <is_enabled>
89
- <label>Enabled</label>
90
- <comment>Send password reset emails through Iterable</comment>
91
- <frontend_type>select</frontend_type>
92
- <source_model>adminhtml/system_config_source_yesno</source_model>
93
- <sort_order>1</sort_order>
94
- <show_in_default>1</show_in_default>
95
- <show_in_website>1</show_in_website>
96
- <show_in_store>1</show_in_store>
97
- </is_enabled>
98
- <campaign_id>
99
- <label>Triggered Campaign Id</label>
100
- <comment>Id of the Triggered Email Campaign to send when a user resets their password</comment>
101
- <frontend_type>text</frontend_type>
102
- <validate>validate-number</validate>
103
- <sort_order>2</sort_order>
104
- <show_in_default>1</show_in_default>
105
- <show_in_website>1</show_in_website>
106
- <show_in_store>1</show_in_store>
107
- </campaign_id>
108
- </fields>
109
- </forgot_password>
110
- <newsletter_subscribe translate="label">
111
- <label>Newsletter Subscribes</label>
112
- <frontend_type>text</frontend_type>
113
- <sort_order>3</sort_order>
114
- <show_in_default>1</show_in_default>
115
- <show_in_website>1</show_in_website>
116
- <show_in_store>1</show_in_store>
117
- <fields>
118
- <is_enabled>
119
- <label>Enabled</label>
120
- <comment>Send newsletter subscription emails through Iterable</comment>
121
- <frontend_type>select</frontend_type>
122
- <source_model>adminhtml/system_config_source_yesno</source_model>
123
- <sort_order>1</sort_order>
124
  <show_in_default>1</show_in_default>
125
  <show_in_website>1</show_in_website>
126
  <show_in_store>1</show_in_store>
127
- </is_enabled>
128
- <campaign_id>
129
- <label>Triggered Campaign Id</label>
130
- <comment>Id of the Triggered Email Campaign to send when a user subscribes to a newsletter</comment>
131
- <frontend_type>text</frontend_type>
132
- <validate>validate-number</validate>
133
- <sort_order>2</sort_order>
134
- <show_in_default>1</show_in_default>
135
- <show_in_website>1</show_in_website>
136
- <show_in_store>1</show_in_store>
137
- </campaign_id>
138
  </fields>
139
- </newsletter_subscribe>
140
- <newsletter_unsubscribe translate="label">
141
- <label>Newsletter Unsubscribes</label>
142
  <frontend_type>text</frontend_type>
143
- <sort_order>4</sort_order>
144
- <show_in_default>1</show_in_default>
145
- <show_in_website>1</show_in_website>
146
- <show_in_store>1</show_in_store>
147
- <fields>
148
- <is_enabled>
149
- <label>Enabled</label>
150
- <comment>Send newsletter unsubscription emails through Iterable</comment>
151
- <frontend_type>select</frontend_type>
152
- <source_model>adminhtml/system_config_source_yesno</source_model>
153
- <sort_order>1</sort_order>
154
- <show_in_default>1</show_in_default>
155
- <show_in_website>1</show_in_website>
156
- <show_in_store>1</show_in_store>
157
- </is_enabled>
158
- <campaign_id>
159
- <label>Triggered Campaign Id</label>
160
- <comment>Id of the Triggered Email Campaign to send when a user unsubscribes from a newsletter</comment>
161
- <frontend_type>text</frontend_type>
162
- <validate>validate-number</validate>
163
- <sort_order>2</sort_order>
164
- <show_in_default>1</show_in_default>
165
- <show_in_website>1</show_in_website>
166
- <show_in_store>1</show_in_store>
167
- </campaign_id>
168
- </fields>
169
- </newsletter_unsubscribe>
170
- <order_confirm translate="label">
171
- <label>Order Confirmations</label>
172
- <frontend_type>text</frontend_type>
173
- <sort_order>5</sort_order>
174
  <show_in_default>1</show_in_default>
175
  <show_in_website>1</show_in_website>
176
  <show_in_store>1</show_in_store>
177
  <fields>
178
- <is_disabled>
179
- <label>Disabled</label>
180
- <comment>Suppress default order confirmation emails from Magento. Make sure you set up an appropriate workflow in Iterable first!</comment>
181
- <frontend_type>select</frontend_type>
182
- <source_model>adminhtml/system_config_source_yesno</source_model>
183
- <sort_order>1</sort_order>
184
  <show_in_default>1</show_in_default>
185
  <show_in_website>1</show_in_website>
186
  <show_in_store>1</show_in_store>
187
- </is_disabled>
 
188
  </fields>
189
- </order_confirm>
190
  </groups>
191
  </transactional_email_options>
192
  <advanced_options>
3
  <iterableconfig translate="label" module="trackorderplaced">
4
  <label><![CDATA[<div>Iterable</div>]]></label>
5
  <class>iterable-section</class>
6
+ <sort_order>101</sort_order>
7
+ <!-- General is 100, from app/code/core/Mage/Core/etc/system.xml -->
8
  </iterableconfig>
9
  </tabs>
10
  <sections> <!-- each section defined here is a subcategory of a heading from tabs. EACH SECTION NEEDS AN ACL DEFINED IN CONFIG.XML -->
48
  <show_in_website>1</show_in_website>
49
  <show_in_store>1</show_in_store>
50
  <groups>
51
+ <campaigns translate="label">
52
+ <label>Campaigns</label>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  <frontend_type>text</frontend_type>
54
  <sort_order>2</sort_order>
55
  <show_in_default>1</show_in_default>
56
  <show_in_website>1</show_in_website>
57
  <show_in_store>1</show_in_store>
58
  <fields>
59
+ <intercept translate="label">
60
+ <label>Transaction Emails to intercept into campaigns</label>
61
+ <frontend_model>trackorderplaced/adminhtml_system_config_form_field_campaigns</frontend_model>
62
+ <backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
63
+ <sort_order>100</sort_order>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  <show_in_default>1</show_in_default>
65
  <show_in_website>1</show_in_website>
66
  <show_in_store>1</show_in_store>
67
+ <comment><![CDATA[Intercept these emails and initiate a campaign]]></comment>
68
+ </intercept>
 
 
 
 
 
 
 
 
 
69
  </fields>
70
+ </campaigns>
71
+ <events translate="label">
72
+ <label>Events</label>
73
  <frontend_type>text</frontend_type>
74
+ <sort_order>1</sort_order>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  <show_in_default>1</show_in_default>
76
  <show_in_website>1</show_in_website>
77
  <show_in_store>1</show_in_store>
78
  <fields>
79
+ <intercept translate="label">
80
+ <label>Transaction Emails to intercept into events</label>
81
+ <frontend_model>trackorderplaced/adminhtml_system_config_form_field_events</frontend_model>
82
+ <backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
83
+ <sort_order>100</sort_order>
 
84
  <show_in_default>1</show_in_default>
85
  <show_in_website>1</show_in_website>
86
  <show_in_store>1</show_in_store>
87
+ <comment><![CDATA[Intercept these emails and push tracking data]]></comment>
88
+ </intercept>
89
  </fields>
90
+ </events>
91
  </groups>
92
  </transactional_email_options>
93
  <advanced_options>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Iterable_Plugin</name>
4
- <version>1.6.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/OSL-3.0">Open Software License (OSL) </license>
7
  <channel>community</channel>
@@ -15,11 +15,11 @@ drip marketing campaigns.&#xD;
15
  To install, click the 'Install Now' button above and paste the link into your Magento Connect Manager. You will then see an Iterable section in your Magento Admin view. In the 'Advanced' section, select the events you would like to be sent to Iterable. Then, in the API section, enter your Magento API key from Iterable (located in the API Config section on the left side menu).&#xD;
16
  &#xD;
17
  Questions? Comments? Feel free to contact us at support@iterable.com. Also, for more info or a free demo, please visit us at Iterable.com.</description>
18
- <notes>Fixes TrackingEventTypes on a case-sensitive file system.</notes>
19
  <authors><author><name>Ilya Brin</name><user>Iterable</user><email>ilya@iterable.com</email></author></authors>
20
- <date>2015-09-11</date>
21
- <time>01:18:29</time>
22
- <contents><target name="magecommunity"><dir name="Iterable"><dir name="TrackOrderPlaced"><dir name="Helper"><file name="Data.php" hash="06b62e12204751bfd4a0b9f9c385eb82"/></dir><dir name="Model"><dir name="Email"><file name="Template.php" hash="225b9fb6b5eac3b506813bae86e1f005"/></dir><file name="Observer.php" hash="52381c8207b52476a11a52860e6268f3"/><file name="Trackingeventtypes.php" hash="ebc9e15c1bb02bb6dade12c4be8328e3"/></dir><dir name="etc"><file name="config.xml" hash="5332ebcd72d93a677d05d0a3e938c294"/><file name="system.xml" hash="32d1f49eb03cd585b7c33a894fe4de15"/></dir><dir name=".idea"><file name="TrackOrderPlaced.iml" hash="64a676a732fd4b7f408cdd46b49aaa24"/><file name="compiler.xml" hash="7e7efa3e3d6514a0ff290e4dfce3cbe9"/><dir name="copyright"><file name="profiles_settings.xml" hash="b1e0b181e080c28b1d116582290e6e97"/></dir><file name="encodings.xml" hash="f1c5edfa5b1a67aabcb9e41674afa252"/><file name="foobar" hash="d41d8cd98f00b204e9800998ecf8427e"/><file name="misc.xml" hash="a09f56c13a544171f953e7723e0d4439"/><file name="modules.xml" hash="c93cdff764916047e398fcf5b105a3ed"/><dir name="scopes"><file name="scope_settings.xml" hash="3d0b1957d39aa5636904788c54e654cf"/></dir><file name="vcs.xml" hash="1b4ab30910ae53c73594cd0e3db9840b"/><file name="workspace.xml" hash="6b623904b5b85b0966e42a14d9711d8d"/><file name=".name" hash="8b29e935aaea69d5d9c071be993c4610"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="iterable"><file name="common.xml" hash="d90fbb22fb34fa29deb6b0e131f9e767"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Iterable_TrackOrderPlaced.xml" hash="0d4506dadf95eecb54e215ed03b2c6a7"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="iterable"><dir name="images"><file name="section_logo.png" hash="fe5090ba955a890c1efe2c09cb260342"/></dir><file name="iterable.css" hash="4d928c5a4ed76d62e246a57ee868ec23"/></dir></dir></dir></dir></target></contents>
23
  <compatible/>
24
  <dependencies><required><php><min>5.3.1</min><max>6.0.0</max></php></required></dependencies>
25
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Iterable_Plugin</name>
4
+ <version>1.7.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/OSL-3.0">Open Software License (OSL) </license>
7
  <channel>community</channel>
15
  To install, click the 'Install Now' button above and paste the link into your Magento Connect Manager. You will then see an Iterable section in your Magento Admin view. In the 'Advanced' section, select the events you would like to be sent to Iterable. Then, in the API section, enter your Magento API key from Iterable (located in the API Config section on the left side menu).&#xD;
16
  &#xD;
17
  Questions? Comments? Feel free to contact us at support@iterable.com. Also, for more info or a free demo, please visit us at Iterable.com.</description>
18
+ <notes>Changes the Transactional Email section to allow for rewriting any Magento email template to an Iterable event or campaign. </notes>
19
  <authors><author><name>Ilya Brin</name><user>Iterable</user><email>ilya@iterable.com</email></author></authors>
20
+ <date>2015-09-17</date>
21
+ <time>23:50:46</time>
22
+ <contents><target name="magecommunity"><dir name="Iterable"><dir name="TrackOrderPlaced"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Campaigns.php" hash="0ff0612fe4bb5fcd9c5df691538c8515"/><file name="Events.php" hash="3e953d5de5e2aea167776208986146a7"/></dir></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="16dc0af570fda193334f6f3c2881bc7f"/></dir><dir name="Model"><dir name="Email"><file name="Template.php" hash="af6a0584435352b8c9d67d046b308a5b"/></dir><file name="Observer.php" hash="034f44ad801bc7579ca26160c5cb4486"/><file name="Trackingeventtypes.php" hash="ebc9e15c1bb02bb6dade12c4be8328e3"/></dir><dir name="etc"><file name="config.xml" hash="bd1cbfb122ebb3d169b3ed815f36c02f"/><file name="system.xml" hash="bcb2de28283f4ec280f63fe8887e2aa5"/></dir><dir name=".idea"><file name="TrackOrderPlaced.iml" hash="64a676a732fd4b7f408cdd46b49aaa24"/><file name="compiler.xml" hash="7e7efa3e3d6514a0ff290e4dfce3cbe9"/><dir name="copyright"><file name="profiles_settings.xml" hash="b1e0b181e080c28b1d116582290e6e97"/></dir><file name="encodings.xml" hash="f1c5edfa5b1a67aabcb9e41674afa252"/><file name="foobar" hash="d41d8cd98f00b204e9800998ecf8427e"/><file name="misc.xml" hash="a09f56c13a544171f953e7723e0d4439"/><file name="modules.xml" hash="c93cdff764916047e398fcf5b105a3ed"/><dir name="scopes"><file name="scope_settings.xml" hash="3d0b1957d39aa5636904788c54e654cf"/></dir><file name="vcs.xml" hash="1b4ab30910ae53c73594cd0e3db9840b"/><file name="workspace.xml" hash="6b623904b5b85b0966e42a14d9711d8d"/><file name=".name" hash="8b29e935aaea69d5d9c071be993c4610"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="iterable"><file name="common.xml" hash="d90fbb22fb34fa29deb6b0e131f9e767"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Iterable_TrackOrderPlaced.xml" hash="0d4506dadf95eecb54e215ed03b2c6a7"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="iterable"><dir name="images"><file name="section_logo.png" hash="fe5090ba955a890c1efe2c09cb260342"/></dir><file name="iterable.css" hash="4d928c5a4ed76d62e246a57ee868ec23"/></dir></dir></dir></dir></target></contents>
23
  <compatible/>
24
  <dependencies><required><php><min>5.3.1</min><max>6.0.0</max></php></required></dependencies>
25
  </package>