Version Description
- Support new couriers, please check out supported couriers in https://www.aftership.com/courier
- Support new required field,
tracking key
andtracking destination country
- Support custom track message on order history page
Download this release
Release Info
Developer | aftership |
Plugin | AfterShip – WooCommerce Tracking |
Version | 1.3.2 |
Comparing to | |
See all releases |
Code changes from version 1.3.1 to 1.3.2
- aftership.php +544 -444
- api/class-aftership-api-orders.php +13 -3
- assets/js/admin.js +106 -103
- assets/js/couriers.js +40 -10
- assets/js/setting.js +66 -41
- class-aftership-api.php +0 -1
- class-aftership-settings.php +35 -1
- readme.txt +6 -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.3.
|
7 |
Author: AfterShip
|
8 |
Author URI: http://aftership.com
|
9 |
|
@@ -19,7 +19,7 @@ defined('ABSPATH') or die("No script kiddies please!");
|
|
19 |
* Required functions
|
20 |
*/
|
21 |
if (!function_exists('is_woocommerce_active'))
|
22 |
-
|
23 |
|
24 |
|
25 |
/**
|
@@ -28,447 +28,547 @@ if (!function_exists('is_woocommerce_active'))
|
|
28 |
|
29 |
if (is_woocommerce_active()) {
|
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 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
'
|
211 |
-
'
|
212 |
-
'
|
213 |
-
'
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
'
|
220 |
-
'
|
221 |
-
'
|
222 |
-
'
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
'
|
229 |
-
'
|
230 |
-
'
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
473 |
|
474 |
}
|
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.3.2
|
7 |
Author: AfterShip
|
8 |
Author URI: http://aftership.com
|
9 |
|
19 |
* Required functions
|
20 |
*/
|
21 |
if (!function_exists('is_woocommerce_active'))
|
22 |
+
require_once('aftership-functions.php');
|
23 |
|
24 |
|
25 |
/**
|
28 |
|
29 |
if (is_woocommerce_active()) {
|
30 |
|
31 |
+
/**
|
32 |
+
* AfterShip class
|
33 |
+
*/
|
34 |
+
if (!class_exists('AfterShip')) {
|
35 |
+
|
36 |
+
final class AfterShip
|
37 |
+
{
|
38 |
+
|
39 |
+
protected static $_instance = null;
|
40 |
+
|
41 |
+
public static function instance()
|
42 |
+
{
|
43 |
+
if (is_null(self::$_instance)) {
|
44 |
+
self::$_instance = new self();
|
45 |
+
}
|
46 |
+
return self::$_instance;
|
47 |
+
}
|
48 |
+
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Constructor
|
52 |
+
*/
|
53 |
+
public function __construct()
|
54 |
+
{
|
55 |
+
$this->includes();
|
56 |
+
|
57 |
+
$this->api = new AfterShip_API();
|
58 |
+
|
59 |
+
$options = get_option('aftership_option_name');
|
60 |
+
if ($options) {
|
61 |
+
|
62 |
+
if (isset($options['plugin'])) {
|
63 |
+
$plugin = $options['plugin'];
|
64 |
+
if ($plugin == 'aftership') {
|
65 |
+
add_action('admin_print_scripts', array(&$this, 'library_scripts'));
|
66 |
+
add_action('admin_print_styles', array(&$this, 'admin_styles'));
|
67 |
+
add_action('add_meta_boxes', array(&$this, 'add_meta_box'));
|
68 |
+
add_action('woocommerce_process_shop_order_meta', array(&$this, 'save_meta_box'), 0, 2);
|
69 |
+
add_action('plugins_loaded', array($this, 'load_plugin_textdomain'));
|
70 |
+
|
71 |
+
$this->couriers = $options['couriers'];
|
72 |
+
}
|
73 |
+
|
74 |
+
// View Order Page
|
75 |
+
$this->plugin = $plugin;
|
76 |
+
} else {
|
77 |
+
$this->plugin = '';
|
78 |
+
}
|
79 |
+
|
80 |
+
if (isset($options['use_track_button'])) {
|
81 |
+
$this->use_track_button = $options['use_track_button'];
|
82 |
+
} else {
|
83 |
+
$this->use_track_button = false;
|
84 |
+
}
|
85 |
+
|
86 |
+
add_action('woocommerce_view_order', array(&$this, 'display_tracking_info'));
|
87 |
+
add_action('woocommerce_email_before_order_table', array(&$this, 'email_display'));
|
88 |
+
|
89 |
+
}
|
90 |
+
|
91 |
+
// user profile api key
|
92 |
+
add_action('show_user_profile', array($this, 'add_api_key_field'));
|
93 |
+
add_action('edit_user_profile', array($this, 'add_api_key_field'));
|
94 |
+
add_action('personal_options_update', array($this, 'generate_api_key'));
|
95 |
+
add_action('edit_user_profile_update', array($this, 'generate_api_key'));
|
96 |
+
|
97 |
+
register_activation_hook(__FILE__, array($this, 'install'));
|
98 |
+
}
|
99 |
+
|
100 |
+
public function install()
|
101 |
+
{
|
102 |
+
global $wp_roles;
|
103 |
+
|
104 |
+
if (class_exists('WP_Roles')) {
|
105 |
+
if (!isset($wp_roles)) {
|
106 |
+
$wp_roles = new WP_Roles();
|
107 |
+
}
|
108 |
+
}
|
109 |
+
|
110 |
+
if (is_object($wp_roles)) {
|
111 |
+
$wp_roles->add_cap('administrator', 'manage_aftership');
|
112 |
+
}
|
113 |
+
}
|
114 |
+
|
115 |
+
private function includes()
|
116 |
+
{
|
117 |
+
include_once('aftership-fields.php');
|
118 |
+
$this->aftership_fields = $aftership_fields;
|
119 |
+
|
120 |
+
include_once('class-aftership-api.php');
|
121 |
+
include_once('class-aftership-settings.php');
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Localisation
|
126 |
+
*/
|
127 |
+
public function load_plugin_textdomain()
|
128 |
+
{
|
129 |
+
load_plugin_textdomain('aftership', false, dirname(plugin_basename(__FILE__)) . '/languages/');
|
130 |
+
}
|
131 |
+
|
132 |
+
public function admin_styles()
|
133 |
+
{
|
134 |
+
wp_enqueue_style('aftership_styles_chosen', plugins_url(basename(dirname(__FILE__))) . '/assets/plugin/chosen/chosen.min.css');
|
135 |
+
wp_enqueue_style('aftership_styles', plugins_url(basename(dirname(__FILE__))) . '/assets/css/admin.css');
|
136 |
+
}
|
137 |
+
|
138 |
+
public function library_scripts()
|
139 |
+
{
|
140 |
+
wp_enqueue_script('aftership_styles_chosen_jquery', plugins_url(basename(dirname(__FILE__))) . '/assets/plugin/chosen/chosen.jquery.min.js');
|
141 |
+
wp_enqueue_script('aftership_styles_chosen_proto', plugins_url(basename(dirname(__FILE__))) . '/assets/plugin/chosen/chosen.proto.min.js');
|
142 |
+
wp_enqueue_script('aftership_script_util', plugins_url(basename(dirname(__FILE__))) . '/assets/js/util.js');
|
143 |
+
wp_enqueue_script('aftership_script_couriers', plugins_url(basename(dirname(__FILE__))) . '/assets/js/couriers.js');
|
144 |
+
wp_enqueue_script('aftership_script_admin', plugins_url(basename(dirname(__FILE__))) . '/assets/js/admin.js');
|
145 |
+
}
|
146 |
+
|
147 |
+
/**
|
148 |
+
* Add the meta box for shipment info on the order page
|
149 |
+
*
|
150 |
+
* @access public
|
151 |
+
*/
|
152 |
+
public function add_meta_box()
|
153 |
+
{
|
154 |
+
add_meta_box('woocommerce-aftership', __('AfterShip', 'wc_aftership'), array(&$this, 'meta_box'), 'shop_order', 'side', 'high');
|
155 |
+
}
|
156 |
+
|
157 |
+
/**
|
158 |
+
* Show the meta box for shipment info on the order page
|
159 |
+
*
|
160 |
+
* @access public
|
161 |
+
*/
|
162 |
+
public function meta_box()
|
163 |
+
{
|
164 |
+
|
165 |
+
// just draw the layout, no data
|
166 |
+
global $post;
|
167 |
+
|
168 |
+
$selected_provider = get_post_meta($post->ID, '_aftership_tracking_provider', true);
|
169 |
+
|
170 |
+
echo '<div id="aftership_wrapper">';
|
171 |
+
|
172 |
+
echo '<p class="form-field"><label for="aftership_tracking_provider">' . __('Carrier:', 'wc_aftership') . '</label><br/><select id="aftership_tracking_provider" name="aftership_tracking_provider" class="chosen_select" style="width:100%">';
|
173 |
+
if ($selected_provider == '') {
|
174 |
+
$selected_text = 'selected="selected"';
|
175 |
+
} else {
|
176 |
+
$selected_text = '';
|
177 |
+
}
|
178 |
+
echo '<option disabled ' . $selected_text . ' value="">Please Select</option>';
|
179 |
+
echo '</select>';
|
180 |
+
echo '<br><a href="options-general.php?page=aftership-setting-admin">Update carrier list</a>';
|
181 |
+
echo '<input type="hidden" id="aftership_tracking_provider_hidden" value="' . $selected_provider . '"/>';
|
182 |
+
echo '<input type="hidden" id="aftership_couriers_selected" value="' . $this->couriers . '"/>';
|
183 |
+
|
184 |
+
foreach ($this->aftership_fields as $field) {
|
185 |
+
if ($field['type'] == 'date') {
|
186 |
+
woocommerce_wp_text_input(array(
|
187 |
+
'id' => $field['id'],
|
188 |
+
'label' => __($field['label'], 'wc_aftership'),
|
189 |
+
'placeholder' => $field['placeholder'],
|
190 |
+
'description' => $field['description'],
|
191 |
+
'class' => $field['class'],
|
192 |
+
'value' => ($date = get_post_meta($post->ID, '_' . $field['id'], true)) ? date('Y-m-d', $date) : ''
|
193 |
+
));
|
194 |
+
} else {
|
195 |
+
woocommerce_wp_text_input(array(
|
196 |
+
'id' => $field['id'],
|
197 |
+
'label' => __($field['label'], 'wc_aftership'),
|
198 |
+
'placeholder' => $field['placeholder'],
|
199 |
+
'description' => $field['description'],
|
200 |
+
'class' => $field['class'],
|
201 |
+
'value' => get_post_meta($post->ID, '_' . $field['id'], true),
|
202 |
+
));
|
203 |
+
}
|
204 |
+
}
|
205 |
+
|
206 |
+
//
|
207 |
+
// woocommerce_wp_text_input(array(
|
208 |
+
// 'id' => 'aftership_tracking_provider_name',
|
209 |
+
// 'label' => __('', 'wc_aftership'),
|
210 |
+
// 'placeholder' => '',
|
211 |
+
// 'description' => '',
|
212 |
+
// 'class' => 'hidden',
|
213 |
+
// 'value' => get_post_meta($post->ID, '_aftership_tracking_provider_name', true),
|
214 |
+
// ));
|
215 |
+
//
|
216 |
+
// woocommerce_wp_text_input(array(
|
217 |
+
// 'id' => 'aftership_tracking_required_fields',
|
218 |
+
// 'label' => __('', 'wc_aftership'),
|
219 |
+
// 'placeholder' => '',
|
220 |
+
// 'description' => '',
|
221 |
+
// 'class' => 'hidden',
|
222 |
+
// 'value' => get_post_meta($post->ID, '_aftership_tracking_required_fields', true),
|
223 |
+
// ));
|
224 |
+
//
|
225 |
+
// woocommerce_wp_text_input(array(
|
226 |
+
// 'id' => 'aftership_tracking_number',
|
227 |
+
// 'label' => __('Tracking number:', 'wc_aftership'),
|
228 |
+
// 'placeholder' => '',
|
229 |
+
// 'description' => '',
|
230 |
+
// 'value' => get_post_meta($post->ID, '_aftership_tracking_number', true),
|
231 |
+
// ));
|
232 |
+
//
|
233 |
+
// woocommerce_wp_text_input(array(
|
234 |
+
// 'id' => 'aftership_tracking_shipdate',
|
235 |
+
// 'label' => __('Date shipped:', 'wc_aftership'),
|
236 |
+
// 'placeholder' => 'YYYY-MM-DD',
|
237 |
+
// 'description' => '',
|
238 |
+
// 'class' => 'date-picker-field hidden-field',
|
239 |
+
// 'value' => ($date = get_post_meta($post->ID, '_aftership_tracking_shipdate', true)) ? date('Y-m-d', $date) : ''
|
240 |
+
// ));
|
241 |
+
//
|
242 |
+
// woocommerce_wp_text_input(array(
|
243 |
+
// 'id' => 'aftership_tracking_postal',
|
244 |
+
// 'label' => __('Postal Code:', 'wc_aftership'),
|
245 |
+
// 'placeholder' => '',
|
246 |
+
// 'description' => '',
|
247 |
+
// 'class' => 'hidden-field',
|
248 |
+
// 'value' => get_post_meta($post->ID, '_aftership_tracking_postal', true),
|
249 |
+
// ));
|
250 |
+
//
|
251 |
+
// woocommerce_wp_text_input(array(
|
252 |
+
// 'id' => 'aftership_tracking_account',
|
253 |
+
// 'label' => __('Account name:', 'wc_aftership'),
|
254 |
+
// 'placeholder' => '',
|
255 |
+
// 'description' => '',
|
256 |
+
// 'class' => 'hidden-field',
|
257 |
+
// 'value' => get_post_meta($post->ID, '_aftership_tracking_account', true),
|
258 |
+
// ));
|
259 |
+
//
|
260 |
+
// woocommerce_wp_text_input(array(
|
261 |
+
// 'id' => 'aftership_tracking_key',
|
262 |
+
// 'label' => __('Tracking key:', 'wc_aftership'),
|
263 |
+
// 'placeholder' => '',
|
264 |
+
// 'description' => '',
|
265 |
+
// 'class' => 'hidden-field',
|
266 |
+
// 'value' => get_post_meta($post->ID, '_aftership_tracking_key', true),
|
267 |
+
// ));
|
268 |
+
//
|
269 |
+
// woocommerce_wp_text_input(array(
|
270 |
+
// 'id' => 'aftership_tracking_destination_country',
|
271 |
+
// 'label' => __('Destination Country:', 'wc_aftership'),
|
272 |
+
// 'placeholder' => '',
|
273 |
+
// 'description' => '',
|
274 |
+
// 'class' => 'hidden-field',
|
275 |
+
// 'value' => get_post_meta($post->ID, '_aftership_tracking_destination_country', true),
|
276 |
+
// ));
|
277 |
+
echo '</div>';
|
278 |
+
}
|
279 |
+
|
280 |
+
/**
|
281 |
+
* Order Downloads Save
|
282 |
+
*
|
283 |
+
* Function for processing and storing all order downloads.
|
284 |
+
*/
|
285 |
+
public function save_meta_box($post_id, $post)
|
286 |
+
{
|
287 |
+
if (isset($_POST['aftership_tracking_number'])) {
|
288 |
+
//
|
289 |
+
// // Download data
|
290 |
+
$tracking_provider = woocommerce_clean($_POST['aftership_tracking_provider']);
|
291 |
+
// $tracking_number = woocommerce_clean($_POST['aftership_tracking_number']);
|
292 |
+
// $tracking_provider_name = woocommerce_clean($_POST['aftership_tracking_provider_name']);
|
293 |
+
// $tracking_required_fields = woocommerce_clean($_POST['aftership_tracking_required_fields']);
|
294 |
+
// $shipdate = woocommerce_clean(strtotime($_POST['aftership_tracking_shipdate']));
|
295 |
+
// $postal = woocommerce_clean($_POST['aftership_tracking_postal']);
|
296 |
+
// $account = woocommerce_clean($_POST['aftership_tracking_account']);
|
297 |
+
// $tracking_key = woocommerce_clean($_POST['aftership_tracking_key']);
|
298 |
+
// $tracking_destination_country = woocommerce_clean($_POST['aftership_tracking_destination_country']);
|
299 |
+
//
|
300 |
+
// // Update order data
|
301 |
+
update_post_meta($post_id, '_aftership_tracking_provider', $tracking_provider);
|
302 |
+
// update_post_meta($post_id, '_aftership_tracking_number', $tracking_number);
|
303 |
+
// update_post_meta($post_id, '_aftership_tracking_provider_name', $tracking_provider_name);
|
304 |
+
// update_post_meta($post_id, '_aftership_tracking_required_fields', $tracking_required_fields);
|
305 |
+
// update_post_meta($post_id, '_aftership_tracking_shipdate', $shipdate);
|
306 |
+
// update_post_meta($post_id, '_aftership_tracking_postal', $postal);
|
307 |
+
// update_post_meta($post_id, '_aftership_tracking_account', $account);
|
308 |
+
// update_post_meta($post_id, '_aftership_tracking_key', $tracking_key);
|
309 |
+
// update_post_meta($post_id, '_aftership_tracking_destination_country', $tracking_destination_country);
|
310 |
+
|
311 |
+
|
312 |
+
foreach ($this->aftership_fields as $field) {
|
313 |
+
if ($field['type'] == 'date') {
|
314 |
+
update_post_meta($post_id, '_' . $field['id'], woocommerce_clean(strtotime($_POST[$field['id']])));
|
315 |
+
} else {
|
316 |
+
update_post_meta($post_id, '_' . $field['id'], woocommerce_clean($_POST[$field['id']]));
|
317 |
+
}
|
318 |
+
}
|
319 |
+
}
|
320 |
+
}
|
321 |
+
|
322 |
+
/**
|
323 |
+
* Display the API key info for a user
|
324 |
+
*
|
325 |
+
* @since 2.1
|
326 |
+
* @param WP_User $user
|
327 |
+
*/
|
328 |
+
public function add_api_key_field($user)
|
329 |
+
{
|
330 |
+
|
331 |
+
if (!current_user_can('manage_aftership'))
|
332 |
+
return;
|
333 |
+
|
334 |
+
if (current_user_can('edit_user', $user->ID)) {
|
335 |
+
?>
|
336 |
+
<h3>AfterShip</h3>
|
337 |
+
<table class="form-table">
|
338 |
+
<tbody>
|
339 |
+
<tr>
|
340 |
+
<th><label
|
341 |
+
for="aftership_wp_api_key"><?php _e('AfterShip\'s WordPress API Key', 'aftership'); ?></label>
|
342 |
+
</th>
|
343 |
+
<td>
|
344 |
+
<?php if (empty($user->aftership_wp_api_key)) : ?>
|
345 |
+
<input name="aftership_wp_generate_api_key" type="checkbox"
|
346 |
+
id="aftership_wp_generate_api_key" value="0"/>
|
347 |
+
<span class="description"><?php _e('Generate API Key', 'aftership'); ?></span>
|
348 |
+
<?php else : ?>
|
349 |
+
<code id="aftership_wp_api_key"><?php echo $user->aftership_wp_api_key ?></code>
|
350 |
+
<br/>
|
351 |
+
<input name="aftership_wp_generate_api_key" type="checkbox"
|
352 |
+
id="aftership_wp_generate_api_key" value="0"/>
|
353 |
+
<span class="description"><?php _e('Revoke API Key', 'aftership'); ?></span>
|
354 |
+
<?php endif; ?>
|
355 |
+
</td>
|
356 |
+
</tr>
|
357 |
+
</tbody>
|
358 |
+
</table>
|
359 |
+
<?php
|
360 |
+
}
|
361 |
+
}
|
362 |
+
|
363 |
+
/**
|
364 |
+
* Generate and save (or delete) the API keys for a user
|
365 |
+
*
|
366 |
+
* @since 2.1
|
367 |
+
* @param int $user_id
|
368 |
+
*/
|
369 |
+
public function generate_api_key($user_id)
|
370 |
+
{
|
371 |
+
|
372 |
+
if (current_user_can('edit_user', $user_id)) {
|
373 |
+
|
374 |
+
$user = get_userdata($user_id);
|
375 |
+
|
376 |
+
// creating/deleting key
|
377 |
+
if (isset($_POST['aftership_wp_generate_api_key'])) {
|
378 |
+
|
379 |
+
// consumer key
|
380 |
+
if (empty($user->aftership_wp_api_key)) {
|
381 |
+
|
382 |
+
$api_key = 'ck_' . hash('md5', $user->user_login . date('U') . mt_rand());
|
383 |
+
|
384 |
+
update_user_meta($user_id, 'aftership_wp_api_key', $api_key);
|
385 |
+
|
386 |
+
} else {
|
387 |
+
|
388 |
+
delete_user_meta($user_id, 'aftership_wp_api_key');
|
389 |
+
}
|
390 |
+
|
391 |
+
}
|
392 |
+
}
|
393 |
+
}
|
394 |
+
|
395 |
+
/**
|
396 |
+
* Display Shipment info in the frontend (order view/tracking page).
|
397 |
+
*
|
398 |
+
* @access public
|
399 |
+
*/
|
400 |
+
function display_tracking_info($order_id, $for_email = false)
|
401 |
+
{
|
402 |
+
if ($this->plugin == 'aftership') {
|
403 |
+
$this->display_order_aftership($order_id, $for_email);
|
404 |
+
} else if ($this->plugin == 'wc-shipment-tracking') { //$49
|
405 |
+
$this->display_order_wc_shipment_tracking($order_id, $for_email);
|
406 |
+
}
|
407 |
+
}
|
408 |
+
|
409 |
+
private function display_order_aftership($order_id, $for_email)
|
410 |
+
{
|
411 |
+
|
412 |
+
// print_r($this->aftership_fields);
|
413 |
+
$values = array();
|
414 |
+
foreach ($this->aftership_fields as $field) {
|
415 |
+
$values[$field['id']] = get_post_meta($order_id, '_' . $field['id'], true);
|
416 |
+
if ($field['type'] == 'date' && $values[$field['id']]) {
|
417 |
+
$values[$field['id']] = date_i18n(__('l jS F Y', 'wc_shipment_tracking'), $values[$field['id']]);
|
418 |
+
}
|
419 |
+
}
|
420 |
+
$values['aftership_tracking_provider'] = get_post_meta($order_id, '_aftership_tracking_provider', true);
|
421 |
+
|
422 |
+
if (!$values['aftership_tracking_provider'])
|
423 |
+
return;
|
424 |
+
|
425 |
+
if (!$values['aftership_tracking_number'])
|
426 |
+
return;
|
427 |
+
|
428 |
+
|
429 |
+
$options = get_option('aftership_option_name');
|
430 |
+
if (array_key_exists('track_message_1', $options) && array_key_exists('track_message_2', $options)) {
|
431 |
+
$track_message_1 = $options['track_message_1'];
|
432 |
+
$track_message_2 = $options['track_message_2'];
|
433 |
+
} else {
|
434 |
+
$track_message_1 = 'Your order was shipped via ';
|
435 |
+
$track_message_2 = 'Tracking number is ';
|
436 |
+
}
|
437 |
+
|
438 |
+
$required_fields_values = array();
|
439 |
+
$provider_required_fields = explode(",", $values['aftership_tracking_required_fields']);
|
440 |
+
foreach ($provider_required_fields as $field) {
|
441 |
+
foreach ($this->aftership_fields as $aftership_field) {
|
442 |
+
if (array_key_exists('key', $aftership_field) && $field == $aftership_field['key']) {
|
443 |
+
array_push($required_fields_values, $values[$aftership_field['id']]);
|
444 |
+
}
|
445 |
+
}
|
446 |
+
}
|
447 |
+
|
448 |
+
echo $track_message_1 . $values['aftership_tracking_provider_name'] . '<br/>' . $track_message_2 . $values['aftership_tracking_number'] . ' (' . join(', ', $required_fields_values) . ')';
|
449 |
+
|
450 |
+
if (!$for_email && $this->use_track_button) {
|
451 |
+
$this->display_track_button($values['aftership_tracking_provider'], $values['aftership_tracking_number']);
|
452 |
+
}
|
453 |
+
|
454 |
+
//-------------------------------------------------------------------------------------
|
455 |
+
/*
|
456 |
+
$tracking_provider = get_post_meta($order_id, '_aftership_tracking_provider', true);
|
457 |
+
$tracking_number = get_post_meta($order_id, '_aftership_tracking_number', true);
|
458 |
+
$tracking_provider_name = get_post_meta($order_id, '_aftership_tracking_provider_name', true);
|
459 |
+
$tracking_required_fields = get_post_meta($order_id, '_aftership_tracking_required_fields', true);
|
460 |
+
$date_shipped = get_post_meta($order_id, '_aftership_tracking_shipdate', true);
|
461 |
+
$postcode = get_post_meta($order_id, '_aftership_tracking_postal', true);
|
462 |
+
$account = get_post_meta($order_id, '_aftership_tracking_account', true);
|
463 |
+
|
464 |
+
if (!$tracking_provider)
|
465 |
+
return;
|
466 |
+
|
467 |
+
if (!$tracking_number)
|
468 |
+
return;
|
469 |
+
|
470 |
+
$provider_name = $tracking_provider_name;
|
471 |
+
$provider_required_fields = explode(",", $tracking_required_fields);
|
472 |
+
|
473 |
+
$date_shipped_str = '';
|
474 |
+
$postcode_str = '';
|
475 |
+
$account_str = '';
|
476 |
+
|
477 |
+
foreach ($provider_required_fields as $field) {
|
478 |
+
if ($field == 'tracking_ship_date') {
|
479 |
+
if ($date_shipped) {
|
480 |
+
$date_shipped_str = ' ' . sprintf(__('on %s', 'wc_shipment_tracking'), date_i18n(__('l jS F Y', 'wc_shipment_tracking'), $date_shipped));
|
481 |
+
}
|
482 |
+
} else if ($field == 'tracking_postal_code') {
|
483 |
+
if ($postcode) {
|
484 |
+
$postcode_str = ' ' . sprintf('The postal code is %s.', $postcode);
|
485 |
+
}
|
486 |
+
} else if ($field == 'tracking_account_number') {
|
487 |
+
if ($account) {
|
488 |
+
$account_str = ' ' . sprintf('The account is %s.', $account);
|
489 |
+
}
|
490 |
+
}
|
491 |
+
}
|
492 |
+
|
493 |
+
$provider_name = ' ' . __('via', 'wc_shipment_tracking') . ' <strong>' . $provider_name . '</strong>';
|
494 |
+
|
495 |
+
echo wpautop(sprintf(__('Your order was shipped%s%s. Tracking number is %s.%s%s', 'wc_shipment_tracking'), $date_shipped_str, $provider_name, $tracking_number, $postcode_str, $account_str));
|
496 |
+
|
497 |
+
if (!$for_email && $this->use_track_button) {
|
498 |
+
$this->display_track_button($tracking_provider, $tracking_number);
|
499 |
+
}
|
500 |
+
*/
|
501 |
+
|
502 |
+
}
|
503 |
+
|
504 |
+
private function display_order_wc_shipment_tracking($order_id, $for_email)
|
505 |
+
{
|
506 |
+
if ($for_email || !$this->use_track_button) {
|
507 |
+
return;
|
508 |
+
}
|
509 |
+
|
510 |
+
$tracking = get_post_meta($order_id, '_tracking_number', true);
|
511 |
+
$sharp = strpos($tracking, '#');
|
512 |
+
$colon = strpos($tracking, ':');
|
513 |
+
if ($sharp && $colon && $sharp >= $colon) {
|
514 |
+
return;
|
515 |
+
} else if (!$sharp && $colon) {
|
516 |
+
return;
|
517 |
+
} else if ($sharp) {
|
518 |
+
$tracking_provider = substr($tracking, 0, $sharp);
|
519 |
+
if ($colon) {
|
520 |
+
$tracking_number = substr($tracking, $sharp + 1, $colon - $sharp - 1);
|
521 |
+
} else {
|
522 |
+
$tracking_number = substr($tracking, $sharp + 1, strlen($tracking));
|
523 |
+
}
|
524 |
+
} else {
|
525 |
+
$tracking_provider = '';
|
526 |
+
$tracking_number = $tracking;
|
527 |
+
}
|
528 |
+
if ($tracking_number) {
|
529 |
+
$this->display_track_button($tracking_provider, $tracking_number);
|
530 |
+
}
|
531 |
+
}
|
532 |
+
|
533 |
+
/**
|
534 |
+
* Display shipment info in customer emails.
|
535 |
+
*
|
536 |
+
* @access public
|
537 |
+
* @return void
|
538 |
+
*/
|
539 |
+
function email_display($order)
|
540 |
+
{
|
541 |
+
$this->display_tracking_info($order->id, true);
|
542 |
+
}
|
543 |
+
|
544 |
+
private function display_track_button($tracking_provider, $tracking_number)
|
545 |
+
{
|
546 |
+
|
547 |
+
$js = '(function(e,t,n){var r,i=e.getElementsByTagName(t)[0];if(e.getElementById(n))return;r=e.createElement(t);r.id=n;r.src="//apps.aftership.com/all.js";i.parentNode.insertBefore(r,i)})(document,"script","aftership-jssdk")';
|
548 |
+
if (function_exists('wc_enqueue_js')) {
|
549 |
+
wc_enqueue_js($js);
|
550 |
+
} else {
|
551 |
+
global $woocommerce;
|
552 |
+
$woocommerce->add_inline_js($js);
|
553 |
+
}
|
554 |
+
|
555 |
+
$track_button = '<div id="as-root"></div><div class="as-track-button" data-slug="' . $tracking_provider . '" data-tracking-number="' . $tracking_number . '" data-support="true" data-width="400" data-size="normal" data-hide-tracking-number="true"></div>';
|
556 |
+
echo wpautop(sprintf('%s', $track_button));
|
557 |
+
echo "<br><br>";
|
558 |
+
}
|
559 |
+
}
|
560 |
+
|
561 |
+
if (!function_exists('getAfterShipInstance')) {
|
562 |
+
function getAfterShipInstance()
|
563 |
+
{
|
564 |
+
return AfterShip::Instance();
|
565 |
+
}
|
566 |
+
}
|
567 |
+
}
|
568 |
+
|
569 |
+
/**
|
570 |
+
* Register this class globally
|
571 |
+
*/
|
572 |
+
$GLOBALS['aftership'] = getAfterShipInstance();
|
573 |
|
574 |
}
|
api/class-aftership-api-orders.php
CHANGED
@@ -241,12 +241,22 @@ class AfterShip_API_Orders extends AfterShip_API_Resource
|
|
241 |
$options = get_option('aftership_option_name');
|
242 |
$plugin = $options['plugin'];
|
243 |
if ($plugin == 'aftership') {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
244 |
$order_data['aftership']['woocommerce']['trackings'][] = array(
|
245 |
'tracking_provider' => get_post_meta($order->id, '_aftership_tracking_provider', true),
|
246 |
'tracking_number' => get_post_meta($order->id, '_aftership_tracking_number', true),
|
247 |
-
'
|
248 |
-
'
|
249 |
-
'
|
|
|
|
|
250 |
);
|
251 |
} else if ($plugin == 'wc-shipment-tracking') { //$49
|
252 |
$order_data['aftership']['woocommerce']['trackings'][] = array(
|
241 |
$options = get_option('aftership_option_name');
|
242 |
$plugin = $options['plugin'];
|
243 |
if ($plugin == 'aftership') {
|
244 |
+
|
245 |
+
// $result = array();
|
246 |
+
// foreach($this->aftership_fields as $field){
|
247 |
+
// $id = $field['id'];
|
248 |
+
// $result[substr($id,10)] = get_post_meta($order->id, '_' . $field['id'], true);
|
249 |
+
// }
|
250 |
+
// $order_data['aftership']['woocommerce']['trackings'][] = $result;
|
251 |
+
|
252 |
$order_data['aftership']['woocommerce']['trackings'][] = array(
|
253 |
'tracking_provider' => get_post_meta($order->id, '_aftership_tracking_provider', true),
|
254 |
'tracking_number' => get_post_meta($order->id, '_aftership_tracking_number', true),
|
255 |
+
'tracking_ship_date' => get_post_meta($order->id, '_aftership_tracking_shipdate', true),
|
256 |
+
'tracking_postal_code' => get_post_meta($order->id, '_aftership_tracking_postal', true),
|
257 |
+
'tracking_account_number' => get_post_meta($order->id, '_aftership_tracking_account', true),
|
258 |
+
'tracking_key' => get_post_meta($order->id, '_aftership_tracking_key', true),
|
259 |
+
'tracking_destination_country' => get_post_meta($order->id, '_aftership_tracking_destination_country', true),
|
260 |
);
|
261 |
} else if ($plugin == 'wc-shipment-tracking') { //$49
|
262 |
$order_data['aftership']['woocommerce']['trackings'][] = array(
|
assets/js/admin.js
CHANGED
@@ -1,107 +1,110 @@
|
|
1 |
-
jQuery(function() {
|
2 |
-
|
3 |
-
|
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 |
// console.log(couriers);
|
67 |
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
// jQuery('#aftership_tracking_provider').val(selected_provider);
|
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 |
});
|
1 |
+
jQuery(function () {
|
2 |
+
|
3 |
+
var fields_id = {
|
4 |
+
'tracking_ship_date': 'aftership_tracking_shipdate',
|
5 |
+
'tracking_postal_code': 'aftership_tracking_postal',
|
6 |
+
'tracking_account_number': 'aftership_tracking_account',
|
7 |
+
'tracking_key': 'aftership_tracking_key',
|
8 |
+
'tracking_destination_country': 'aftership_tracking_destination_country'
|
9 |
+
};
|
10 |
+
|
11 |
+
var providers;
|
12 |
+
|
13 |
+
|
14 |
+
function set_aftership_tracking_provider() {
|
15 |
+
function hide_input_and_label(id) {
|
16 |
+
jQuery('#' + id).hide();
|
17 |
+
jQuery('label[for=' + id + ']').hide();
|
18 |
+
}
|
19 |
+
|
20 |
+
function show_input_and_label(id) {
|
21 |
+
jQuery('#' + id).show();
|
22 |
+
jQuery('label[for=' + id + ']').show();
|
23 |
+
}
|
24 |
+
|
25 |
+
jQuery('#aftership_tracking_provider').change(function () {
|
26 |
+
jQuery.each(fields_id, function (index, item) {
|
27 |
+
hide_input_and_label(item);
|
28 |
+
});
|
29 |
+
|
30 |
+
var slug = jQuery(this).val();
|
31 |
+
if (slug) {
|
32 |
+
var provider = providers[slug];
|
33 |
+
var fields = [];
|
34 |
+
if (jQuery.isArray(provider.required_fields)) {
|
35 |
+
fields = provider.required_fields;
|
36 |
+
} else {
|
37 |
+
fields.push(provider.required_fields);
|
38 |
+
}
|
39 |
+
jQuery.each(fields, function (index, item) {
|
40 |
+
if (fields_id[item]){
|
41 |
+
show_input_and_label(fields_id[item]);
|
42 |
+
}
|
43 |
+
});
|
44 |
+
jQuery('#aftership_tracking_provider_name').val(provider.name);
|
45 |
+
jQuery('#aftership_tracking_required_fields').val(fields.join());
|
46 |
+
}
|
47 |
+
});
|
48 |
+
}
|
49 |
+
|
50 |
+
|
51 |
+
function fill_meta_box(couriers_selected) {
|
52 |
+
var response = get_couriers();
|
53 |
+
var couriers = [];
|
54 |
+
jQuery.each(response, function (index, courier) {
|
55 |
+
if (couriers_selected.indexOf(courier.slug) != -1) {
|
56 |
+
couriers.push(courier);
|
57 |
+
}
|
58 |
+
});
|
59 |
+
|
60 |
+
var selected_provider = jQuery('#aftership_tracking_provider_hidden').val();
|
61 |
+
var find_selected_provider = couriers_selected.indexOf(selected_provider) != -1;
|
62 |
+
if (!find_selected_provider) {
|
63 |
+
couriers.push({
|
64 |
+
slug: selected_provider,
|
65 |
+
name: jQuery("#aftership_tracking_provider_name").val(),
|
66 |
+
required_fields: jQuery("#aftership_tracking_required_fields").val()
|
67 |
+
});
|
68 |
+
}
|
69 |
// console.log(couriers);
|
70 |
|
71 |
+
couriers = sort_couriers(couriers);
|
72 |
+
|
73 |
+
jQuery.each(couriers, function (key, courier) {
|
74 |
+
var str = '<option ';
|
75 |
+
if (!find_selected_provider && courier['slug'] == selected_provider) {
|
76 |
+
str += 'style="display:none;" ';
|
77 |
+
}
|
78 |
+
str += 'value="' + courier['slug'] + '" ';
|
79 |
+
if (courier['slug'] == selected_provider) {
|
80 |
+
str += 'selected="selected"';
|
81 |
+
}
|
82 |
+
str += '>' + courier['name'] + '</option>';
|
83 |
+
jQuery('#aftership_tracking_provider').append(str);
|
84 |
+
});
|
85 |
// jQuery('#aftership_tracking_provider').val(selected_provider);
|
86 |
+
jQuery('#aftership_tracking_provider').trigger("chosen:updated");
|
87 |
+
jQuery('#aftership_tracking_provider_chosen').css({width: '100%'});
|
88 |
+
|
89 |
+
providers = {};
|
90 |
+
jQuery.each(couriers, function (index, courier) {
|
91 |
+
providers[courier.slug] = courier;
|
92 |
+
});
|
93 |
+
set_aftership_tracking_provider();
|
94 |
+
jQuery('#aftership_tracking_provider').trigger('change');
|
95 |
+
}
|
96 |
+
|
97 |
+
if (jQuery('#aftership_tracking_provider')) {
|
98 |
+
var couriers_selected = jQuery('#aftership_couriers_selected').val();
|
99 |
+
var couriers_selected_arr = (couriers_selected) ? couriers_selected.split(',') : [];
|
100 |
+
fill_meta_box(couriers_selected_arr);
|
101 |
+
}
|
102 |
+
|
103 |
+
if (jQuery('#aftership_tracking_provider_name')) {
|
104 |
+
jQuery('#aftership_tracking_provider_name').parent().hide();
|
105 |
+
}
|
106 |
+
|
107 |
+
if (jQuery('#aftership_tracking_required_fields')) {
|
108 |
+
jQuery('#aftership_tracking_required_fields').parent().hide();
|
109 |
+
}
|
110 |
});
|
assets/js/couriers.js
CHANGED
@@ -674,6 +674,14 @@ function get_couriers() {
|
|
674 |
"web_url": "http://www.estes-express.com",
|
675 |
"required_fields": []
|
676 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
677 |
{
|
678 |
"slug": "fastway-au",
|
679 |
"name": "Fastway Australia",
|
@@ -730,14 +738,6 @@ function get_couriers() {
|
|
730 |
"web_url": "http://www.jne.co.id/",
|
731 |
"required_fields": []
|
732 |
},
|
733 |
-
{
|
734 |
-
"slug": "flash-courier",
|
735 |
-
"name": "Flash Courier",
|
736 |
-
"phone": "+55 011 5033 3260",
|
737 |
-
"other_name": "Flash Courier Brazil",
|
738 |
-
"web_url": "http://www.jall.com.br/",
|
739 |
-
"required_fields": []
|
740 |
-
},
|
741 |
{
|
742 |
"slug": "flytexpress",
|
743 |
"name": "Flyt Express",
|
@@ -1120,6 +1120,14 @@ function get_couriers() {
|
|
1120 |
"web_url": "http://www.fedex.com/pl/",
|
1121 |
"required_fields": []
|
1122 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1123 |
{
|
1124 |
"slug": "panther",
|
1125 |
"name": "Panther",
|
@@ -1194,6 +1202,14 @@ function get_couriers() {
|
|
1194 |
"web_url": "http://www.posta-romana.ro/",
|
1195 |
"required_fields": []
|
1196 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1197 |
{
|
1198 |
"slug": "poste-italiane",
|
1199 |
"name": "Poste Italiane",
|
@@ -1242,7 +1258,10 @@ function get_couriers() {
|
|
1242 |
"phone": "+31 (0)900 0990",
|
1243 |
"other_name": "TNT Post parcel service United Kingdom",
|
1244 |
"web_url": "http://www.postnl.nl/voorthuis/",
|
1245 |
-
"required_fields": [
|
|
|
|
|
|
|
1246 |
},
|
1247 |
{
|
1248 |
"slug": "postnl-international",
|
@@ -1412,6 +1431,17 @@ function get_couriers() {
|
|
1412 |
"web_url": "http://www.sf-express.com",
|
1413 |
"required_fields": []
|
1414 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1415 |
{
|
1416 |
"slug": "singapore-post",
|
1417 |
"name": "Singapore Post",
|
@@ -1575,7 +1605,7 @@ function get_couriers() {
|
|
1575 |
{
|
1576 |
"slug": "taqbin-sg",
|
1577 |
"name": "TAQBIN Singapore",
|
1578 |
-
"phone": "+65
|
1579 |
"other_name": "Yamato Singapore",
|
1580 |
"web_url": "http://sg.ta-q-bin.com/",
|
1581 |
"required_fields": []
|
674 |
"web_url": "http://www.estes-express.com",
|
675 |
"required_fields": []
|
676 |
},
|
677 |
+
{
|
678 |
+
"slug": "exapaq",
|
679 |
+
"name": "Exapaq",
|
680 |
+
"phone": "+33 (0)1 55 35 02 80 ",
|
681 |
+
"other_name": "DPD France",
|
682 |
+
"web_url": "http://www.exapaq.com/accueil.php",
|
683 |
+
"required_fields": []
|
684 |
+
},
|
685 |
{
|
686 |
"slug": "fastway-au",
|
687 |
"name": "Fastway Australia",
|
738 |
"web_url": "http://www.jne.co.id/",
|
739 |
"required_fields": []
|
740 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
741 |
{
|
742 |
"slug": "flytexpress",
|
743 |
"name": "Flyt Express",
|
1120 |
"web_url": "http://www.fedex.com/pl/",
|
1121 |
"required_fields": []
|
1122 |
},
|
1123 |
+
{
|
1124 |
+
"slug": "packlink",
|
1125 |
+
"name": "Packlink",
|
1126 |
+
"phone": "",
|
1127 |
+
"other_name": "Packlink Spain",
|
1128 |
+
"web_url": "http://www.packlink.es/",
|
1129 |
+
"required_fields": []
|
1130 |
+
},
|
1131 |
{
|
1132 |
"slug": "panther",
|
1133 |
"name": "Panther",
|
1202 |
"web_url": "http://www.posta-romana.ro/",
|
1203 |
"required_fields": []
|
1204 |
},
|
1205 |
+
{
|
1206 |
+
"slug": "postaplus",
|
1207 |
+
"name": "Posta Plus",
|
1208 |
+
"phone": "+965 1881881",
|
1209 |
+
"other_name": "PostaPlus",
|
1210 |
+
"web_url": "http://www.postaplus.com",
|
1211 |
+
"required_fields": []
|
1212 |
+
},
|
1213 |
{
|
1214 |
"slug": "poste-italiane",
|
1215 |
"name": "Poste Italiane",
|
1258 |
"phone": "+31 (0)900 0990",
|
1259 |
"other_name": "TNT Post parcel service United Kingdom",
|
1260 |
"web_url": "http://www.postnl.nl/voorthuis/",
|
1261 |
+
"required_fields": [
|
1262 |
+
"tracking_destination_country",
|
1263 |
+
"tracking_postal_code"
|
1264 |
+
]
|
1265 |
},
|
1266 |
{
|
1267 |
"slug": "postnl-international",
|
1431 |
"web_url": "http://www.sf-express.com",
|
1432 |
"required_fields": []
|
1433 |
},
|
1434 |
+
{
|
1435 |
+
"slug": "sic-teliway",
|
1436 |
+
"name": "Teliway SIC Express",
|
1437 |
+
"phone": "+33 (0) 1 39 37 40 08",
|
1438 |
+
"other_name": "Prevote",
|
1439 |
+
"web_url": "http://sic.teliway.com/appli/vsic/tracking/suivi.php?code=sic&clef=",
|
1440 |
+
"required_fields": [
|
1441 |
+
"tracking_account_number",
|
1442 |
+
"tracking_key"
|
1443 |
+
]
|
1444 |
+
},
|
1445 |
{
|
1446 |
"slug": "singapore-post",
|
1447 |
"name": "Singapore Post",
|
1605 |
{
|
1606 |
"slug": "taqbin-sg",
|
1607 |
"name": "TAQBIN Singapore",
|
1608 |
+
"phone": "+65 1800 225 5888",
|
1609 |
"other_name": "Yamato Singapore",
|
1610 |
"web_url": "http://sg.ta-q-bin.com/",
|
1611 |
"required_fields": []
|
assets/js/setting.js
CHANGED
@@ -1,46 +1,71 @@
|
|
1 |
-
jQuery(function() {
|
2 |
-
|
3 |
-
|
4 |
|
5 |
// console.log(couriers);
|
6 |
|
7 |
-
|
8 |
// console.log(courier.name);
|
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 |
});
|
1 |
+
jQuery(function () {
|
2 |
+
function set_aftership_tracking_provider(selected_couriers) {
|
3 |
+
var couriers = sort_couriers(get_couriers());
|
4 |
|
5 |
// console.log(couriers);
|
6 |
|
7 |
+
jQuery.each(couriers, function (key, courier) {
|
8 |
// console.log(courier.name);
|
9 |
+
var str = '<option ';
|
10 |
+
str += 'value="' + courier['slug'] + '" ';
|
11 |
+
if (selected_couriers.hasOwnProperty(courier['slug'])) {
|
12 |
+
str += 'selected="selected"';
|
13 |
+
}
|
14 |
+
str += '>' + courier['name'] + '</option>';
|
15 |
+
jQuery('#couriers_select').append(str);
|
16 |
+
});
|
17 |
+
|
18 |
+
jQuery('#couriers_select').val(selected_couriers);
|
19 |
+
jQuery('#couriers_select').chosen();
|
20 |
+
}
|
21 |
+
|
22 |
+
function set_track_message_demo(){
|
23 |
+
jQuery('#track_message_demo_1').html(
|
24 |
+
jQuery('#track_message_1').val() + 'UPS' +
|
25 |
+
'<br/>'+
|
26 |
+
jQuery('#track_message_2').val() + '1Z0X118A0324011613'
|
27 |
+
);
|
28 |
+
}
|
29 |
+
|
30 |
+
jQuery('#couriers_select').change(function () {
|
31 |
+
var couriers_select = jQuery('#couriers_select').val();
|
32 |
+
var value = (couriers_select) ? couriers_select.join(',') : '';
|
33 |
+
jQuery('#couriers').val(value);
|
34 |
+
});
|
35 |
+
|
36 |
+
jQuery('#plugin').change(function () {
|
37 |
+
if (jQuery(this).val() == 'aftership') {
|
38 |
+
jQuery('#couriers').parent().parent().show();
|
39 |
+
jQuery('#track_message_demo_1').parent().parent().show();
|
40 |
+
} else {
|
41 |
+
jQuery('#couriers').parent().parent().hide();
|
42 |
+
jQuery('#track_message_demo_1').parent().parent().hide();
|
43 |
+
}
|
44 |
+
})
|
45 |
+
|
46 |
+
if (jQuery('#couriers')) {
|
47 |
+
var couriers_select = jQuery('#couriers').val();
|
48 |
+
var couriers_select_array = (couriers_select) ? couriers_select.split(',') : [];
|
49 |
+
set_aftership_tracking_provider(couriers_select_array);
|
50 |
+
|
51 |
+
if (jQuery('#plugin').val() != 'aftership') {
|
52 |
+
jQuery('#couriers').parent().parent().hide();
|
53 |
+
}
|
54 |
+
}
|
55 |
+
|
56 |
+
if (jQuery('#track_message_demo_1')) {
|
57 |
+
set_track_message_demo();
|
58 |
+
|
59 |
+
if (jQuery('#plugin').val() != 'aftership') {
|
60 |
+
jQuery('#track_message_demo_1').parent().parent().hide();
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
jQuery('#track_message_1').keyup(function () {
|
65 |
+
set_track_message_demo();
|
66 |
+
});
|
67 |
+
|
68 |
+
jQuery('#track_message_2').keyup(function () {
|
69 |
+
set_track_message_demo();
|
70 |
+
});
|
71 |
});
|
class-aftership-api.php
CHANGED
@@ -144,7 +144,6 @@ class AfterShip_API
|
|
144 |
private function includes()
|
145 |
{
|
146 |
|
147 |
-
|
148 |
// API server / response handlers
|
149 |
include_once('api/class-aftership-api-server.php');
|
150 |
include_once('api/interface-aftership-api-handler.php');
|
144 |
private function includes()
|
145 |
{
|
146 |
|
|
|
147 |
// API server / response handlers
|
148 |
include_once('api/class-aftership-api-server.php');
|
149 |
include_once('api/interface-aftership-api-handler.php');
|
class-aftership-settings.php
CHANGED
@@ -145,6 +145,14 @@ class AfterShip_Settings
|
|
145 |
'aftership-setting-admin',
|
146 |
'aftership_setting_section_id'
|
147 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
}
|
149 |
|
150 |
/**
|
@@ -164,7 +172,15 @@ class AfterShip_Settings
|
|
164 |
$new_input['plugin'] = sanitize_text_field($input['plugin']);
|
165 |
}
|
166 |
|
167 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
$new_input['use_track_button'] = true;
|
169 |
}
|
170 |
|
@@ -217,6 +233,24 @@ class AfterShip_Settings
|
|
217 |
);
|
218 |
}
|
219 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
220 |
public function track_button_callback()
|
221 |
{
|
222 |
printf(
|
145 |
'aftership-setting-admin',
|
146 |
'aftership_setting_section_id'
|
147 |
);
|
148 |
+
|
149 |
+
add_settings_field(
|
150 |
+
'track_message',
|
151 |
+
'Content',
|
152 |
+
array($this, 'track_message_callback'),
|
153 |
+
'aftership-setting-admin',
|
154 |
+
'aftership_setting_section_id'
|
155 |
+
);
|
156 |
}
|
157 |
|
158 |
/**
|
172 |
$new_input['plugin'] = sanitize_text_field($input['plugin']);
|
173 |
}
|
174 |
|
175 |
+
if (isset($input['track_message_1'])) {
|
176 |
+
$new_input['track_message_1'] = sanitize_text_field($input['track_message_1']);
|
177 |
+
}
|
178 |
+
|
179 |
+
if (isset($input['track_message_2'])) {
|
180 |
+
$new_input['track_message_2'] = sanitize_text_field($input['track_message_2']);
|
181 |
+
}
|
182 |
+
|
183 |
+
if (isset($input['use_track_button'])) {
|
184 |
$new_input['use_track_button'] = true;
|
185 |
}
|
186 |
|
233 |
);
|
234 |
}
|
235 |
|
236 |
+
public function track_message_callback(){
|
237 |
+
printf(
|
238 |
+
'<input type="text" id="track_message_1" name="aftership_option_name[track_message_1]" value="%s" style="width:100%%">',
|
239 |
+
isset($this->options['track_message_1']) ? $this->options['track_message_1'] : 'Your order was shipped via '
|
240 |
+
);
|
241 |
+
printf('<br/>');
|
242 |
+
printf(
|
243 |
+
'<input type="text" id="track_message_2" name="aftership_option_name[track_message_2]" value="%s" style="width:100%%">',
|
244 |
+
isset($this->options['track_message_2']) ? $this->options['track_message_2'] : 'Tracking number is '
|
245 |
+
);
|
246 |
+
printf('<br/>');
|
247 |
+
printf('<br/>');
|
248 |
+
printf('<b>Demo:</b>');
|
249 |
+
printf(
|
250 |
+
'<div id="track_message_demo_1" style="width:100%%"></div>'
|
251 |
+
);
|
252 |
+
}
|
253 |
+
|
254 |
public function track_button_callback()
|
255 |
{
|
256 |
printf(
|
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: 4.0
|
7 |
-
Stable tag: 1.3.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -95,6 +95,11 @@ You'll find the FAQ on [AfterShip.com](https://aftership.uservoice.com/knowledge
|
|
95 |
|
96 |
== Changelog ==
|
97 |
|
|
|
|
|
|
|
|
|
|
|
98 |
= 1.3.1 =
|
99 |
* Support 231 couriers, please check out supported couriers in https://www.aftership.com/courier
|
100 |
|
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: 4.0
|
7 |
+
Stable tag: 1.3.2
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
95 |
|
96 |
== Changelog ==
|
97 |
|
98 |
+
= 1.3.2 =
|
99 |
+
* Support new couriers, please check out supported couriers in https://www.aftership.com/courier
|
100 |
+
* Support new required field, `tracking key` and `tracking destination country`
|
101 |
+
* Support custom track message on order history page
|
102 |
+
|
103 |
= 1.3.1 =
|
104 |
* Support 231 couriers, please check out supported couriers in https://www.aftership.com/courier
|
105 |
|