Version Description
- No longer require to input AfterShip API key at Wordpress
- Allow carrier selection at Wordpress
- Support PHP 5.2.4 or greater
Download this release
Release Info
Developer | aftership |
Plugin | AfterShip – WooCommerce Tracking |
Version | 1.2.5 |
Comparing to | |
See all releases |
Code changes from version 1.2.4 to 1.2.5
- aftership.php +13 -69
- api/class-aftership-api-orders.php +38 -6
- assets/css/admin.css +0 -15
- assets/js/admin.js +65 -63
- class-aftership-settings.php +33 -22
- readme.txt +13 -8
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.2.
|
7 |
Author: AfterShip
|
8 |
Author URI: http://aftership.com
|
9 |
|
@@ -68,8 +68,7 @@ if (is_woocommerce_active()) {
|
|
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 |
-
|
72 |
-
add_action('wp_ajax_aftership_get_couriers_callback', array(&$this, 'aftership_get_couriers_callback'));
|
73 |
}
|
74 |
|
75 |
// View Order Page
|
@@ -86,6 +85,7 @@ if (is_woocommerce_active()) {
|
|
86 |
|
87 |
add_action('woocommerce_view_order', array(&$this, 'display_tracking_info'));
|
88 |
add_action('woocommerce_email_before_order_table', array(&$this, 'email_display'));
|
|
|
89 |
}
|
90 |
|
91 |
// user profile api key
|
@@ -116,7 +116,6 @@ if (is_woocommerce_active()) {
|
|
116 |
{
|
117 |
include_once('class-aftership-api.php');
|
118 |
include_once('class-aftership-settings.php');
|
119 |
-
include_once('vendor/autoload.php');
|
120 |
}
|
121 |
|
122 |
/**
|
@@ -129,70 +128,17 @@ if (is_woocommerce_active()) {
|
|
129 |
|
130 |
public function admin_styles()
|
131 |
{
|
|
|
132 |
wp_enqueue_style('aftership_styles', plugins_url(basename(dirname(__FILE__))) . '/assets/css/admin.css');
|
133 |
}
|
134 |
|
135 |
public function library_scripts()
|
136 |
{
|
137 |
-
wp_enqueue_script('
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
//todo: not only check shop_order, have to check action=edit too
|
143 |
-
if (get_post_type(get_the_ID()) == 'shop_order') {
|
144 |
-
$js = '
|
145 |
-
jQuery(document).ready(function($) {
|
146 |
-
var data = {
|
147 |
-
"action": "aftership_get_couriers_callback"
|
148 |
-
};
|
149 |
-
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
|
150 |
-
$.post(ajaxurl, data, function(response) {
|
151 |
-
//alert("Got this from the server: " + response);
|
152 |
-
fill_meta_box(response);
|
153 |
-
});
|
154 |
-
});
|
155 |
-
';
|
156 |
-
|
157 |
-
if (function_exists('wc_enqueue_js')) {
|
158 |
-
wc_enqueue_js($js);
|
159 |
-
} else {
|
160 |
-
global $woocommerce;
|
161 |
-
$woocommerce->add_inline_js($js);
|
162 |
-
}
|
163 |
-
}
|
164 |
-
|
165 |
-
}
|
166 |
-
|
167 |
-
public function aftership_get_couriers_callback()
|
168 |
-
{
|
169 |
-
$options = get_option('aftership_option_name');
|
170 |
-
$api_key = $options['api_key'];
|
171 |
-
|
172 |
-
$code = 200;
|
173 |
-
$message = '';
|
174 |
-
$response = '';
|
175 |
-
if (!$api_key) {
|
176 |
-
$code = 800; // no api key
|
177 |
-
$message = 'No Api Key';
|
178 |
-
} else {
|
179 |
-
$courier = new AfterShip\Couriers($api_key);
|
180 |
-
$response = $courier->get();
|
181 |
-
if ($response['meta']['code'] == 401) {
|
182 |
-
$code = 401;
|
183 |
-
$message = 'Invalid API';
|
184 |
-
} else if ($response['meta']['code'] != 200) {
|
185 |
-
$code = $response['meta']['code'];
|
186 |
-
$message = $response['meta']['message'];
|
187 |
-
}
|
188 |
-
}
|
189 |
-
|
190 |
-
$result = array(
|
191 |
-
'code' => $code,
|
192 |
-
'message' => $message,
|
193 |
-
'response' => $response);
|
194 |
-
echo json_encode($result);
|
195 |
-
die;
|
196 |
}
|
197 |
|
198 |
/**
|
@@ -218,11 +164,6 @@ if (is_woocommerce_active()) {
|
|
218 |
|
219 |
$selected_provider = get_post_meta($post->ID, '_aftership_tracking_provider', true);
|
220 |
|
221 |
-
|
222 |
-
echo '<div id="aftership_spinner"></div>';
|
223 |
-
echo '<div id="aftership_error_insert_api" class="aftership_error"><a href="options-general.php?page=aftership-setting-admin">Please insert your AfterShip API Key</a></div>';
|
224 |
-
echo '<div id="aftership_error_update_api" class="aftership_error"><a href="options-general.php?page=aftership-setting-admin">Error - Update AfterShip API Key</a></div>';
|
225 |
-
echo '<div id="aftership_error" class="aftership_error"></div>';
|
226 |
echo '<div id="aftership_wrapper">';
|
227 |
|
228 |
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%">';
|
@@ -233,8 +174,11 @@ if (is_woocommerce_active()) {
|
|
233 |
}
|
234 |
echo '<option disabled ' . $selected_text . ' value="">Please Select</option>';
|
235 |
echo '</select>';
|
236 |
-
echo '<br><a href="
|
237 |
echo '<input type="hidden" id="aftership_tracking_provider_hidden" value="' . $selected_provider . '"/>';
|
|
|
|
|
|
|
238 |
|
239 |
woocommerce_wp_text_input(array(
|
240 |
'id' => 'aftership_tracking_provider_name',
|
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.2.5
|
7 |
Author: AfterShip
|
8 |
Author URI: http://aftership.com
|
9 |
|
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
|
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
|
116 |
{
|
117 |
include_once('class-aftership-api.php');
|
118 |
include_once('class-aftership-settings.php');
|
|
|
119 |
}
|
120 |
|
121 |
/**
|
128 |
|
129 |
public function admin_styles()
|
130 |
{
|
131 |
+
wp_enqueue_style('aftership_styles_chosen', plugins_url(basename(dirname(__FILE__))) . '/assets/plugin/chosen/chosen.min.css');
|
132 |
wp_enqueue_style('aftership_styles', plugins_url(basename(dirname(__FILE__))) . '/assets/css/admin.css');
|
133 |
}
|
134 |
|
135 |
public function library_scripts()
|
136 |
{
|
137 |
+
wp_enqueue_script('aftership_styles_chosen_jquery', plugins_url(basename(dirname(__FILE__))) . '/assets/plugin/chosen/chosen.jquery.min.js');
|
138 |
+
wp_enqueue_script('aftership_styles_chosen_proto', plugins_url(basename(dirname(__FILE__))) . '/assets/plugin/chosen/chosen.proto.min.js');
|
139 |
+
wp_enqueue_script('aftership_script_util', plugins_url(basename(dirname(__FILE__))) . '/assets/js/util.js');
|
140 |
+
wp_enqueue_script('aftership_script_couriers', plugins_url(basename(dirname(__FILE__))) . '/assets/js/couriers.js');
|
141 |
+
wp_enqueue_script('aftership_script_admin', plugins_url(basename(dirname(__FILE__))) . '/assets/js/admin.js');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
}
|
143 |
|
144 |
/**
|
164 |
|
165 |
$selected_provider = get_post_meta($post->ID, '_aftership_tracking_provider', true);
|
166 |
|
|
|
|
|
|
|
|
|
|
|
167 |
echo '<div id="aftership_wrapper">';
|
168 |
|
169 |
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%">';
|
174 |
}
|
175 |
echo '<option disabled ' . $selected_text . ' value="">Please Select</option>';
|
176 |
echo '</select>';
|
177 |
+
echo '<br><a href="options-general.php?page=aftership-setting-admin">Update carrier list</a>';
|
178 |
echo '<input type="hidden" id="aftership_tracking_provider_hidden" value="' . $selected_provider . '"/>';
|
179 |
+
echo '<input type="hidden" id="aftership_couriers_selected" value="' . $this->couriers . '"/>';
|
180 |
+
|
181 |
+
|
182 |
|
183 |
woocommerce_wp_text_input(array(
|
184 |
'id' => 'aftership_tracking_provider_name',
|
api/class-aftership-api-orders.php
CHANGED
@@ -378,12 +378,44 @@ class AfterShip_API_Orders extends AfterShip_API_Resource
|
|
378 |
private function query_orders($args)
|
379 |
{
|
380 |
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
387 |
|
388 |
// add status argument
|
389 |
if (!empty($args['status'])) {
|
378 |
private function query_orders($args)
|
379 |
{
|
380 |
|
381 |
+
function wpbo_get_woo_version_number()
|
382 |
+
{
|
383 |
+
// If get_plugins() isn't available, require it
|
384 |
+
if (!function_exists('get_plugins'))
|
385 |
+
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
|
386 |
+
|
387 |
+
// Create the plugins folder and file variables
|
388 |
+
$plugin_folder = get_plugins('/' . 'woocommerce');
|
389 |
+
$plugin_file = 'woocommerce.php';
|
390 |
+
|
391 |
+
// If the plugin version number is set, return it
|
392 |
+
if (isset($plugin_folder[$plugin_file]['Version'])) {
|
393 |
+
return $plugin_folder[$plugin_file]['Version'];
|
394 |
+
|
395 |
+
} else {
|
396 |
+
// Otherwise return null
|
397 |
+
return NULL;
|
398 |
+
}
|
399 |
+
}
|
400 |
+
|
401 |
+
$woo_version = wpbo_get_woo_version_number();
|
402 |
+
|
403 |
+
if ($woo_version >= 2.2) {
|
404 |
+
// set base query arguments
|
405 |
+
$query_args = array(
|
406 |
+
'fields' => 'ids',
|
407 |
+
'post_type' => 'shop_order',
|
408 |
+
// 'post_status' => 'publish',
|
409 |
+
'post_status' => array_keys(wc_get_order_statuses())
|
410 |
+
);
|
411 |
+
} else {
|
412 |
+
// set base query arguments
|
413 |
+
$query_args = array(
|
414 |
+
'fields' => 'ids',
|
415 |
+
'post_type' => 'shop_order',
|
416 |
+
'post_status' => 'publish',
|
417 |
+
);
|
418 |
+
}
|
419 |
|
420 |
// add status argument
|
421 |
if (!empty($args['status'])) {
|
assets/css/admin.css
CHANGED
@@ -2,25 +2,10 @@
|
|
2 |
display: none;
|
3 |
}
|
4 |
|
5 |
-
#aftership_wrapper {
|
6 |
-
display: none;
|
7 |
-
}
|
8 |
-
|
9 |
-
#aftership_spinner {
|
10 |
-
background: url('../image/loadingAnimation.gif') no-repeat;
|
11 |
-
opacity: .7;
|
12 |
-
filter: alpha(opacity=70);
|
13 |
-
height: 16px;
|
14 |
-
}
|
15 |
-
|
16 |
#aftership_tracking_provider {
|
17 |
width: 100%;
|
18 |
}
|
19 |
|
20 |
-
.aftership_error {
|
21 |
-
display: none;
|
22 |
-
}
|
23 |
-
|
24 |
.aftership_input_text {
|
25 |
width: 300px;
|
26 |
}
|
2 |
display: none;
|
3 |
}
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
#aftership_tracking_provider {
|
6 |
width: 100%;
|
7 |
}
|
8 |
|
|
|
|
|
|
|
|
|
9 |
.aftership_input_text {
|
10 |
width: 300px;
|
11 |
}
|
assets/js/admin.js
CHANGED
@@ -1,78 +1,75 @@
|
|
1 |
-
|
2 |
|
3 |
|
4 |
-
|
5 |
-
function hide_input_and_label(id) {
|
6 |
-
jQuery('#' + id).hide();
|
7 |
-
jQuery('label[for=' + id + ']').hide();
|
8 |
-
}
|
9 |
|
10 |
-
function show_input_and_label(id) {
|
11 |
-
jQuery('#' + id).show();
|
12 |
-
jQuery('label[for=' + id + ']').show();
|
13 |
-
}
|
14 |
|
15 |
-
|
16 |
-
hide_input_and_label(
|
17 |
-
|
18 |
-
|
|
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
var fields = [];
|
24 |
-
if (jQuery.isArray(provider.required_fields)) {
|
25 |
-
fields = provider.required_fields;
|
26 |
-
} else {
|
27 |
-
fields.push(provider.required_fields);
|
28 |
-
}
|
29 |
-
jQuery.each(fields, function(index, item) {
|
30 |
-
if (item == 'tracking_ship_date') {
|
31 |
-
show_input_and_label('aftership_tracking_shipdate');
|
32 |
-
} else if (item == 'tracking_postal_code') {
|
33 |
-
show_input_and_label('aftership_tracking_postal');
|
34 |
-
} else if (item == 'tracking_account_number') {
|
35 |
-
show_input_and_label('aftership_tracking_account');
|
36 |
-
}
|
37 |
-
});
|
38 |
-
jQuery('#aftership_tracking_provider_name').val(provider.name);
|
39 |
-
jQuery('#aftership_tracking_required_fields').val(fields.join());
|
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 |
var selected_provider = jQuery('#aftership_tracking_provider_hidden').val();
|
66 |
-
|
67 |
-
|
|
|
68 |
slug: selected_provider,
|
69 |
name: jQuery("#aftership_tracking_provider_name").val(),
|
70 |
required_fields: jQuery("#aftership_tracking_required_fields").val()
|
71 |
-
};
|
72 |
}
|
|
|
|
|
|
|
|
|
73 |
jQuery.each(couriers, function(key, courier) {
|
74 |
var str = '<option ';
|
75 |
-
if (courier['slug'] == selected_provider) {
|
76 |
str += 'style="display:none;" ';
|
77 |
}
|
78 |
str += 'value="' + courier['slug'] + '" ';
|
@@ -82,16 +79,21 @@ function fill_meta_box(json) {
|
|
82 |
str += '>' + courier['name'] + '</option>';
|
83 |
jQuery('#aftership_tracking_provider').append(str);
|
84 |
});
|
|
|
85 |
jQuery('#aftership_tracking_provider').trigger("chosen:updated");
|
86 |
jQuery('#aftership_tracking_provider_chosen').css({width: '100%'});
|
87 |
|
88 |
-
providers =
|
|
|
|
|
|
|
89 |
set_aftership_tracking_provider();
|
90 |
jQuery('#aftership_tracking_provider').trigger('change');
|
91 |
-
|
92 |
-
jQuery('#aftership_spinner').fadeOut(function() {
|
93 |
-
jQuery('#aftership_wrapper').fadeIn();
|
94 |
-
});
|
95 |
}
|
96 |
-
}
|
97 |
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
jQuery(function() {
|
2 |
|
3 |
|
4 |
+
var providers;
|
|
|
|
|
|
|
|
|
5 |
|
|
|
|
|
|
|
|
|
6 |
|
7 |
+
function set_aftership_tracking_provider() {
|
8 |
+
function hide_input_and_label(id) {
|
9 |
+
jQuery('#' + id).hide();
|
10 |
+
jQuery('label[for=' + id + ']').hide();
|
11 |
+
}
|
12 |
|
13 |
+
function show_input_and_label(id) {
|
14 |
+
jQuery('#' + id).show();
|
15 |
+
jQuery('label[for=' + id + ']').show();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
}
|
|
|
|
|
17 |
|
18 |
+
jQuery('#aftership_tracking_provider').change(function() {
|
19 |
+
hide_input_and_label('aftership_tracking_shipdate');
|
20 |
+
hide_input_and_label('aftership_tracking_postal');
|
21 |
+
hide_input_and_label('aftership_tracking_account');
|
22 |
|
23 |
+
var slug = jQuery(this).val();
|
24 |
+
if (slug) {
|
25 |
+
var provider = providers[slug];
|
26 |
+
var fields = [];
|
27 |
+
if (jQuery.isArray(provider.required_fields)) {
|
28 |
+
fields = provider.required_fields;
|
29 |
+
} else {
|
30 |
+
fields.push(provider.required_fields);
|
31 |
+
}
|
32 |
+
jQuery.each(fields, function(index, item) {
|
33 |
+
if (item == 'tracking_ship_date') {
|
34 |
+
show_input_and_label('aftership_tracking_shipdate');
|
35 |
+
} else if (item == 'tracking_postal_code') {
|
36 |
+
show_input_and_label('aftership_tracking_postal');
|
37 |
+
} else if (item == 'tracking_account_number') {
|
38 |
+
show_input_and_label('aftership_tracking_account');
|
39 |
+
}
|
40 |
+
});
|
41 |
+
jQuery('#aftership_tracking_provider_name').val(provider.name);
|
42 |
+
jQuery('#aftership_tracking_required_fields').val(fields.join());
|
43 |
+
}
|
44 |
});
|
45 |
+
}
|
46 |
+
|
47 |
+
|
48 |
+
function fill_meta_box(couriers_selected) {
|
49 |
+
var response = get_couriers();
|
50 |
+
var couriers = [];
|
51 |
+
jQuery.each(response, function(index, courier) {
|
52 |
+
if (couriers_selected.indexOf(courier.slug) != -1) {
|
53 |
+
couriers.push(courier);
|
54 |
+
}
|
55 |
});
|
56 |
|
57 |
var selected_provider = jQuery('#aftership_tracking_provider_hidden').val();
|
58 |
+
var find_selected_provider = couriers_selected.indexOf(selected_provider) != -1;
|
59 |
+
if (!find_selected_provider) {
|
60 |
+
couriers.push({
|
61 |
slug: selected_provider,
|
62 |
name: jQuery("#aftership_tracking_provider_name").val(),
|
63 |
required_fields: jQuery("#aftership_tracking_required_fields").val()
|
64 |
+
});
|
65 |
}
|
66 |
+
// console.log(couriers);
|
67 |
+
|
68 |
+
couriers = sort_couriers(couriers);
|
69 |
+
|
70 |
jQuery.each(couriers, function(key, courier) {
|
71 |
var str = '<option ';
|
72 |
+
if (!find_selected_provider && courier['slug'] == selected_provider) {
|
73 |
str += 'style="display:none;" ';
|
74 |
}
|
75 |
str += 'value="' + courier['slug'] + '" ';
|
79 |
str += '>' + courier['name'] + '</option>';
|
80 |
jQuery('#aftership_tracking_provider').append(str);
|
81 |
});
|
82 |
+
// jQuery('#aftership_tracking_provider').val(selected_provider);
|
83 |
jQuery('#aftership_tracking_provider').trigger("chosen:updated");
|
84 |
jQuery('#aftership_tracking_provider_chosen').css({width: '100%'});
|
85 |
|
86 |
+
providers = {};
|
87 |
+
jQuery.each(couriers, function(index,courier){
|
88 |
+
providers[courier.slug] = courier;
|
89 |
+
});
|
90 |
set_aftership_tracking_provider();
|
91 |
jQuery('#aftership_tracking_provider').trigger('change');
|
|
|
|
|
|
|
|
|
92 |
}
|
|
|
93 |
|
94 |
+
if (jQuery('#aftership_tracking_provider')) {
|
95 |
+
var couriers_selected = jQuery('#aftership_couriers_selected').val();
|
96 |
+
var couriers_selected_arr = (couriers_selected) ? couriers_selected.split(',') : [];
|
97 |
+
fill_meta_box(couriers_selected_arr);
|
98 |
+
}
|
99 |
+
});
|
class-aftership-settings.php
CHANGED
@@ -46,14 +46,25 @@ class AfterShip_Settings
|
|
46 |
add_action('admin_menu', array($this, 'add_plugin_page'));
|
47 |
add_action('admin_init', array($this, 'page_init'));
|
48 |
add_action('admin_print_styles', array($this, 'admin_styles'));
|
|
|
49 |
}
|
50 |
|
51 |
|
52 |
public function admin_styles()
|
53 |
{
|
|
|
54 |
wp_enqueue_style('aftership_styles', plugins_url(basename(dirname(__FILE__))) . '/assets/css/admin.css');
|
55 |
}
|
56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
/**
|
58 |
* Add options page
|
59 |
*/
|
@@ -112,24 +123,24 @@ class AfterShip_Settings
|
|
112 |
);
|
113 |
|
114 |
add_settings_field(
|
115 |
-
'
|
116 |
-
'
|
117 |
-
array($this, '
|
118 |
'aftership-setting-admin',
|
119 |
'aftership_setting_section_id'
|
120 |
);
|
121 |
|
122 |
add_settings_field(
|
123 |
-
'
|
124 |
-
'
|
125 |
-
array($this, '
|
126 |
'aftership-setting-admin',
|
127 |
'aftership_setting_section_id'
|
128 |
);
|
129 |
|
130 |
add_settings_field(
|
131 |
'use_track_button',
|
132 |
-
'
|
133 |
array($this, 'track_button_callback'),
|
134 |
'aftership-setting-admin',
|
135 |
'aftership_setting_section_id'
|
@@ -145,8 +156,8 @@ class AfterShip_Settings
|
|
145 |
{
|
146 |
$new_input = array();
|
147 |
|
148 |
-
if (isset($input['
|
149 |
-
$new_input['
|
150 |
}
|
151 |
|
152 |
if (isset($input['plugin'])) {
|
@@ -157,7 +168,6 @@ class AfterShip_Settings
|
|
157 |
$new_input['use_track_button'] = true;
|
158 |
}
|
159 |
|
160 |
-
|
161 |
return $new_input;
|
162 |
}
|
163 |
|
@@ -169,18 +179,19 @@ class AfterShip_Settings
|
|
169 |
//print 'Enter your settings below:';
|
170 |
}
|
171 |
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
);
|
|
|
184 |
}
|
185 |
|
186 |
public function plugin_callback()
|
46 |
add_action('admin_menu', array($this, 'add_plugin_page'));
|
47 |
add_action('admin_init', array($this, 'page_init'));
|
48 |
add_action('admin_print_styles', array($this, 'admin_styles'));
|
49 |
+
add_action('admin_print_scripts', array(&$this, 'library_scripts'));
|
50 |
}
|
51 |
|
52 |
|
53 |
public function admin_styles()
|
54 |
{
|
55 |
+
wp_enqueue_style('aftership_styles_chosen', plugins_url(basename(dirname(__FILE__))) . '/assets/plugin/chosen/chosen.min.css');
|
56 |
wp_enqueue_style('aftership_styles', plugins_url(basename(dirname(__FILE__))) . '/assets/css/admin.css');
|
57 |
}
|
58 |
|
59 |
+
public function library_scripts()
|
60 |
+
{
|
61 |
+
wp_enqueue_script('aftership_styles_chosen_jquery', plugins_url(basename(dirname(__FILE__))) . '/assets/plugin/chosen/chosen.jquery.min.js');
|
62 |
+
wp_enqueue_script('aftership_styles_chosen_proto', plugins_url(basename(dirname(__FILE__))) . '/assets/plugin/chosen/chosen.proto.min.js');
|
63 |
+
wp_enqueue_script('aftership_script_util', plugins_url(basename(dirname(__FILE__))) . '/assets/js/util.js');
|
64 |
+
wp_enqueue_script('aftership_script_couriers', plugins_url(basename(dirname(__FILE__))) . '/assets/js/couriers.js');
|
65 |
+
wp_enqueue_script('aftership_script_setting', plugins_url(basename(dirname(__FILE__))) . '/assets/js/setting.js');
|
66 |
+
}
|
67 |
+
|
68 |
/**
|
69 |
* Add options page
|
70 |
*/
|
123 |
);
|
124 |
|
125 |
add_settings_field(
|
126 |
+
'plugin',
|
127 |
+
'Plugin',
|
128 |
+
array($this, 'plugin_callback'),
|
129 |
'aftership-setting-admin',
|
130 |
'aftership_setting_section_id'
|
131 |
);
|
132 |
|
133 |
add_settings_field(
|
134 |
+
'couriers',
|
135 |
+
'Couriers',
|
136 |
+
array($this, 'couriers_callback'),
|
137 |
'aftership-setting-admin',
|
138 |
'aftership_setting_section_id'
|
139 |
);
|
140 |
|
141 |
add_settings_field(
|
142 |
'use_track_button',
|
143 |
+
'Display Track Button at Order History Page',
|
144 |
array($this, 'track_button_callback'),
|
145 |
'aftership-setting-admin',
|
146 |
'aftership_setting_section_id'
|
156 |
{
|
157 |
$new_input = array();
|
158 |
|
159 |
+
if (isset($input['couriers'])) {
|
160 |
+
$new_input['couriers'] = sanitize_text_field($input['couriers']);
|
161 |
}
|
162 |
|
163 |
if (isset($input['plugin'])) {
|
168 |
$new_input['use_track_button'] = true;
|
169 |
}
|
170 |
|
|
|
171 |
return $new_input;
|
172 |
}
|
173 |
|
179 |
//print 'Enter your settings below:';
|
180 |
}
|
181 |
|
182 |
+
public function couriers_callback(){
|
183 |
+
|
184 |
+
$couriers = [];
|
185 |
+
if (isset($this->options['couriers'])){
|
186 |
+
$couriers = explode(',', $this->options['couriers']);
|
187 |
+
}
|
188 |
+
|
189 |
+
// print_r($couriers);
|
190 |
+
echo '<select data-placeholder="Please select couriers" id="couriers_select" class="chosen-select " multiple style="width:100%">';
|
191 |
+
echo '</select>';
|
192 |
+
// echo '<br><a href="https://www.aftership.com/settings/courier" target="_blank">Update carrier list</a>';
|
193 |
+
echo '<input type="hidden" id="couriers" name="aftership_option_name[couriers]" value="' . implode(",", $couriers) . '"/>';
|
194 |
+
|
195 |
}
|
196 |
|
197 |
public function plugin_callback()
|
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.2.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -60,13 +60,12 @@ Correos de Mexico • Estafeta • Mexico Senda Express • Mexico Redpack • M
|
|
60 |
|
61 |
1. [Sign up AfterShip account for FREE](https://www.aftership.com/signup)
|
62 |
2. [Download AfterShip plugin](http://downloads.wordpress.org/plugin/aftership-woocommerce-tracking.zip), then install and activate at wordpress.
|
63 |
-
3.
|
64 |
-
4.
|
65 |
-
5.
|
66 |
-
6.
|
67 |
-
7. Input `Store URL` and `AfterShip's WordPress API Key` at [AfterShip WooCommerce page](https://www.aftership.com/apps/woocommerce)
|
68 |
|
69 |
-
*** This plugin requires at least PHP 5.
|
70 |
*** This plugin requires at least WooCommerce 2.1
|
71 |
|
72 |
###Further Reading
|
@@ -96,6 +95,12 @@ You'll find the FAQ on [AfterShip.com](https://aftership.uservoice.com/knowledge
|
|
96 |
|
97 |
== Changelog ==
|
98 |
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
= 1.2.4 =
|
100 |
* Fix enable track button issues
|
101 |
* Support at least WooCommerce 2.1
|
@@ -170,4 +175,4 @@ You'll find the FAQ on [AfterShip.com](https://aftership.uservoice.com/knowledge
|
|
170 |
|
171 |
== Upgrade Notice ==
|
172 |
|
173 |
-
No Upgrade Yet
|
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.2.5
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
60 |
|
61 |
1. [Sign up AfterShip account for FREE](https://www.aftership.com/signup)
|
62 |
2. [Download AfterShip plugin](http://downloads.wordpress.org/plugin/aftership-woocommerce-tracking.zip), then install and activate at wordpress.
|
63 |
+
3. Select AfterShip Plugin or [WooCommerce Shipment Tracking Plugin](http://www.woothemes.com/products/shipment-tracking/) for entering tracking number
|
64 |
+
4. Check `Use Track Button` for displaying tracking info at order history page
|
65 |
+
5. Generate [AfterShip's WordPress API Key](http://aftership.uservoice.com/knowledgebase/articles/405909) under `Users` > `Your Profile`
|
66 |
+
6. Input `Store URL` and `AfterShip's WordPress API Key` at [AfterShip WooCommerce page](https://www.aftership.com/apps/woocommerce)
|
|
|
67 |
|
68 |
+
*** This plugin requires at least PHP 5.2.4
|
69 |
*** This plugin requires at least WooCommerce 2.1
|
70 |
|
71 |
###Further Reading
|
95 |
|
96 |
== Changelog ==
|
97 |
|
98 |
+
= 1.2.5 =
|
99 |
+
* No longer require to input AfterShip API key at Wordpress
|
100 |
+
* Allow carrier selection at Wordpress
|
101 |
+
* Support PHP 5.2.4 or greater
|
102 |
+
|
103 |
+
|
104 |
= 1.2.4 =
|
105 |
* Fix enable track button issues
|
106 |
* Support at least WooCommerce 2.1
|
175 |
|
176 |
== Upgrade Notice ==
|
177 |
|
178 |
+
No Upgrade Yet
|