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.3 |
| Comparing to | |
| See all releases | |
Code changes from version 1.4.2 to 1.4.3
- app/code/community/Iterable/TrackOrderPlaced/Helper/Data.php +7 -3
- app/code/community/Iterable/TrackOrderPlaced/Model/Observer.php +35 -0
- app/code/community/Iterable/TrackOrderPlaced/Model/TrackingEventTypes.php +3 -1
- app/code/community/Iterable/TrackOrderPlaced/etc/config.xml +10 -1
- package.xml +4 -4
app/code/community/Iterable/TrackOrderPlaced/Helper/Data.php
CHANGED
|
@@ -89,11 +89,11 @@ class Iterable_TrackOrderPlaced_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
| 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;
|
| 93 |
}
|
| 94 |
$apiKey = $this->getIterableApiToken();
|
| 95 |
if ($apiKey == NULL) {
|
| 96 |
-
return;
|
| 97 |
}
|
| 98 |
$url = "https://api.iterable.com/{$endpoint}?api_key={$apiKey}";
|
| 99 |
// $url = "http://localhost:9000{$endpoint}?api_key={$apiKey}";
|
|
@@ -101,7 +101,7 @@ class Iterable_TrackOrderPlaced_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
| 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;
|
| 105 |
}
|
| 106 |
$client->setMethod(Zend_Http_Client::POST);
|
| 107 |
// $client->setHeaders('Content-Type', 'application/json');
|
|
@@ -232,4 +232,8 @@ class Iterable_TrackOrderPlaced_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
| 232 |
}
|
| 233 |
return $this->callIterableApi(Iterable_TrackOrderPlaced_Model_TrackingEventTypes::EVENT_TYPE_TRIGGER_EMAIL, $endpoint, $params);
|
| 234 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 235 |
}
|
| 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}";
|
| 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);
|
| 107 |
// $client->setHeaders('Content-Type', 'application/json');
|
| 232 |
}
|
| 233 |
return $this->callIterableApi(Iterable_TrackOrderPlaced_Model_TrackingEventTypes::EVENT_TYPE_TRIGGER_EMAIL, $endpoint, $params);
|
| 234 |
}
|
| 235 |
+
|
| 236 |
+
public function trackShipment($email, $shipment) {
|
| 237 |
+
return $this->track(Iterable_TrackOrderPlaced_Model_TrackingEventTypes::EVENT_TYPE_SHIPMENT, $email, $shipment);
|
| 238 |
+
}
|
| 239 |
}
|
app/code/community/Iterable/TrackOrderPlaced/Model/Observer.php
CHANGED
|
@@ -447,4 +447,39 @@ class Iterable_TrackOrderPlaced_Model_Observer
|
|
| 447 |
}
|
| 448 |
}
|
| 449 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 450 |
}
|
| 447 |
}
|
| 448 |
}
|
| 449 |
|
| 450 |
+
public function shipmentSaveAfter($observer)
|
| 451 |
+
{
|
| 452 |
+
$shipment = $observer->getEvent()->getShipment();
|
| 453 |
+
|
| 454 |
+
$trackingData = array();
|
| 455 |
+
$tracks = $shipment->getAllTracks();
|
| 456 |
+
foreach ($tracks as $track) {
|
| 457 |
+
$trackingData[] = $track->getData();
|
| 458 |
+
}
|
| 459 |
+
|
| 460 |
+
$comments = array();
|
| 461 |
+
$commentsCollection = $shipment->getCommentsCollection();
|
| 462 |
+
foreach ($commentsCollection as $comment) {
|
| 463 |
+
$comments[] = $comment->getData();
|
| 464 |
+
}
|
| 465 |
+
|
| 466 |
+
$items = array();
|
| 467 |
+
foreach ($shipment->getAllItems() as $item) {
|
| 468 |
+
$items[] = $item->getData();
|
| 469 |
+
}
|
| 470 |
+
|
| 471 |
+
$shipmentData = array(
|
| 472 |
+
"tracking" => $trackingData,
|
| 473 |
+
"comments" => $comments,
|
| 474 |
+
"billingAddress" => $shipment->getBillingAddress()->getData(),
|
| 475 |
+
"shippingAddress" => $shipment->getShippingAddress()->getData(),
|
| 476 |
+
"shippingDescription" => $shipment->getOrder()->getShippingDescription(),
|
| 477 |
+
"items" => $items
|
| 478 |
+
);
|
| 479 |
+
|
| 480 |
+
$email = $shipment->getOrder()->getCustomerEmail();
|
| 481 |
+
|
| 482 |
+
$helper = Mage::helper('trackorderplaced');
|
| 483 |
+
$helper->trackShipment($email, $shipmentData);
|
| 484 |
+
}
|
| 485 |
}
|
app/code/community/Iterable/TrackOrderPlaced/Model/TrackingEventTypes.php
CHANGED
|
@@ -9,6 +9,7 @@ class Iterable_TrackOrderPlaced_Model_TrackingEventTypes
|
|
| 9 |
const EVENT_TYPE_NEWSLETTER_SUBSCRIBE = 'newsletterSubscribe';
|
| 10 |
const EVENT_TYPE_NEWSLETTER_UNSUBSCRIBE = 'newsletterUnsubscribe';
|
| 11 |
const EVENT_TYPE_TRIGGER_EMAIL = 'triggerEmail';
|
|
|
|
| 12 |
|
| 13 |
/** @const */
|
| 14 |
private static $eventTypes = array(
|
|
@@ -17,7 +18,8 @@ class Iterable_TrackOrderPlaced_Model_TrackingEventTypes
|
|
| 17 |
self::EVENT_TYPE_CART_UPDATED => 'Cart Updated',
|
| 18 |
self::EVENT_TYPE_NEWSLETTER_SUBSCRIBE => 'Newsletter Subscribe',
|
| 19 |
self::EVENT_TYPE_NEWSLETTER_UNSUBSCRIBE => 'Newsletter Unsubscribe',
|
| 20 |
-
self::EVENT_TYPE_TRIGGER_EMAIL => 'Trigger Email'
|
|
|
|
| 21 |
);
|
| 22 |
|
| 23 |
public function toOptionArray()
|
| 9 |
const EVENT_TYPE_NEWSLETTER_SUBSCRIBE = 'newsletterSubscribe';
|
| 10 |
const EVENT_TYPE_NEWSLETTER_UNSUBSCRIBE = 'newsletterUnsubscribe';
|
| 11 |
const EVENT_TYPE_TRIGGER_EMAIL = 'triggerEmail';
|
| 12 |
+
const EVENT_TYPE_SHIPMENT = 'shipment';
|
| 13 |
|
| 14 |
/** @const */
|
| 15 |
private static $eventTypes = array(
|
| 18 |
self::EVENT_TYPE_CART_UPDATED => 'Cart Updated',
|
| 19 |
self::EVENT_TYPE_NEWSLETTER_SUBSCRIBE => 'Newsletter Subscribe',
|
| 20 |
self::EVENT_TYPE_NEWSLETTER_UNSUBSCRIBE => 'Newsletter Unsubscribe',
|
| 21 |
+
self::EVENT_TYPE_TRIGGER_EMAIL => 'Trigger Email',
|
| 22 |
+
self::EVENT_TYPE_SHIPMENT => 'Shipment'
|
| 23 |
);
|
| 24 |
|
| 25 |
public function toOptionArray()
|
app/code/community/Iterable/TrackOrderPlaced/etc/config.xml
CHANGED
|
@@ -167,6 +167,15 @@
|
|
| 167 |
</iterable_tracknewslettersubscribe>
|
| 168 |
</observers>
|
| 169 |
</newsletter_subscriber_save_after>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
</events>
|
| 171 |
</global>
|
| 172 |
|
|
@@ -178,7 +187,7 @@
|
|
| 178 |
</api_options>
|
| 179 |
<advanced_options>
|
| 180 |
<tracking_options>
|
| 181 |
-
<enabled_events>order,user,cartUpdated,newsletterSubscribe,newsletterUnsubscribe,triggerEmail</enabled_events>
|
| 182 |
</tracking_options>
|
| 183 |
</advanced_options>
|
| 184 |
</default>
|
| 167 |
</iterable_tracknewslettersubscribe>
|
| 168 |
</observers>
|
| 169 |
</newsletter_subscriber_save_after>
|
| 170 |
+
<sales_order_shipment_save_after>
|
| 171 |
+
<observers>
|
| 172 |
+
<iterable_trackshipmentsaved>
|
| 173 |
+
<class>iterable_trackorderplaced/observer</class>
|
| 174 |
+
<method>shipmentSaveAfter</method>
|
| 175 |
+
<type>singleton</type>
|
| 176 |
+
</iterable_trackshipmentsaved>
|
| 177 |
+
</observers>
|
| 178 |
+
</sales_order_shipment_save_after>
|
| 179 |
</events>
|
| 180 |
</global>
|
| 181 |
|
| 187 |
</api_options>
|
| 188 |
<advanced_options>
|
| 189 |
<tracking_options>
|
| 190 |
+
<enabled_events>order,user,cartUpdated,newsletterSubscribe,newsletterUnsubscribe,triggerEmail,shipment</enabled_events>
|
| 191 |
</tracking_options>
|
| 192 |
</advanced_options>
|
| 193 |
</default>
|
package.xml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Iterable_Plugin</name>
|
| 4 |
-
<version>1.4.
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://opensource.org/licenses/OSL-3.0">Open Software License (OSL) </license>
|
| 7 |
<channel>community</channel>
|
|
@@ -17,9 +17,9 @@ To install, click the 'Install Now' button above and paste the link into your Ma
|
|
| 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-
|
| 21 |
-
<time>
|
| 22 |
-
<contents><target name="magecommunity"><dir name="Iterable"><dir name="TrackOrderPlaced"><dir name="Helper"><file name="Data.php" hash="
|
| 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.3</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://opensource.org/licenses/OSL-3.0">Open Software License (OSL) </license>
|
| 7 |
<channel>community</channel>
|
| 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-08</date>
|
| 21 |
+
<time>00:25:29</time>
|
| 22 |
+
<contents><target name="magecommunity"><dir name="Iterable"><dir name="TrackOrderPlaced"><dir name="Helper"><file name="Data.php" hash="ca07dd598f7a2b8b625ab89d9a52024b"/></dir><dir name="Model"><dir name="Email"><file name="Template.php" hash="225b9fb6b5eac3b506813bae86e1f005"/></dir><file name="Observer.php" hash="f9c4ba566ec7418d8ac76dfc73cfc8b4"/><file name="TrackingEventTypes.php" hash="69088c4683284b176b9ec2978d7db472"/></dir><dir name="etc"><file name="config.xml" hash="8d56ea84ef08ec66ab1f451e923032dd"/><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>
|
