Version Notes
Enable new php version
Fixed wrong order info issue
Download this release
Release Info
Developer | aftership |
Extension | aftership |
Version | 0.3.3 |
Comparing to | |
See all releases |
Code changes from version 0.3.2 to 0.3.3
app/code/community/Aftership/Track/Model/Observer.php
CHANGED
@@ -38,6 +38,7 @@ class Aftership_Track_Model_Observer {
|
|
38 |
$order_id = $order_data["increment_id"];
|
39 |
}
|
40 |
|
|
|
41 |
$exist_track_data = Mage::getModel('track/track')
|
42 |
->getCollection()
|
43 |
->addFieldToFilter('tracking_number', array('eq' => $track_no))
|
@@ -48,10 +49,8 @@ class Aftership_Track_Model_Observer {
|
|
48 |
$track = Mage::getModel('track/track');
|
49 |
|
50 |
$track->setTrackingNumber($track_no);
|
51 |
-
|
52 |
$track->setShipCompCode($track_data["carrier_code"]);
|
53 |
$track->setTitle($order_data["increment_id"]);
|
54 |
-
|
55 |
$track->setOrderId($order_data["increment_id"]);
|
56 |
|
57 |
if ($order_data["customer_email"] && $order_data["customer_email"] != "") {
|
@@ -62,8 +61,17 @@ class Aftership_Track_Model_Observer {
|
|
62 |
$track->setTelephone($shipping_address_data["telephone"]);
|
63 |
}
|
64 |
|
|
|
65 |
if (array_key_exists("status", $config) && $config["status"]) {
|
66 |
$track->setPosted(0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
} else {
|
68 |
$track->setPosted(2);
|
69 |
}
|
@@ -71,51 +79,35 @@ class Aftership_Track_Model_Observer {
|
|
71 |
$track->save();
|
72 |
}
|
73 |
|
|
|
|
|
74 |
if (array_key_exists("status", $config) && $config["status"]) {
|
75 |
|
76 |
$api_key = $config["api_key"];
|
77 |
|
|
|
78 |
$post_tracks = Mage::getModel('track/track')
|
79 |
->getCollection()
|
80 |
->addFieldToFilter('posted', array('eq' => 0))
|
81 |
->getData();
|
82 |
|
83 |
-
$url_params = array("api_key" => $api_key . "");
|
84 |
|
85 |
foreach ($post_tracks as $track) {
|
86 |
|
87 |
-
|
88 |
-
$url_params["tracking_number"] = $track["tracking_number"];
|
89 |
-
$url_params["smses[]"] = $track["telephone"];
|
90 |
-
$url_params["emails[]"] = $track["email"];
|
91 |
-
$url_params["title"] = $track["title"];
|
92 |
-
$url_params["order_id"] = $track["order_id"];
|
93 |
-
$url_params["customer_name"] = $shipping_address_data["firstname"] . " " . $shipping_address_data['lastname'];
|
94 |
-
$url_params["source"] = "magento";
|
95 |
-
|
96 |
-
$url_params = http_build_query($url_params);
|
97 |
-
|
98 |
-
$ch = curl_init();
|
99 |
-
curl_setopt($ch, CURLOPT_URL, $url);
|
100 |
-
curl_setopt($ch, CURLOPT_POST, true);
|
101 |
-
curl_setopt($ch, CURLOPT_POSTFIELDS, $url_params);
|
102 |
-
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
103 |
-
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
|
104 |
-
//curl_setopt($ch, CURLOPT_HEADER, 0);
|
105 |
-
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
106 |
|
107 |
-
|
108 |
-
|
109 |
-
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); //the SSL is not correct
|
110 |
-
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Length: ' . strlen($url_params)));
|
111 |
|
112 |
-
$
|
113 |
|
114 |
-
|
115 |
-
$
|
116 |
-
|
|
|
|
|
117 |
|
118 |
-
$
|
119 |
|
120 |
//422: repeated
|
121 |
if ($http_status == "201" || $http_status == "422") {
|
@@ -124,19 +116,51 @@ class Aftership_Track_Model_Observer {
|
|
124 |
$track_obj->setPosted(1);
|
125 |
$track_obj->save();
|
126 |
}
|
127 |
-
|
128 |
-
//simulate track success post
|
129 |
-
/*$track_obj = Mage::getModel('track/track');
|
130 |
-
$track_obj->load($track["track_id"]);
|
131 |
-
$track_obj->setPosted(1);
|
132 |
-
$track_obj->save();*/
|
133 |
-
|
134 |
}
|
135 |
}
|
136 |
|
137 |
ob_end_clean();
|
138 |
}
|
139 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
140 |
public function adminSystemConfigChangedSectionAftership(Varien_Event_Observer $observer)
|
141 |
{
|
142 |
$post_data = Mage::app()->getRequest()->getPost();
|
@@ -161,9 +185,7 @@ class Aftership_Track_Model_Observer {
|
|
161 |
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
|
162 |
curl_setopt($ch, CURLOPT_HEADER, 0);
|
163 |
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
164 |
-
curl_setopt($ch,
|
165 |
-
//handle SSL certificate problem: unable to get local issuer certificate issue
|
166 |
-
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); //the SSL is not correct
|
167 |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); //the SSL is not correct
|
168 |
|
169 |
$response = curl_exec($ch);
|
38 |
$order_id = $order_data["increment_id"];
|
39 |
}
|
40 |
|
41 |
+
//save into db if the tracking number not exists
|
42 |
$exist_track_data = Mage::getModel('track/track')
|
43 |
->getCollection()
|
44 |
->addFieldToFilter('tracking_number', array('eq' => $track_no))
|
49 |
$track = Mage::getModel('track/track');
|
50 |
|
51 |
$track->setTrackingNumber($track_no);
|
|
|
52 |
$track->setShipCompCode($track_data["carrier_code"]);
|
53 |
$track->setTitle($order_data["increment_id"]);
|
|
|
54 |
$track->setOrderId($order_data["increment_id"]);
|
55 |
|
56 |
if ($order_data["customer_email"] && $order_data["customer_email"] != "") {
|
61 |
$track->setTelephone($shipping_address_data["telephone"]);
|
62 |
}
|
63 |
|
64 |
+
//if enabled the module, send to aftership
|
65 |
if (array_key_exists("status", $config) && $config["status"]) {
|
66 |
$track->setPosted(0);
|
67 |
+
|
68 |
+
$api_key = $config["api_key"];
|
69 |
+
$http_status = $this->sendTrackingRequest($api_key.'', $track_no, $shipping_address_data["telephone"], $order_data["customer_email"], $order_data["increment_id"], $order_data["increment_id"], $shipping_address_data["firstname"].' '.$shipping_address_data['lastname']);
|
70 |
+
|
71 |
+
//422: repeated
|
72 |
+
if ($http_status == "201" || $http_status == "422") {
|
73 |
+
$track->setPosted(1);
|
74 |
+
}
|
75 |
} else {
|
76 |
$track->setPosted(2);
|
77 |
}
|
79 |
$track->save();
|
80 |
}
|
81 |
|
82 |
+
|
83 |
+
//send old to aftership
|
84 |
if (array_key_exists("status", $config) && $config["status"]) {
|
85 |
|
86 |
$api_key = $config["api_key"];
|
87 |
|
88 |
+
//get all tracking numbers that not sent
|
89 |
$post_tracks = Mage::getModel('track/track')
|
90 |
->getCollection()
|
91 |
->addFieldToFilter('posted', array('eq' => 0))
|
92 |
->getData();
|
93 |
|
|
|
94 |
|
95 |
foreach ($post_tracks as $track) {
|
96 |
|
97 |
+
//echo 'tracking number: '.$track["tracking_number"].', order id: '.$track["order_id"]."\n";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
|
99 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($track["order_id"]);
|
100 |
+
$tracking_data = Mage::getResourceModel('sales/order_shipment_track_collection')->setOrderFilter($order);
|
|
|
|
|
101 |
|
102 |
+
$shipping_address = array();
|
103 |
|
104 |
+
//no matter how many tracking number in this order, the shipping detail is the same
|
105 |
+
foreach ($tracking_data as $track_detail) {
|
106 |
+
$shipping_address = $track_detail->getShipment()->getOrder()->getShippingAddress()->getData();
|
107 |
+
break;
|
108 |
+
}
|
109 |
|
110 |
+
$http_status = $this->sendTrackingRequest($api_key.'', $track["tracking_number"], $track["telephone"], $track["email"], $track["title"], $track["order_id"], $shipping_address["firstname"].' '.$shipping_address['lastname']);
|
111 |
|
112 |
//422: repeated
|
113 |
if ($http_status == "201" || $http_status == "422") {
|
116 |
$track_obj->setPosted(1);
|
117 |
$track_obj->save();
|
118 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
}
|
120 |
}
|
121 |
|
122 |
ob_end_clean();
|
123 |
}
|
124 |
|
125 |
+
public function sendTrackingRequest($api_key, $tracking_number, $telephone, $email, $title, $order_id, $customer_name) {
|
126 |
+
$url = self::ENDPOINT_TRACKING;
|
127 |
+
|
128 |
+
$url_params = array(
|
129 |
+
'api_key' => $api_key,
|
130 |
+
'tracking_number' => $tracking_number,
|
131 |
+
'smses[]' => $telephone,
|
132 |
+
'emails[]' => $email,
|
133 |
+
'title' => $title,
|
134 |
+
'order_id' => $order_id,
|
135 |
+
'customer_name' => $customer_name,
|
136 |
+
'source' => 'magento'
|
137 |
+
);
|
138 |
+
|
139 |
+
$url_params = http_build_query($url_params);
|
140 |
+
|
141 |
+
$ch = curl_init();
|
142 |
+
curl_setopt($ch, CURLOPT_URL, $url);
|
143 |
+
curl_setopt($ch, CURLOPT_POST, true);
|
144 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $url_params);
|
145 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
146 |
+
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
|
147 |
+
curl_setopt($ch, CURLOPT_HEADER, 0);
|
148 |
+
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
149 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); //handle SSL certificate problem: unable to get local issuer certificate issue
|
150 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); //the SSL is not correct
|
151 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Length: ' . strlen($url_params)));
|
152 |
+
|
153 |
+
$response = curl_exec($ch);
|
154 |
+
|
155 |
+
$http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
156 |
+
$error = curl_error($ch);
|
157 |
+
curl_close($ch);
|
158 |
+
|
159 |
+
$response_obj = json_decode($response, true);
|
160 |
+
|
161 |
+
return $http_status;
|
162 |
+
}
|
163 |
+
|
164 |
public function adminSystemConfigChangedSectionAftership(Varien_Event_Observer $observer)
|
165 |
{
|
166 |
$post_data = Mage::app()->getRequest()->getPost();
|
185 |
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
|
186 |
curl_setopt($ch, CURLOPT_HEADER, 0);
|
187 |
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
188 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); //handle SSL certificate problem: unable to get local issuer certificate issue
|
|
|
|
|
189 |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); //the SSL is not correct
|
190 |
|
191 |
$response = curl_exec($ch);
|
package.xml
CHANGED
@@ -1,18 +1,19 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>aftership</name>
|
4 |
-
<version>0.3.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.opensource.org/licenses/gpl-license.php">GPL</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>AfterShip magento extension interface. Tracking number will be added to the aftership.com <https://www.aftership.com/> account at the same time when input in magento shipment. Please go to aftership.com <https://www.aftership.com/> to change the notification setting and value.</summary>
|
10 |
<description>Users can simply link their online stores to Aftership and view all packages in one place. Online stores can also automatically inform their customers of the latest delivery status through SMS, email and Twitter. All the messages are white-labeled and can be customized for any marketing opportunities. Aftership also provides online stores a reporting tool so that they can easily find out any shipping problems like delayed delivery and solve immediately. Aftership currently supports over 40 shipping companies worldwide.</description>
|
11 |
-
<notes>Enable new php version
|
|
|
12 |
<authors><author><name>aftership</name><user>aftership</user><email>support@aftership.com</email></author></authors>
|
13 |
-
<date>
|
14 |
-
<time>
|
15 |
-
<contents><target name="magecommunity"><dir name="Aftership"><dir name="Track"><dir name="Helper"><file name="Data.php" hash="854baf793cb348f80c94703b585691b9"/></dir><dir name="Model"><file name="FrequencyWords.php" hash="91aad25bcba1c0f8433ab0f297f50614"/><file name="Methods.php" hash="ee6ccd73ab94405e8b0ab4a59990a0fa"/><dir name="Mysql4"><dir name="Track"><file name="Collection.php" hash="b359845af660063396556b37920675ad"/></dir><file name="Track.php" hash="e7799ea4fef0ff7e4217ae0d3a3ed50e"/></dir><file name="Observer.php" hash="
|
16 |
<compatible/>
|
17 |
-
<dependencies><required><php><min>5.2.13</min><max>5.
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>aftership</name>
|
4 |
+
<version>0.3.3</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.opensource.org/licenses/gpl-license.php">GPL</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>AfterShip magento extension interface. Tracking number will be added to the aftership.com <https://www.aftership.com/> account at the same time when input in magento shipment. Please go to aftership.com <https://www.aftership.com/> to change the notification setting and value.</summary>
|
10 |
<description>Users can simply link their online stores to Aftership and view all packages in one place. Online stores can also automatically inform their customers of the latest delivery status through SMS, email and Twitter. All the messages are white-labeled and can be customized for any marketing opportunities. Aftership also provides online stores a reporting tool so that they can easily find out any shipping problems like delayed delivery and solve immediately. Aftership currently supports over 40 shipping companies worldwide.</description>
|
11 |
+
<notes>Enable new php version
|
12 |
+
Fixed wrong order info issue</notes>
|
13 |
<authors><author><name>aftership</name><user>aftership</user><email>support@aftership.com</email></author></authors>
|
14 |
+
<date>2014-02-26</date>
|
15 |
+
<time>07:43:32</time>
|
16 |
+
<contents><target name="magecommunity"><dir name="Aftership"><dir name="Track"><dir name="Helper"><file name="Data.php" hash="854baf793cb348f80c94703b585691b9"/></dir><dir name="Model"><file name="FrequencyWords.php" hash="91aad25bcba1c0f8433ab0f297f50614"/><file name="Methods.php" hash="ee6ccd73ab94405e8b0ab4a59990a0fa"/><dir name="Mysql4"><dir name="Track"><file name="Collection.php" hash="b359845af660063396556b37920675ad"/></dir><file name="Track.php" hash="e7799ea4fef0ff7e4217ae0d3a3ed50e"/></dir><file name="Observer.php" hash="e794ec0b860827be47c6710da9518f15"/><dir name="Resource"><dir name="Mysql4"><file name="Setup.php" hash="9a1fee597d5f7219cd3f68f38bb1ed97"/></dir></dir><file name="Track.php" hash="61bae429d01ace637296e11994203fe5"/><file name="Words.php" hash="40d412b8ea57998ae6429219b14709db"/></dir><dir name="controllers"><file name="IndexController.php" hash="7f5c1ae52f625152ca3e9ffe15a93028"/></dir><dir name="etc"><file name="adminhtml.xml" hash="cadc113478c285edf9f43c7506f6ba89"/><file name="config.xml" hash="d93a3fa0764e4fde76f2a9065fcc40c9"/><file name="system.xml" hash="bfd83204df3be87132971d15fbef8607"/></dir><dir name="sql"><dir name="track_setup"><file name="mysql4-install-0.3.2.php" hash="7639b6303191813f78441a6d7297e0d1"/><file name="mysql4-upgrade-0.2.9-0.3.2.php" hash="7639b6303191813f78441a6d7297e0d1"/></dir></dir></dir></dir></target><target name="mage"><dir name="app"><dir name="etc"><dir name="modules"><file name="Aftership_Track.xml" hash="25367ce0ec0484973a73e5548199dea0"/></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="aftership"><dir name="css"><file name="style.css" hash="bd5df03e68aa767303eb392df394ce52"/></dir><dir name="images"><file name="logo.png" hash="3e8d8f9d5e1747c18fcd1a810ddc5f2a"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><file name=".DS_Store" hash="e8931b980e8ec084f41ef4f99eeef0c3"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="aftership.xml" hash="263c8bb1e2ba9acbf017a2a44fb11439"/></dir></dir></dir></dir></target></contents>
|
17 |
<compatible/>
|
18 |
+
<dependencies><required><php><min>5.2.13</min><max>5.6.0</max></php></required></dependencies>
|
19 |
</package>
|