Version Notes
Fixed minor bugs
Download this release
Release Info
Developer | aftership |
Extension | aftership |
Version | 0.1.8 |
Comparing to | |
See all releases |
Code changes from version 0.1.7 to 0.1.8
app/code/community/Aftership/Track/Model/Observer.php
CHANGED
@@ -1,104 +1,103 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
class Aftership_Track_Model_Observer
|
4 |
{
|
5 |
public function salesOrderShipmentTrackSaveAfter(Varien_Event_Observer $observer)
|
6 |
{
|
7 |
$config = Mage::getStoreConfig('aftership_options/messages');
|
8 |
-
|
9 |
/*if(array_key_exists("notification",$config)){
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
$track = $observer->getEvent()->getTrack();
|
27 |
$track_data = $track->getData();
|
28 |
$order_data = $track->getShipment()->getOrder()->getData();
|
29 |
$shipment_data = $track->getShipment()->getData();
|
30 |
$shipping_address_data = $track->getShipment()->getOrder()->getShippingAddress()->getData();
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
$exist_track_data = Mage::getModel('track/track')
|
33 |
->getCollection()
|
34 |
-
->addFieldToFilter('tracking_number',array('eq'
|
35 |
->getData();
|
36 |
|
37 |
-
if(!$exist_track_data){
|
38 |
$track = Mage::getModel('track/track');
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
//1.6.2.0 or later
|
43 |
-
$track->setTrackingNumber(trim($track_data["track_number"]));
|
44 |
-
}
|
45 |
-
else
|
46 |
-
{
|
47 |
-
//1.5.1.0
|
48 |
-
$track->setTrackingNumber(trim($track_data["number"]));
|
49 |
-
}
|
50 |
|
51 |
$track->setShipCompCode($track_data["carrier_code"]);
|
52 |
//$track->setTitle($_SERVER['HTTP_HOST'] . " " . $order_data["increment_id"]);
|
53 |
//$track->setTitle($_SERVER['HTTP_ORIGIN'] . " " . $order_data["increment_id"]);
|
54 |
$track->setTitle($order_data["increment_id"]);
|
55 |
|
56 |
-
if ($order_data["customer_email"] && $order_data["customer_email"] != "")
|
57 |
-
{
|
58 |
$track->setEmail($order_data["customer_email"]);
|
59 |
}
|
60 |
|
61 |
-
if ($shipping_address_data["telephone"] && $shipping_address_data["telephone"] != "")
|
62 |
-
{
|
63 |
$track->setTelephone($shipping_address_data["telephone"]);
|
64 |
}
|
65 |
|
66 |
/*
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
|
75 |
|
76 |
-
if(array_key_exists("status"
|
77 |
$track->setPosted(0);
|
78 |
-
}else{
|
79 |
$track->setPosted(2);
|
80 |
}
|
81 |
$track->save();
|
82 |
}
|
83 |
-
|
84 |
-
if(array_key_exists("status"
|
85 |
$consumer_key = $config["consumer_key"];
|
86 |
$consumer_secret = $config["consumer_secret"];
|
87 |
-
|
88 |
$post_tracks = Mage::getModel('track/track')
|
89 |
->getCollection()
|
90 |
-
->addFieldToFilter('posted',array('eq'=>0))
|
91 |
->getData();
|
92 |
-
|
93 |
-
$url_params = array("consumer_key"
|
94 |
-
|
95 |
-
|
96 |
-
foreach($post_tracks as $track){
|
97 |
$url = "http://www.aftership.com/api/v1/add-tracking/?";
|
98 |
-
$url_params["tracking_number"]
|
99 |
-
$url_params["mobile"]
|
100 |
-
$url_params["email"]
|
101 |
-
$url_params["title"]
|
102 |
$url .= http_build_query($url_params);
|
103 |
|
104 |
$ch = curl_init();
|
@@ -107,38 +106,38 @@ class Aftership_Track_Model_Observer
|
|
107 |
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
|
108 |
curl_setopt($ch, CURLOPT_HEADER, 0);
|
109 |
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
110 |
-
|
111 |
$response = curl_exec($ch);
|
112 |
$error = curl_error($ch);
|
113 |
curl_close($ch);
|
114 |
$response_obj = json_decode($response);
|
115 |
-
|
116 |
-
if(property_exists($response_obj,"message")){
|
117 |
-
if($response_obj->message=="OK"){
|
118 |
$track_obj = Mage::getModel('track/track');
|
119 |
$track_obj->load($track["track_id"]);
|
120 |
$track_obj->setPosted(1);
|
121 |
$track_obj->save();
|
122 |
}
|
123 |
-
}else{
|
124 |
//fail
|
125 |
}
|
126 |
}
|
127 |
}
|
128 |
}
|
129 |
-
|
130 |
public function adminSystemConfigChangedSectionAftership($obj)
|
131 |
{
|
132 |
$post_data = Mage::app()->getRequest()->getPost();
|
133 |
$consumer_key = $post_data["groups"]["messages"]["fields"]["consumer_key"]["value"];
|
134 |
$consumer_secret = $post_data["groups"]["messages"]["fields"]["consumer_secret"]["value"];
|
135 |
-
if(!array_key_exists("notification"
|
136 |
-
Mage::getModel('core/config')->saveConfig('aftership_options/messages/notification', 0
|
137 |
}
|
138 |
-
|
139 |
-
$url_params = array("consumer_key"
|
140 |
-
|
141 |
-
|
142 |
$url = "http://www.aftership.com/api/v1/user-detail/?";
|
143 |
$url .= http_build_query($url_params);
|
144 |
|
@@ -148,20 +147,20 @@ class Aftership_Track_Model_Observer
|
|
148 |
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
|
149 |
curl_setopt($ch, CURLOPT_HEADER, 0);
|
150 |
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
151 |
-
|
152 |
$response = curl_exec($ch);
|
153 |
$error = curl_error($ch);
|
154 |
curl_close($ch);
|
155 |
$response_obj = json_decode($response);
|
156 |
-
|
157 |
-
if(!property_exists($response_obj,"twitter_screen_name")){
|
158 |
-
Mage::getModel('core/config')->saveConfig('aftership_options/messages/status', 0
|
159 |
-
if($error){
|
160 |
Mage::throwException(Mage::helper('adminhtml')->__($error));
|
161 |
-
}else{
|
162 |
Mage::throwException(Mage::helper('adminhtml')->__($response_obj->error));
|
163 |
}
|
164 |
-
}else{
|
165 |
// success
|
166 |
}
|
167 |
}
|
1 |
<?php
|
2 |
+
|
3 |
class Aftership_Track_Model_Observer
|
4 |
{
|
5 |
public function salesOrderShipmentTrackSaveAfter(Varien_Event_Observer $observer)
|
6 |
{
|
7 |
$config = Mage::getStoreConfig('aftership_options/messages');
|
8 |
+
|
9 |
/*if(array_key_exists("notification",$config)){
|
10 |
+
$notifications = explode(",",$config["notification"]);
|
11 |
+
if(array_search("1",$notifications)!==False){ // email
|
12 |
+
$is_notify_email = true;
|
13 |
+
}else{
|
14 |
+
$is_notify_email = false;
|
15 |
+
}
|
16 |
+
if(array_search("2",$notifications)!==False){ // sms
|
17 |
+
$is_notify_sms = true;
|
18 |
+
}else{
|
19 |
+
$is_notify_sms = false;
|
20 |
+
}
|
21 |
+
}else{
|
22 |
+
$is_notify_email = false;
|
23 |
+
$is_notify_sms = false;
|
24 |
+
}*/
|
25 |
+
|
26 |
$track = $observer->getEvent()->getTrack();
|
27 |
$track_data = $track->getData();
|
28 |
$order_data = $track->getShipment()->getOrder()->getData();
|
29 |
$shipment_data = $track->getShipment()->getData();
|
30 |
$shipping_address_data = $track->getShipment()->getOrder()->getShippingAddress()->getData();
|
31 |
+
|
32 |
+
|
33 |
+
if (strlen(trim($track_data["track_number"])) > 0) {
|
34 |
+
//1.6.2.0 or later
|
35 |
+
$track_no = trim($track_data["track_number"]);
|
36 |
+
} else {
|
37 |
+
//1.5.1.0
|
38 |
+
$track_no = trim($track_data["number"]);
|
39 |
+
}
|
40 |
+
|
41 |
$exist_track_data = Mage::getModel('track/track')
|
42 |
->getCollection()
|
43 |
+
->addFieldToFilter('tracking_number', array('eq' => $track_no))
|
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 |
+
if ($order_data["customer_email"] && $order_data["customer_email"] != "") {
|
|
|
58 |
$track->setEmail($order_data["customer_email"]);
|
59 |
}
|
60 |
|
61 |
+
if ($shipping_address_data["telephone"] && $shipping_address_data["telephone"] != "") {
|
|
|
62 |
$track->setTelephone($shipping_address_data["telephone"]);
|
63 |
}
|
64 |
|
65 |
/*
|
66 |
+
if($is_notify_email){
|
67 |
+
$track->setEmail($order_data["customer_email"]);
|
68 |
+
}
|
69 |
|
70 |
+
if($is_notify_sms){
|
71 |
+
$track->setTelephone($shipping_address_data["telephone"]);
|
72 |
+
}*/
|
73 |
|
74 |
|
75 |
+
if (array_key_exists("status", $config) && $config["status"]) {
|
76 |
$track->setPosted(0);
|
77 |
+
} else {
|
78 |
$track->setPosted(2);
|
79 |
}
|
80 |
$track->save();
|
81 |
}
|
82 |
+
|
83 |
+
if (array_key_exists("status", $config) && $config["status"]) {
|
84 |
$consumer_key = $config["consumer_key"];
|
85 |
$consumer_secret = $config["consumer_secret"];
|
86 |
+
|
87 |
$post_tracks = Mage::getModel('track/track')
|
88 |
->getCollection()
|
89 |
+
->addFieldToFilter('posted', array('eq' => 0))
|
90 |
->getData();
|
91 |
+
|
92 |
+
$url_params = array("consumer_key" => $consumer_key,
|
93 |
+
"consumer_secret" => $consumer_secret
|
94 |
+
);
|
95 |
+
foreach ($post_tracks as $track) {
|
96 |
$url = "http://www.aftership.com/api/v1/add-tracking/?";
|
97 |
+
$url_params["tracking_number"] = $track["tracking_number"];
|
98 |
+
$url_params["mobile"] = $track["telephone"];
|
99 |
+
$url_params["email"] = $track["email"];
|
100 |
+
$url_params["title"] = $track["title"];
|
101 |
$url .= http_build_query($url_params);
|
102 |
|
103 |
$ch = curl_init();
|
106 |
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
|
107 |
curl_setopt($ch, CURLOPT_HEADER, 0);
|
108 |
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
109 |
+
|
110 |
$response = curl_exec($ch);
|
111 |
$error = curl_error($ch);
|
112 |
curl_close($ch);
|
113 |
$response_obj = json_decode($response);
|
114 |
+
|
115 |
+
if (property_exists($response_obj, "message")) {
|
116 |
+
if ($response_obj->message == "OK") {
|
117 |
$track_obj = Mage::getModel('track/track');
|
118 |
$track_obj->load($track["track_id"]);
|
119 |
$track_obj->setPosted(1);
|
120 |
$track_obj->save();
|
121 |
}
|
122 |
+
} else {
|
123 |
//fail
|
124 |
}
|
125 |
}
|
126 |
}
|
127 |
}
|
128 |
+
|
129 |
public function adminSystemConfigChangedSectionAftership($obj)
|
130 |
{
|
131 |
$post_data = Mage::app()->getRequest()->getPost();
|
132 |
$consumer_key = $post_data["groups"]["messages"]["fields"]["consumer_key"]["value"];
|
133 |
$consumer_secret = $post_data["groups"]["messages"]["fields"]["consumer_secret"]["value"];
|
134 |
+
if (!array_key_exists("notification", $post_data["groups"]["messages"]["fields"])) {
|
135 |
+
Mage::getModel('core/config')->saveConfig('aftership_options/messages/notification', 0);
|
136 |
}
|
137 |
+
|
138 |
+
$url_params = array("consumer_key" => $consumer_key,
|
139 |
+
"consumer_secret" => $consumer_secret
|
140 |
+
);
|
141 |
$url = "http://www.aftership.com/api/v1/user-detail/?";
|
142 |
$url .= http_build_query($url_params);
|
143 |
|
147 |
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
|
148 |
curl_setopt($ch, CURLOPT_HEADER, 0);
|
149 |
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
150 |
+
|
151 |
$response = curl_exec($ch);
|
152 |
$error = curl_error($ch);
|
153 |
curl_close($ch);
|
154 |
$response_obj = json_decode($response);
|
155 |
+
|
156 |
+
if (!property_exists($response_obj, "twitter_screen_name")) {
|
157 |
+
Mage::getModel('core/config')->saveConfig('aftership_options/messages/status', 0);
|
158 |
+
if ($error) {
|
159 |
Mage::throwException(Mage::helper('adminhtml')->__($error));
|
160 |
+
} else {
|
161 |
Mage::throwException(Mage::helper('adminhtml')->__($response_obj->error));
|
162 |
}
|
163 |
+
} else {
|
164 |
// success
|
165 |
}
|
166 |
}
|
app/code/community/Aftership/Track/sql/track_setup/mysql4-install-0.1.0.php
CHANGED
@@ -2,6 +2,7 @@
|
|
2 |
//echo "start";
|
3 |
$installer = $this;
|
4 |
$installer->startSetup();
|
|
|
5 |
$installer->run("
|
6 |
CREATE TABLE `{$installer->getTable('track/track')}` (
|
7 |
`track_id` int(11) NOT NULL AUTO_INCREMENT,
|
2 |
//echo "start";
|
3 |
$installer = $this;
|
4 |
$installer->startSetup();
|
5 |
+
$installer->run("DROP TABLE IF EXISTS `{$installer->getTable('track/track')}`;");
|
6 |
$installer->run("
|
7 |
CREATE TABLE `{$installer->getTable('track/track')}` (
|
8 |
`track_id` int(11) NOT NULL AUTO_INCREMENT,
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
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>
|
@@ -11,8 +11,8 @@
|
|
11 |
<notes>Fixed minor bugs</notes>
|
12 |
<authors><author><name>aftership</name><user>aftership</user><email>support@aftership.com</email></author></authors>
|
13 |
<date>2012-06-13</date>
|
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.8</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.opensource.org/licenses/gpl-license.php">GPL</license>
|
7 |
<channel>community</channel>
|
11 |
<notes>Fixed minor bugs</notes>
|
12 |
<authors><author><name>aftership</name><user>aftership</user><email>support@aftership.com</email></author></authors>
|
13 |
<date>2012-06-13</date>
|
14 |
+
<time>09:52:05</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="a9f3af0e61d4190d940293c4995b94b3"/><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="bc2bd83404fb537b914c6c771e0f0f2f"/></dir><dir name="etc"><file name="config.xml" hash="44b407dcd58774176a2a37191daf04a2"/><file name="system.xml" hash="24bd66d83794242ddf8433fccc48f893"/></dir><dir name="sql"><dir name="track_setup"><file name="mysql4-install-0.1.0.php" hash="03e6e8dc8c5097f37999880b2778f69c"/></dir></dir></dir></dir></target><target name="mageetc"><dir><dir name="modules"><file name="Aftership_Track.xml" hash="6518f61d8f390f4fc8a517b2b15b01d1"/></dir></dir></target></contents>
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.2.17</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|