AfterShip – WooCommerce Tracking - Version 1.9.17

Version Description

  • Fix known issue
Download this release

Release Info

Developer aftership
Plugin Icon 128x128 AfterShip – WooCommerce Tracking
Version 1.9.17
Comparing to
See all releases

Code changes from version 1.9.16 to 1.9.17

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.16
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.17
7
  Author: AfterShip
8
  Author URI: http://aftership.com
9
 
api/class-aftership-api-v2-json-handler.php ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
@@ -125,8 +125,8 @@ class AfterShip_API_V2_Orders extends AfterShip_API_Resource
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 = [
125
  $shipping_method = null;
126
  if($current_shipping_method['method_id'] && $current_shipping_method['name']) {
127
  $shipping_method = [
128
+ 'code' => $current_shipping_method['method_id'],
129
+ 'name' => $current_shipping_method['name'],
130
  ];
131
  }
132
  $order_data = [
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.16
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.16 =
101
  * Fix known issue
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.17
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.17 =
101
+ * Fix known issue
102
+
103
  = 1.9.16 =
104
  * Fix known issue
105