Iterable_Plugin - Version 1.4.2

Version Notes

Pass over a ton more data about the order.

Download this release

Release Info

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


Code changes from version 1.4.1 to 1.4.2

app/code/community/Iterable/TrackOrderPlaced/Model/Observer.php CHANGED
@@ -195,12 +195,77 @@ class Iterable_TrackOrderPlaced_Model_Observer
195
  }
196
  }
197
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
198
  /**
199
  * Gets called when an order is placed
200
  */
201
  public function orderPlaced(Varien_Event_Observer $observer)
202
  {
203
  $order = $observer->getEvent()->getOrder();
 
204
  $payment = $order->getPayment();
205
  $orderItems = $this->getItemsFromQuote($order, FALSE);
206
  $items = array_values($orderItems);
@@ -220,6 +285,8 @@ class Iterable_TrackOrderPlaced_Model_Observer
220
  'taxAmount' => $order->getTaxAmount(),
221
  'shippingAmount' => $order->getShippingAmount(),
222
  'incrementId' => $order->increment_id,
 
 
223
  'billingAddress' => $order->getBillingAddress()->getData(),
224
  'billingAddressHtml' => $order->getBillingAddress()->format('html'),
225
  'shippingAddress' => $order->getShippingAddress()->getData(),
@@ -228,8 +295,28 @@ class Iterable_TrackOrderPlaced_Model_Observer
228
  'emailCustomerNote' => $order->getEmailCustomerNote(),
229
  'statusLabel' => $order->getStatusLabel(),
230
  'storeFrontendName' => $order->getStore()->getFrontendName(),
 
 
 
231
  'payment' => $payment->getData()
232
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
233
  $customerDataFields = array(
234
  'firstName' => $order->getCustomerFirstname(),
235
  'lastName' => $order->getCustomerLastname()
195
  }
196
  }
197
 
198
+ /**
199
+ * Generates the items html. Copied from Mage_Core_Model_Email_Template_Filter->layoutDirective
200
+ */
201
+ private function generateOrderItemsHtml($order)
202
+ {
203
+ $params = array(
204
+ 'order' => $order
205
+ );
206
+
207
+ $layout = Mage::getModel('core/layout');
208
+ $layout->getUpdate()->addHandle('sales_email_order_items');
209
+ $layout->getUpdate()->load();
210
+
211
+ $layout->generateXml();
212
+ $layout->generateBlocks();
213
+
214
+ foreach ($layout->getAllBlocks() as $blockName => $block) {
215
+ foreach ($params as $k => $v) {
216
+ $block->setDataUsingMethod($k, $v);
217
+ }
218
+ }
219
+
220
+ /**
221
+ * Add output method for first block
222
+ */
223
+ $allBlocks = $layout->getAllBlocks();
224
+ $firstBlock = reset($allBlocks);
225
+ if ($firstBlock) {
226
+ $layout->addOutputBlock($firstBlock->getNameInLayout());
227
+ }
228
+
229
+ $layout->setDirectOutput(false);
230
+
231
+ return $layout->getOutput();
232
+ }
233
+
234
+ /**
235
+ * borrowed from Mage_Core_Model_Email_Template
236
+ */
237
+ protected function getLogoUrl($store)
238
+ {
239
+ $fileName = $store->getConfig(Mage_Core_Model_Email_Template::XML_PATH_DESIGN_EMAIL_LOGO);
240
+ if ($fileName) {
241
+ $uploadDir = Mage_Adminhtml_Model_System_Config_Backend_Email_Logo::UPLOAD_DIR;
242
+ $fullFileName = Mage::getBaseDir('media') . DS . $uploadDir . DS . $fileName;
243
+ if (file_exists($fullFileName)) {
244
+ return Mage::getBaseUrl('media') . $uploadDir . '/' . $fileName;
245
+ }
246
+ }
247
+ return Mage::getDesign()->getSkinUrl('images/logo_email.gif');
248
+ }
249
+
250
+ /**
251
+ * borrowed from Mage_Core_Model_Email_Template
252
+ */
253
+ protected function getLogoAlt($store)
254
+ {
255
+ $alt = $store->getConfig(Mage_Core_Model_Email_Template::XML_PATH_DESIGN_EMAIL_LOGO_ALT);
256
+ if ($alt) {
257
+ return $alt;
258
+ }
259
+ return $store->getFrontendName();
260
+ }
261
+
262
  /**
263
  * Gets called when an order is placed
264
  */
265
  public function orderPlaced(Varien_Event_Observer $observer)
266
  {
267
  $order = $observer->getEvent()->getOrder();
268
+ $store = $order->getStore();
269
  $payment = $order->getPayment();
270
  $orderItems = $this->getItemsFromQuote($order, FALSE);
271
  $items = array_values($orderItems);
285
  'taxAmount' => $order->getTaxAmount(),
286
  'shippingAmount' => $order->getShippingAmount(),
287
  'incrementId' => $order->increment_id,
288
+ 'orderCreatedAtLong' => $order->getCreatedAtFormated('long'),
289
+ 'orderIsNotVirtual' => $order->getIsNotVirtual(),
290
  'billingAddress' => $order->getBillingAddress()->getData(),
291
  'billingAddressHtml' => $order->getBillingAddress()->format('html'),
292
  'shippingAddress' => $order->getShippingAddress()->getData(),
295
  'emailCustomerNote' => $order->getEmailCustomerNote(),
296
  'statusLabel' => $order->getStatusLabel(),
297
  'storeFrontendName' => $order->getStore()->getFrontendName(),
298
+ 'storeUrl' => Mage::app()->getStore(Mage::getDesign()->getStore())->getUrl(''), // from Mage_Core_Model_Email_Template_Filter->storeDirective
299
+ 'logoUrl' => $this->getLogoUrl($store),
300
+ 'logoAlt' => $this->getLogoAlt($store),
301
  'payment' => $payment->getData()
302
  );
303
+
304
+ ///////////////
305
+ // COPIED FROM MAGENTO CORE: Mage_Sales_Model_Order->sendNewOrderEmail()
306
+ $storeId = $order->getStore()->getId();
307
+ try {
308
+ // Retrieve specified view block from appropriate design package (depends on emulated store)
309
+ $paymentBlock = Mage::helper('payment')->getInfoBlock($payment)
310
+ ->setIsSecureMode(true);
311
+ $paymentBlock->getMethod()->setStore($storeId);
312
+ $dataFields['paymentHtml'] = $paymentBlock->toHtml();
313
+ } catch (Exception $exception) {
314
+ Mage::log("Iterable Warning: unable to generate paymentHtml ({$exception->getMessage()})");
315
+ }
316
+ //////////// end payment_html
317
+
318
+ $dataFields['orderItemsHtml'] = $this->generateOrderItemsHtml($order);
319
+
320
  $customerDataFields = array(
321
  'firstName' => $order->getCustomerFirstname(),
322
  'lastName' => $order->getCustomerLastname()
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Iterable_Plugin</name>
4
- <version>1.4.1</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>Handle more order information such as billing, shipping, and payment.</notes>
19
  <authors><author><name>Ilya Brin</name><user>Iterable</user><email>ilya@iterable.com</email></author></authors>
20
- <date>2014-10-02</date>
21
- <time>02:11:46</time>
22
- <contents><target name="magecommunity"><dir name="Iterable"><dir name="TrackOrderPlaced"><dir name="Helper"><file name="Data.php" hash="a6029c49149215655477fac0442b365f"/></dir><dir name="Model"><dir name="Email"><file name="Template.php" hash="225b9fb6b5eac3b506813bae86e1f005"/></dir><file name="Observer.php" hash="9beac31883fd63bb653e083ad9befb13"/><file name="TrackingEventTypes.php" hash="b81614a3a0fcd67aee43a29093044261"/></dir><dir name="etc"><file name="config.xml" hash="fcfea5dfdb4a375516c4d5b4d8ab6684"/><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="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.4.2</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>Pass over a ton more data about the order.</notes>
19
  <authors><author><name>Ilya Brin</name><user>Iterable</user><email>ilya@iterable.com</email></author></authors>
20
+ <date>2014-10-03</date>
21
+ <time>04:28:46</time>
22
+ <contents><target name="magecommunity"><dir name="Iterable"><dir name="TrackOrderPlaced"><dir name="Helper"><file name="Data.php" hash="a6029c49149215655477fac0442b365f"/></dir><dir name="Model"><dir name="Email"><file name="Template.php" hash="225b9fb6b5eac3b506813bae86e1f005"/></dir><file name="Observer.php" hash="5b56d6eb53e09d317a4cc0e8b18a6d7b"/><file name="TrackingEventTypes.php" hash="b81614a3a0fcd67aee43a29093044261"/></dir><dir name="etc"><file name="config.xml" hash="fcfea5dfdb4a375516c4d5b4d8ab6684"/><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="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>