Version Description
- Fix known issue
Download this release
Release Info
Developer | aftership |
Plugin | AfterShip – WooCommerce Tracking |
Version | 1.9.16 |
Comparing to | |
See all releases |
Code changes from version 1.9.15 to 1.9.16
- aftership.php +1 -1
- api/class-aftership-api-v2-json-handler.php +0 -129
- api/class-aftership-api-v2-orders.php +12 -8
- readme.txt +4 -1
aftership.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: AfterShip - WooCommerce Tracking
|
4 |
Plugin URI: http://aftership.com/
|
5 |
Description: Add tracking number and carrier name to WooCommerce, display tracking info at order history page, auto import tracking numbers to AfterShip.
|
6 |
-
Version: 1.9.
|
7 |
Author: AfterShip
|
8 |
Author URI: http://aftership.com
|
9 |
|
3 |
Plugin Name: AfterShip - WooCommerce Tracking
|
4 |
Plugin URI: http://aftership.com/
|
5 |
Description: Add tracking number and carrier name to WooCommerce, display tracking info at order history page, auto import tracking numbers to AfterShip.
|
6 |
+
Version: 1.9.16
|
7 |
Author: AfterShip
|
8 |
Author URI: http://aftership.com
|
9 |
|
api/class-aftership-api-v2-json-handler.php
DELETED
@@ -1,129 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* AfterShip API
|
4 |
-
*
|
5 |
-
* Handles parsing JSON request bodies and generating JSON responses
|
6 |
-
*
|
7 |
-
* @author AfterShip
|
8 |
-
* @category API
|
9 |
-
* @package AfterShip/API
|
10 |
-
* @since 1.0
|
11 |
-
*/
|
12 |
-
|
13 |
-
if (!defined('ABSPATH')) {
|
14 |
-
exit;
|
15 |
-
} // Exit if accessed directly
|
16 |
-
|
17 |
-
class AfterShip_API_V2_JSON_Handler implements AfterShip_API_Handler
|
18 |
-
{
|
19 |
-
/**
|
20 |
-
* Get the content type for the response
|
21 |
-
*
|
22 |
-
* @return string
|
23 |
-
* @since 2.1
|
24 |
-
*/
|
25 |
-
public function get_content_type()
|
26 |
-
{
|
27 |
-
return 'application/json; charset=' . get_option('blog_charset');
|
28 |
-
}
|
29 |
-
|
30 |
-
/**
|
31 |
-
* Parse the raw request body entity
|
32 |
-
*
|
33 |
-
* @param string $body the raw request body
|
34 |
-
*
|
35 |
-
* @return array|mixed
|
36 |
-
* @since 2.1
|
37 |
-
*
|
38 |
-
*/
|
39 |
-
public function parse_body($body)
|
40 |
-
{
|
41 |
-
return json_decode($body, true);
|
42 |
-
}
|
43 |
-
|
44 |
-
/**
|
45 |
-
* Generate a JSON response given an array of data
|
46 |
-
*
|
47 |
-
* @param array $data the response data
|
48 |
-
*
|
49 |
-
* @return string
|
50 |
-
* @since 2.1
|
51 |
-
*
|
52 |
-
*/
|
53 |
-
public function generate_response($data)
|
54 |
-
{
|
55 |
-
if (isset($_GET['_jsonp'])) {
|
56 |
-
// JSONP enabled by default
|
57 |
-
if (!apply_filters('aftership_api_jsonp_enabled', true)) {
|
58 |
-
|
59 |
-
WC()->api->server->send_status(400);
|
60 |
-
|
61 |
-
$data = [
|
62 |
-
[
|
63 |
-
'code' => 'aftership_api_jsonp_disabled',
|
64 |
-
'message' => __('JSONP support is disabled on this site', 'aftership')
|
65 |
-
]
|
66 |
-
];
|
67 |
-
}
|
68 |
-
|
69 |
-
// Check for invalid characters (only alphanumeric allowed)
|
70 |
-
if (preg_match('/\W/', $_GET['_jsonp'])) {
|
71 |
-
|
72 |
-
WC()->api->server->send_status(400);
|
73 |
-
|
74 |
-
$data = [
|
75 |
-
[
|
76 |
-
'code' => 'aftership_api_jsonp_callback_invalid',
|
77 |
-
__('The JSONP callback function is invalid', 'aftership')
|
78 |
-
]
|
79 |
-
];
|
80 |
-
}
|
81 |
-
|
82 |
-
return $_GET['_jsonp'] . '(' . json_encode($data) . ')';
|
83 |
-
}
|
84 |
-
|
85 |
-
$ok = [
|
86 |
-
'meta' => [
|
87 |
-
'code' => 20000,
|
88 |
-
'type' => 'OK',
|
89 |
-
'message' => 'Everything worked as expected'
|
90 |
-
],
|
91 |
-
'data' => $data
|
92 |
-
];
|
93 |
-
|
94 |
-
if (isset($data['errors'])) {
|
95 |
-
$error = [
|
96 |
-
'meta' => [
|
97 |
-
'code' => $this->map_error_code($data['errors'][0]['code']),
|
98 |
-
'type' => $data['errors'][0]['code'],
|
99 |
-
'message' => $data['errors'][0]['message'],
|
100 |
-
|
101 |
-
],
|
102 |
-
'data' => '{}'
|
103 |
-
];
|
104 |
-
return json_encode($error);
|
105 |
-
}
|
106 |
-
|
107 |
-
|
108 |
-
return json_encode($ok);
|
109 |
-
}
|
110 |
-
|
111 |
-
/**
|
112 |
-
* get error code by error message
|
113 |
-
* @param $code_text
|
114 |
-
* @return int
|
115 |
-
*/
|
116 |
-
private function map_error_code($code_text)
|
117 |
-
{
|
118 |
-
$code = 40010;
|
119 |
-
switch ($code_text) {
|
120 |
-
case 'aftership_api_disabled':
|
121 |
-
$code = 400011;
|
122 |
-
break;
|
123 |
-
default:
|
124 |
-
break;
|
125 |
-
}
|
126 |
-
|
127 |
-
return $code;
|
128 |
-
}
|
129 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
api/class-aftership-api-v2-orders.php
CHANGED
@@ -121,16 +121,20 @@ class AfterShip_API_V2_Orders extends AfterShip_API_Resource
|
|
121 |
}
|
122 |
$order = new WC_Order($id);
|
123 |
$customer = new WC_Customer($order->get_customer_id());
|
124 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
$order_data = [
|
126 |
'id' => (string)$order->get_id(),
|
127 |
'order_number' => $order->get_order_number(),
|
128 |
'order_name' => $order->get_order_number(),
|
129 |
'taxes_included' => ($order->get_total_tax() > 0),
|
130 |
-
'shipping_method' =>
|
131 |
-
'code' => $shipping_method['method_id'],
|
132 |
-
'name' => $shipping_method['name'],
|
133 |
-
],
|
134 |
'order_total' => [
|
135 |
'currency' => $order->get_currency(),
|
136 |
'amount' => (float)wc_format_decimal($order->get_total(), 2),
|
@@ -219,8 +223,8 @@ class AfterShip_API_V2_Orders extends AfterShip_API_Resource
|
|
219 |
$product_categories[] = $categoriesVal->name;
|
220 |
}
|
221 |
$order_data['items'][] = [
|
222 |
-
'id' => $item_id,
|
223 |
-
'product_id' => $product_id,
|
224 |
'sku' => is_object($product) ? $product->get_sku() : null,
|
225 |
'title' => $item['name'],
|
226 |
'quantity' => (int)$item['qty'],
|
@@ -235,7 +239,7 @@ class AfterShip_API_V2_Orders extends AfterShip_API_Resource
|
|
235 |
'amount' => (float)wc_format_decimal($order->get_item_total($item), 2),
|
236 |
],
|
237 |
'discount' => null,
|
238 |
-
'image_urls' => [wp_get_attachment_url($product->image_id)],
|
239 |
'tags' => $product_tags,
|
240 |
'categories' => $product_categories,
|
241 |
];
|
121 |
}
|
122 |
$order = new WC_Order($id);
|
123 |
$customer = new WC_Customer($order->get_customer_id());
|
124 |
+
$current_shipping_method = current($order->get_shipping_methods());
|
125 |
+
$shipping_method = null;
|
126 |
+
if($current_shipping_method['method_id'] && $current_shipping_method['name']) {
|
127 |
+
$shipping_method = [
|
128 |
+
'code' => $shipping_method['method_id'],
|
129 |
+
'name' => $shipping_method['name'],
|
130 |
+
];
|
131 |
+
}
|
132 |
$order_data = [
|
133 |
'id' => (string)$order->get_id(),
|
134 |
'order_number' => $order->get_order_number(),
|
135 |
'order_name' => $order->get_order_number(),
|
136 |
'taxes_included' => ($order->get_total_tax() > 0),
|
137 |
+
'shipping_method' => $shipping_method,
|
|
|
|
|
|
|
138 |
'order_total' => [
|
139 |
'currency' => $order->get_currency(),
|
140 |
'amount' => (float)wc_format_decimal($order->get_total(), 2),
|
223 |
$product_categories[] = $categoriesVal->name;
|
224 |
}
|
225 |
$order_data['items'][] = [
|
226 |
+
'id' => (string)$item_id,
|
227 |
+
'product_id' => (string)$product_id,
|
228 |
'sku' => is_object($product) ? $product->get_sku() : null,
|
229 |
'title' => $item['name'],
|
230 |
'quantity' => (int)$item['qty'],
|
239 |
'amount' => (float)wc_format_decimal($order->get_item_total($item), 2),
|
240 |
],
|
241 |
'discount' => null,
|
242 |
+
'image_urls' => wp_get_attachment_url($product->image_id) ? [wp_get_attachment_url($product->image_id)] : [],
|
243 |
'tags' => $product_tags,
|
244 |
'categories' => $product_categories,
|
245 |
];
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.aftership.com/
|
|
4 |
Tags: shipping, tracking, ups, usps, fedex, dhl, tnt, dpd, post, shipment, woocommerce, tracking number, aftership, package tracking, fulfilment, tracking link, carrier, courier, woo commerce, woocommerce shipment tracking, shipping details plugin, widget, shipstation, track, package
|
5 |
Requires at least: 2.9
|
6 |
Tested up to: 5.2.1
|
7 |
-
Stable tag: 1.9.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -97,6 +97,9 @@ You'll find the FAQ on [AfterShip.com](https://aftership.uservoice.com/knowledge
|
|
97 |
|
98 |
== Changelog ==
|
99 |
|
|
|
|
|
|
|
100 |
= 1.9.15 =
|
101 |
* Add new api endpoint for orders sync
|
102 |
|
4 |
Tags: shipping, tracking, ups, usps, fedex, dhl, tnt, dpd, post, shipment, woocommerce, tracking number, aftership, package tracking, fulfilment, tracking link, carrier, courier, woo commerce, woocommerce shipment tracking, shipping details plugin, widget, shipstation, track, package
|
5 |
Requires at least: 2.9
|
6 |
Tested up to: 5.2.1
|
7 |
+
Stable tag: 1.9.16
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
97 |
|
98 |
== Changelog ==
|
99 |
|
100 |
+
= 1.9.16 =
|
101 |
+
* Fix known issue
|
102 |
+
|
103 |
= 1.9.15 =
|
104 |
* Add new api endpoint for orders sync
|
105 |
|