Version Notes
Fixed minor bugs
Support V2
Download this release
Release Info
Developer | aftership |
Extension | aftership |
Version | 0.1.13 |
Comparing to | |
See all releases |
Code changes from version 0.1.11 to 0.1.13
app/code/community/Aftership/Track/Model/Observer.php
CHANGED
@@ -2,174 +2,170 @@
|
|
2 |
|
3 |
class Aftership_Track_Model_Observer
|
4 |
{
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
}
|
172 |
-
|
173 |
-
}
|
174 |
-
}
|
175 |
}
|
2 |
|
3 |
class Aftership_Track_Model_Observer
|
4 |
{
|
5 |
+
public function salesOrderShipmentTrackSaveAfter(Varien_Event_Observer $observer)
|
6 |
+
{
|
7 |
+
ob_start();
|
8 |
+
$config = Mage::getStoreConfig('aftership_options/messages');
|
9 |
+
|
10 |
+
/*if(array_key_exists("notification",$config)){
|
11 |
+
$notifications = explode(",",$config["notification"]);
|
12 |
+
if(array_search("1",$notifications)!==False){ // email
|
13 |
+
$is_notify_email = true;
|
14 |
+
}else{
|
15 |
+
$is_notify_email = false;
|
16 |
+
}
|
17 |
+
if(array_search("2",$notifications)!==False){ // sms
|
18 |
+
$is_notify_sms = true;
|
19 |
+
}else{
|
20 |
+
$is_notify_sms = false;
|
21 |
+
}
|
22 |
+
}else{
|
23 |
+
$is_notify_email = false;
|
24 |
+
$is_notify_sms = false;
|
25 |
+
}*/
|
26 |
+
|
27 |
+
$track = $observer->getEvent()->getTrack();
|
28 |
+
$track_data = $track->getData();
|
29 |
+
$order_data = $track->getShipment()->getOrder()->getData();
|
30 |
+
$shipment_data = $track->getShipment()->getData();
|
31 |
+
$shipping_address_data = $track->getShipment()->getOrder()->getShippingAddress()->getData();
|
32 |
+
if (strlen(trim($track_data["track_number"])) > 0) {
|
33 |
+
//1.6.2.0 or later
|
34 |
+
$track_no = trim($track_data["track_number"]);
|
35 |
+
} else {
|
36 |
+
//1.5.1.0
|
37 |
+
$track_no = trim($track_data["number"]);
|
38 |
+
}
|
39 |
+
|
40 |
+
$exist_track_data = Mage::getModel('track/track')
|
41 |
+
->getCollection()
|
42 |
+
->addFieldToFilter('tracking_number', array('eq' => $track_no))
|
43 |
+
->addFieldToFilter('order_id', array('eq' => $order_data["order_id"]))
|
44 |
+
->getData();
|
45 |
+
|
46 |
+
if (!$exist_track_data) {
|
47 |
+
$track = Mage::getModel('track/track');
|
48 |
+
|
49 |
+
|
50 |
+
$track->setTrackingNumber($track_no);
|
51 |
+
|
52 |
+
$track->setShipCompCode($track_data["carrier_code"]);
|
53 |
+
//$track->setTitle($_SERVER['HTTP_HOST'] . " " . $order_data["increment_id"]);
|
54 |
+
//$track->setTitle($_SERVER['HTTP_ORIGIN'] . " " . $order_data["increment_id"]);
|
55 |
+
$track->setTitle($order_data["increment_id"]);
|
56 |
+
|
57 |
+
$track->setOrderId($order_data["increment_id"]);
|
58 |
+
|
59 |
+
if ($order_data["customer_email"] && $order_data["customer_email"] != "") {
|
60 |
+
$track->setEmail($order_data["customer_email"]);
|
61 |
+
}
|
62 |
+
|
63 |
+
if ($shipping_address_data["telephone"] && $shipping_address_data["telephone"] != "") {
|
64 |
+
$track->setTelephone($shipping_address_data["telephone"]);
|
65 |
+
}
|
66 |
+
|
67 |
+
/*
|
68 |
+
if($is_notify_email){
|
69 |
+
$track->setEmail($order_data["customer_email"]);
|
70 |
+
}
|
71 |
+
|
72 |
+
if($is_notify_sms){
|
73 |
+
$track->setTelephone($shipping_address_data["telephone"]);
|
74 |
+
}*/
|
75 |
+
|
76 |
+
|
77 |
+
if (array_key_exists("status", $config) && $config["status"]) {
|
78 |
+
$track->setPosted(0);
|
79 |
+
} else {
|
80 |
+
$track->setPosted(2);
|
81 |
+
}
|
82 |
+
|
83 |
+
$track->save();
|
84 |
+
}
|
85 |
+
|
86 |
+
if (array_key_exists("status", $config) && $config["status"]) {
|
87 |
+
$api_key = $config["api_key"];
|
88 |
+
|
89 |
+
$post_tracks = Mage::getModel('track/track')
|
90 |
+
->getCollection()
|
91 |
+
->addFieldToFilter('posted', array('eq' => 0))
|
92 |
+
->getData();
|
93 |
+
|
94 |
+
$url_params = array("api_key" => $api_key);
|
95 |
+
foreach ($post_tracks as $track) {
|
96 |
+
$url = "https://api.aftership.com/v1/trackings";
|
97 |
+
$url_params["tracking_number"] = $track["tracking_number"];
|
98 |
+
$url_params["smses"] = array($track["telephone"]);
|
99 |
+
$url_params["emails"] = array($track["email"]);
|
100 |
+
$url_params["title"] = $track["title"];
|
101 |
+
$url_params["order_id"] = $track["order_id"];
|
102 |
+
|
103 |
+
$ch = curl_init();
|
104 |
+
curl_setopt($ch, CURLOPT_URL, $url);
|
105 |
+
|
106 |
+
curl_setopt($ch, CURLOPT_POST, true);
|
107 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($url_params));
|
108 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
109 |
+
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
|
110 |
+
curl_setopt($ch, CURLOPT_HEADER, 0);
|
111 |
+
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
112 |
+
|
113 |
+
$response = curl_exec($ch);
|
114 |
+
$http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
115 |
+
$error = curl_error($ch);
|
116 |
+
curl_close($ch);
|
117 |
+
$response_obj = json_decode($response, true);
|
118 |
+
|
119 |
+
if ($http_status == "201") {
|
120 |
+
$track_obj = Mage::getModel('track/track');
|
121 |
+
$track_obj->load($track["track_id"]);
|
122 |
+
$track_obj->setPosted(1);
|
123 |
+
$track_obj->save();
|
124 |
+
} else {
|
125 |
+
|
126 |
+
}
|
127 |
+
}
|
128 |
+
}
|
129 |
+
}
|
130 |
+
|
131 |
+
public function adminSystemConfigChangedSectionAftership($obj)
|
132 |
+
{
|
133 |
+
$post_data = Mage::app()->getRequest()->getPost();
|
134 |
+
$api_key = $post_data["groups"]["messages"]["fields"]["api_key"]["value"];
|
135 |
+
if (!array_key_exists("notification", $post_data["groups"]["messages"]["fields"])) {
|
136 |
+
Mage::getModel('core/config')->saveConfig('aftership_options/messages/notification', 0);
|
137 |
+
}
|
138 |
+
|
139 |
+
$url_params = array(
|
140 |
+
"api_key" => $api_key
|
141 |
+
);
|
142 |
+
$url = "http://api.aftership.com/v1/users/authenticate";
|
143 |
+
|
144 |
+
$ch = curl_init();
|
145 |
+
curl_setopt($ch, CURLOPT_URL, $url);
|
146 |
+
curl_setopt($ch, CURLOPT_POST, true);
|
147 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($url_params));
|
148 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
149 |
+
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
|
150 |
+
curl_setopt($ch, CURLOPT_HEADER, 0);
|
151 |
+
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
152 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
153 |
+
|
154 |
+
$response = curl_exec($ch);
|
155 |
+
$error = curl_error($ch);
|
156 |
+
$http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
157 |
+
curl_close($ch);
|
158 |
+
$response_obj = json_decode($response, true);
|
159 |
+
|
160 |
+
if ($http_status != "200" && $http_status != "401") {
|
161 |
+
Mage::getModel('core/config')->saveConfig('aftership_options/messages/status', 0);
|
162 |
+
Mage::throwException(Mage::helper('adminhtml')->__("Connection error, please try again later."));
|
163 |
+
} else {
|
164 |
+
if (!$response_obj["success"]) //error
|
165 |
+
{
|
166 |
+
Mage::getModel('core/config')->saveConfig('aftership_options/messages/status', 0);
|
167 |
+
Mage::throwException(Mage::helper('adminhtml')->__("Incorrect API Key"));
|
168 |
+
}
|
169 |
+
}
|
170 |
+
}
|
|
|
|
|
|
|
|
|
171 |
}
|
app/code/community/Aftership/Track/controllers/IndexController.php
CHANGED
@@ -2,28 +2,6 @@
|
|
2 |
class Aftership_Track_IndexController extends Mage_Core_Controller_Front_Action {
|
3 |
|
4 |
public function indexAction() {
|
5 |
-
|
6 |
-
echo 'Hello Index!';
|
7 |
-
|
8 |
-
}
|
9 |
-
|
10 |
-
public function goodbyeAction() {
|
11 |
-
echo 'Goodbye World!';
|
12 |
-
}
|
13 |
-
|
14 |
-
public function testModelAction() {
|
15 |
-
$params = $this->getRequest()->getParams();
|
16 |
-
$blogpost = Mage::getModel('track/user');
|
17 |
-
echo("Loading the blogpost with an ID of ".$params['id']);
|
18 |
-
$blogpost->load($params['id']);
|
19 |
-
$data = $blogpost->getData();
|
20 |
-
var_dump($data);
|
21 |
-
|
22 |
-
$blogpost = Mage::getModel('track/track');
|
23 |
-
echo("Loading the blogpost with an ID of ".$params['id']);
|
24 |
-
$blogpost->load($params['id']);
|
25 |
-
$data = $blogpost->getData();
|
26 |
-
var_dump($data);
|
27 |
}
|
28 |
}
|
29 |
?>
|
2 |
class Aftership_Track_IndexController extends Mage_Core_Controller_Front_Action {
|
3 |
|
4 |
public function indexAction() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
}
|
6 |
}
|
7 |
?>
|
app/code/community/Aftership/Track/etc/system.xml
CHANGED
@@ -23,23 +23,15 @@
|
|
23 |
<show_in_website>1</show_in_website>
|
24 |
<show_in_store>1</show_in_store>
|
25 |
<fields>
|
26 |
-
<
|
27 |
-
<label>
|
28 |
<frontend_type>text</frontend_type>
|
29 |
<sort_order>10</sort_order>
|
30 |
<show_in_default>1</show_in_default>
|
31 |
<show_in_website>1</show_in_website>
|
32 |
<show_in_store>0</show_in_store>
|
33 |
-
<comment>You can find your
|
34 |
-
</
|
35 |
-
<consumer_secret>
|
36 |
-
<label>Consumer secret</label>
|
37 |
-
<frontend_type>text</frontend_type>
|
38 |
-
<sort_order>20</sort_order>
|
39 |
-
<show_in_default>1</show_in_default>
|
40 |
-
<show_in_website>1</show_in_website>
|
41 |
-
<show_in_store>0</show_in_store>
|
42 |
-
</consumer_secret>
|
43 |
<status>
|
44 |
<label>Status</label>
|
45 |
<frontend_type>Select</frontend_type>
|
23 |
<show_in_website>1</show_in_website>
|
24 |
<show_in_store>1</show_in_store>
|
25 |
<fields>
|
26 |
+
<api_key>
|
27 |
+
<label>API key</label>
|
28 |
<frontend_type>text</frontend_type>
|
29 |
<sort_order>10</sort_order>
|
30 |
<show_in_default>1</show_in_default>
|
31 |
<show_in_website>1</show_in_website>
|
32 |
<show_in_store>0</show_in_store>
|
33 |
+
<comment>You can find your API key in <![CDATA[<a target='_blank' href="https://www.aftership.com/connect/magento">https://www.aftership.com/connect/magento</a>]]></comment>
|
34 |
+
</api_key>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
<status>
|
36 |
<label>Status</label>
|
37 |
<frontend_type>Select</frontend_type>
|
app/code/community/Aftership/Track/sql/track_setup/mysql4-install-0.1.0.php
CHANGED
@@ -12,6 +12,7 @@ CREATE TABLE `{$installer->getTable('track/track')}` (
|
|
12 |
`telephone` varchar(255) NOT NULL,
|
13 |
`title` varchar(255) NOT NULL,
|
14 |
`posted` int(11) NOT NULL DEFAULT '0',
|
|
|
15 |
PRIMARY KEY (`track_id`),
|
16 |
KEY `posted` (`posted`)
|
17 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
|
12 |
`telephone` varchar(255) NOT NULL,
|
13 |
`title` varchar(255) NOT NULL,
|
14 |
`posted` int(11) NOT NULL DEFAULT '0',
|
15 |
+
`order_id` varchar(255) NOT NULL,
|
16 |
PRIMARY KEY (`track_id`),
|
17 |
KEY `posted` (`posted`)
|
18 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
|
package.xml
CHANGED
@@ -1,18 +1,25 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>aftership</name>
|
4 |
-
<version>0.1.
|
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
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
<authors><author><name>aftership</name><user>aftership</user><email>support@aftership.com</email></author></authors>
|
13 |
-
<date>2012-
|
14 |
-
<time>
|
15 |
-
<contents><target name="magecommunity"><dir name="Aftership"><dir name="Track"><dir name="Helper"><file name="Data.php" hash="970d03deb3e5fc478f5d86e5ff3670cb"/></dir><dir name="Model"><file name="Methods.php" hash="d9fa7ef3df0353c01662ff4bdf210f60"/><dir name="Mysql4"><dir name="Track"><file name="Collection.php" hash="336c4b0fba8db78e1222da01aa8c5744"/></dir><file name="Track.php" hash="90ad226fa98576fceb223b85fe88b642"/></dir><file name="Observer.php" hash="
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.2.17</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>aftership</name>
|
4 |
+
<version>0.1.13</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 http://aftership.com/
|
10 |
+
account at the same time when input in magento shipment. Please go to aftership.com http://aftership.com/
|
11 |
+
to change the notification setting and value.</summary>
|
12 |
+
<description>Users can simply link their online stores to Aftership and view all packages in one place. Online
|
13 |
+
stores can also automatically inform their customers of the latest delivery status through SMS, email and
|
14 |
+
Twitter. All the messages are white-labeled and can be customized for any marketing opportunities. Aftership
|
15 |
+
also provides online stores a reporting tool so that they can easily find out any shipping problems like delayed
|
16 |
+
delivery and solve immediately. Aftership currently supports over 40 shipping companies worldwide.</description>
|
17 |
+
<notes>Fixed minor bugs
|
18 |
+
Support V2</notes>
|
19 |
<authors><author><name>aftership</name><user>aftership</user><email>support@aftership.com</email></author></authors>
|
20 |
+
<date>2012-09-12</date>
|
21 |
+
<time>23:47:38</time>
|
22 |
+
<contents><target name="magecommunity"><dir><dir name="Aftership"><dir name="Track"><dir name="Helper"><file name="Data.php" hash="970d03deb3e5fc478f5d86e5ff3670cb"/></dir><dir name="Model"><file name="Methods.php" hash="d9fa7ef3df0353c01662ff4bdf210f60"/><dir name="Mysql4"><dir name="Track"><file name="Collection.php" hash="336c4b0fba8db78e1222da01aa8c5744"/></dir><file name="Track.php" hash="90ad226fa98576fceb223b85fe88b642"/></dir><file name="Observer.php" hash="b5693ae8421cad1dab5254247522b0a2"/><dir name="Resource"><dir name="Mysql4"><file name="Setup.php" hash="b53f65ecc832752c8394f0da74b2f90d"/></dir></dir><file name="Track.php" hash="eb12833d5f084b0b919cbde45f8170eb"/><file name="Words.php" hash="7789e47b991f718fb3097b5e274eb71f"/></dir><dir name="controllers"><file name="IndexController.php" hash="3ee34f42957e816ff336f8f8215a218b"/></dir><dir name="etc"><file name="config.xml" hash="44b407dcd58774176a2a37191daf04a2"/><file name="system.xml" hash="857fa4fae0433c10ba468bff794ca9ef"/></dir><dir name="sql"><dir name="track_setup"><file name="mysql4-install-0.1.0.php" hash="a8f81083585c85a89e8a3097f5f3045c"/></dir></dir></dir></dir></dir></target><target name="mage"><dir><dir name="app"><dir name="etc"><dir name="modules"><file name="Aftership_Track.xml" hash="6518f61d8f390f4fc8a517b2b15b01d1"/></dir></dir></dir></dir></target></contents>
|
23 |
<compatible/>
|
24 |
<dependencies><required><php><min>5.2.17</min><max>6.0.0</max></php></required></dependencies>
|
25 |
</package>
|