wood chen 64e952903a Update system requirements and enhance plugin functionality
- Updated system requirements in the README to reflect compatibility with WordPress 6.0+ and PHP 7.4+.
- Revised usage steps for better clarity on plugin installation and configuration.
- Improved order management features, including AJAX handling for shipment creation and tracking updates.
- Added new custom order statuses (In Transit, Delivered) for better order tracking.
- Enhanced error handling and logging during shipment creation and tracking updates.
- Introduced chargeable weight calculation for shipping rates based on product dimensions and weight.

These changes enhance the overall performance and usability of the CZL Express plugin.
2024-12-20 03:03:12 +08:00

125 lines
4.1 KiB
JavaScript

jQuery(document).ready(function($) {
// 创建运单按钮点击事件
$('.czl-create-shipment').on('click', function(e) {
e.preventDefault();
var button = $(this);
var order_id = button.data('order-id');
button.prop('disabled', true).text(czl_ajax.creating_text);
$.ajax({
url: czl_ajax.ajax_url,
type: 'POST',
data: {
action: 'czl_create_shipment',
order_id: order_id,
nonce: czl_ajax.nonce
},
success: function(response) {
if (response.success) {
button.text(czl_ajax.success_text);
location.reload();
} else {
button.text(czl_ajax.error_text);
alert(response.data);
}
},
error: function() {
button.text(czl_ajax.error_text);
alert('请求失败,请重试');
},
complete: function() {
button.prop('disabled', false);
}
});
});
// 更新跟踪单号对话框
var trackingDialog = $('<div id="czl-tracking-dialog" title="更新跟踪单号">' +
'<p>请输入新的跟踪单号:</p>' +
'<input type="text" id="czl-tracking-number" style="width: 100%;">' +
'</div>').dialog({
autoOpen: false,
modal: true,
width: 400,
buttons: {
"更新": function() {
var dialog = $(this);
var button = dialog.data('button');
var order_id = button.data('order-id');
var tracking_number = $('#czl-tracking-number').val();
if (!tracking_number) {
alert('请输入跟踪单号');
return;
}
$.ajax({
url: czl_ajax.ajax_url,
type: 'POST',
data: {
action: 'czl_update_tracking_number',
order_id: order_id,
tracking_number: tracking_number,
nonce: czl_ajax.nonce
},
success: function(response) {
if (response.success) {
location.reload();
} else {
alert(response.data);
}
},
error: function() {
alert('请求失败,请重试');
}
});
},
"取消": function() {
$(this).dialog('close');
}
}
});
// 更新跟踪单号按钮点击事件
$('.czl-update-tracking').on('click', function(e) {
e.preventDefault();
var button = $(this);
var currentTracking = button.data('tracking');
$('#czl-tracking-number').val(currentTracking || '');
trackingDialog.data('button', button).dialog('open');
});
// 更新轨迹信息按钮点击事件
$('.czl-update-tracking-info').on('click', function(e) {
e.preventDefault();
var button = $(this);
var order_id = button.data('order-id');
button.prop('disabled', true).text('更新中...');
$.ajax({
url: czl_ajax.ajax_url,
type: 'POST',
data: {
action: 'czl_update_tracking_info',
order_id: order_id,
nonce: czl_ajax.nonce
},
success: function(response) {
if (response.success) {
location.reload();
} else {
alert(response.data);
}
},
error: function() {
alert('请求失败,请重试');
},
complete: function() {
button.prop('disabled', false).text('更新轨迹');
}
});
});
});