mirror of
https://github.com/woodchen-ink/czlexpress-for-woocommerce.git
synced 2025-07-19 06:21:57 +08:00
Refactor and Update CZL Express for WooCommerce Plugin
- Renamed the plugin from "woocommerce-czlexpress" to "CZL Express for WooCommerce" for better branding. - Updated README and readme.txt files to reflect the new plugin name and improved description. - Enhanced system requirements to support PHP 8.0 and tested compatibility with WordPress 6.7. - Removed outdated files and references, including the main plugin file and language files. - Improved localization by updating text domain references throughout the codebase. - Streamlined the admin interface for better usability, including updated labels and descriptions. These changes enhance the clarity, performance, and user experience of the CZL Express plugin.
This commit is contained in:
parent
dfc64b1daf
commit
7b7f41d0cc
@ -9,10 +9,10 @@ $tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'settings';
|
||||
|
||||
<nav class="nav-tab-wrapper">
|
||||
<a href="?page=czl-express&tab=settings" class="nav-tab <?php echo $tab === 'settings' ? 'nav-tab-active' : ''; ?>">
|
||||
<?php _e('基本设置', 'woo-czl-express'); ?>
|
||||
<?php _e('基本设置', 'czlexpress-for-woocommerce'); ?>
|
||||
</a>
|
||||
<a href="?page=czl-express&tab=test" class="nav-tab <?php echo $tab === 'test' ? 'nav-tab-active' : ''; ?>">
|
||||
<?php _e('接口测试', 'woo-czl-express'); ?>
|
||||
<?php _e('接口测试', 'czlexpress-for-woocommerce'); ?>
|
||||
</a>
|
||||
</nav>
|
||||
|
||||
@ -20,10 +20,10 @@ $tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'settings';
|
||||
<?php
|
||||
switch ($tab) {
|
||||
case 'test':
|
||||
require_once WOO_CZL_EXPRESS_PATH . 'admin/views/api-test.php';
|
||||
require_once CZL_EXPRESS_PATH . 'admin/views/api-test.php';
|
||||
break;
|
||||
default:
|
||||
require_once WOO_CZL_EXPRESS_PATH . 'admin/views/settings.php';
|
||||
require_once CZL_EXPRESS_PATH . 'admin/views/settings.php';
|
||||
break;
|
||||
}
|
||||
?>
|
||||
|
@ -3,55 +3,55 @@ defined('ABSPATH') || exit;
|
||||
|
||||
$settings = array(
|
||||
array(
|
||||
'title' => __('API Settings', 'woo-czl-express'),
|
||||
'title' => __('API Settings', 'czlexpress-for-woocommerce'),
|
||||
'type' => 'title',
|
||||
'id' => 'czl_api_settings'
|
||||
),
|
||||
array(
|
||||
'title' => __('API URL', 'woo-czl-express'),
|
||||
'title' => __('API URL', 'czlexpress-for-woocommerce'),
|
||||
'type' => 'text',
|
||||
'id' => 'czl_api_url',
|
||||
'desc' => __('Enter the CZL Express API URL', 'woo-czl-express'),
|
||||
'desc' => __('Enter the CZL Express API URL', 'czlexpress-for-woocommerce'),
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'title' => __('Username', 'woo-czl-express'),
|
||||
'title' => __('Username', 'czlexpress-for-woocommerce'),
|
||||
'type' => 'text',
|
||||
'id' => 'czl_username',
|
||||
'desc' => __('Enter your CZL Express API username', 'woo-czl-express'),
|
||||
'desc' => __('Enter your CZL Express API username', 'czlexpress-for-woocommerce'),
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'title' => __('Password', 'woo-czl-express'),
|
||||
'title' => __('Password', 'czlexpress-for-woocommerce'),
|
||||
'type' => 'password',
|
||||
'id' => 'czl_password',
|
||||
'desc' => __('Enter your CZL Express API password', 'woo-czl-express'),
|
||||
'desc' => __('Enter your CZL Express API password', 'czlexpress-for-woocommerce'),
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'title' => __('Warehouse Settings', 'woo-czl-express'),
|
||||
'title' => __('Warehouse Settings', 'czlexpress-for-woocommerce'),
|
||||
'type' => 'title',
|
||||
'id' => 'czl_warehouse_settings'
|
||||
),
|
||||
array(
|
||||
'title' => __('Province', 'woo-czl-express'),
|
||||
'title' => __('Province', 'czlexpress-for-woocommerce'),
|
||||
'type' => 'text',
|
||||
'id' => 'czl_warehouse_province',
|
||||
'desc' => __('Enter warehouse province', 'woo-czl-express'),
|
||||
'desc' => __('Enter warehouse province', 'czlexpress-for-woocommerce'),
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'title' => __('City', 'woo-czl-express'),
|
||||
'title' => __('City', 'czlexpress-for-woocommerce'),
|
||||
'type' => 'text',
|
||||
'id' => 'czl_warehouse_city',
|
||||
'desc' => __('Enter warehouse city', 'woo-czl-express'),
|
||||
'desc' => __('Enter warehouse city', 'czlexpress-for-woocommerce'),
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'title' => __('Address', 'woo-czl-express'),
|
||||
'title' => __('Address', 'czlexpress-for-woocommerce'),
|
||||
'type' => 'textarea',
|
||||
'id' => 'czl_warehouse_address',
|
||||
'desc' => __('Enter warehouse address', 'woo-czl-express'),
|
||||
'desc' => __('Enter warehouse address', 'czlexpress-for-woocommerce'),
|
||||
'default' => ''
|
||||
),
|
||||
array('type' => 'sectionend', 'id' => 'czl_api_settings'),
|
||||
@ -74,12 +74,12 @@ $settings = array(
|
||||
</form>
|
||||
|
||||
<div class="czl-api-test">
|
||||
<h2><?php _e('API Connection Test', 'woo-czl-express'); ?></h2>
|
||||
<h2><?php _e('API Connection Test', 'czlexpress-for-woocommerce'); ?></h2>
|
||||
<button type="button" class="button" id="czl-test-connection">
|
||||
<?php _e('Test Connection', 'woo-czl-express'); ?>
|
||||
<?php _e('Test Connection', 'czlexpress-for-woocommerce'); ?>
|
||||
</button>
|
||||
<button type="button" class="button" id="czl-test-shipping-rate">
|
||||
<?php _e('Test Shipping Rate', 'woo-czl-express'); ?>
|
||||
<?php _e('Test Shipping Rate', 'czlexpress-for-woocommerce'); ?>
|
||||
</button>
|
||||
<div id="czl-test-result"></div>
|
||||
</div>
|
||||
@ -92,7 +92,7 @@ jQuery(function($) {
|
||||
var $result = $('#czl-test-result');
|
||||
|
||||
$button.prop('disabled', true);
|
||||
$result.html('<?php _e('Testing...', 'woo-czl-express'); ?>');
|
||||
$result.html('<?php _e('Testing...', 'czlexpress-for-woocommerce'); ?>');
|
||||
|
||||
$.post(ajaxurl, {
|
||||
action: 'czl_test_connection',
|
||||
@ -100,9 +100,9 @@ jQuery(function($) {
|
||||
}, function(response) {
|
||||
$button.prop('disabled', false);
|
||||
if (response.success) {
|
||||
$result.html('<div class="notice notice-success"><p>' + response.data.message + '</p></div>');
|
||||
$result.html('<div class="notice notice-success"><p>' + wp.escapeHtml(response.data.message) + '</p></div>');
|
||||
} else {
|
||||
$result.html('<div class="notice notice-error"><p>' + response.data.message + '</p></div>');
|
||||
$result.html('<div class="notice notice-error"><p>' + wp.escapeHtml(response.data.message) + '</p></div>');
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -112,7 +112,7 @@ jQuery(function($) {
|
||||
var $result = $('#czl-test-result');
|
||||
|
||||
$button.prop('disabled', true);
|
||||
$result.html('<?php _e('Testing...', 'woo-czl-express'); ?>');
|
||||
$result.html('<?php _e('Testing...', 'czlexpress-for-woocommerce'); ?>');
|
||||
|
||||
$.post(ajaxurl, {
|
||||
action: 'czl_test_shipping_rate',
|
||||
@ -120,11 +120,11 @@ jQuery(function($) {
|
||||
}, function(response) {
|
||||
$button.prop('disabled', false);
|
||||
if (response.success) {
|
||||
var html = '<div class="notice notice-success"><p><?php _e('Shipping rates retrieved successfully:', 'woo-czl-express'); ?></p>';
|
||||
html += '<pre>' + JSON.stringify(response.data, null, 2) + '</pre></div>';
|
||||
var html = '<div class="notice notice-success"><p><?php _e('Shipping rates retrieved successfully:', 'czlexpress-for-woocommerce'); ?></p>';
|
||||
html += '<pre>' + wp.escapeHtml(JSON.stringify(response.data, null, 2)) + '</pre></div>';
|
||||
$result.html(html);
|
||||
} else {
|
||||
$result.html('<div class="notice notice-error"><p>' + response.data.message + '</p></div>');
|
||||
$result.html('<div class="notice notice-error"><p>' + wp.escapeHtml(response.data.message) + '</p></div>');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -3,19 +3,19 @@ defined('ABSPATH') || exit;
|
||||
?>
|
||||
|
||||
<div class="czl-api-test">
|
||||
<h2><?php _e('API连接测试', 'woo-czl-express'); ?></h2>
|
||||
<h2><?php _e('API连接测试', 'czlexpress-for-woocommerce'); ?></h2>
|
||||
|
||||
<p class="description">
|
||||
<?php _e('点击下面的按钮测试与CZL Express API的连接。', 'woo-czl-express'); ?>
|
||||
<?php _e('点击下面的按钮测试与CZL Express API的连接。', 'czlexpress-for-woocommerce'); ?>
|
||||
</p>
|
||||
|
||||
<div class="test-buttons">
|
||||
<button type="button" class="button" id="czl-test-connection">
|
||||
<?php _e('测试连接', 'woo-czl-express'); ?>
|
||||
<?php _e('测试连接', 'czlexpress-for-woocommerce'); ?>
|
||||
</button>
|
||||
|
||||
<button type="button" class="button" id="czl-test-shipping-rate">
|
||||
<?php _e('测试运费查询', 'woo-czl-express'); ?>
|
||||
<?php _e('测试运费查询', 'czlexpress-for-woocommerce'); ?>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@ -29,7 +29,7 @@ jQuery(function($) {
|
||||
var $result = $('#czl-test-result');
|
||||
|
||||
$button.prop('disabled', true);
|
||||
$result.html('<?php _e('测试中...', 'woo-czl-express'); ?>');
|
||||
$result.html('<?php _e('测试中...', 'czlexpress-for-woocommerce'); ?>');
|
||||
|
||||
$.post(ajaxurl, {
|
||||
action: 'czl_test_connection',
|
||||
@ -37,9 +37,9 @@ jQuery(function($) {
|
||||
}, function(response) {
|
||||
$button.prop('disabled', false);
|
||||
if (response.success) {
|
||||
$result.html('<div class="notice notice-success"><p>' + response.data.message + '</p></div>');
|
||||
$result.html('<div class="notice notice-success"><p>' + wp.escapeHtml(response.data.message) + '</p></div>');
|
||||
} else {
|
||||
$result.html('<div class="notice notice-error"><p>' + response.data.message + '</p></div>');
|
||||
$result.html('<div class="notice notice-error"><p>' + wp.escapeHtml(response.data.message) + '</p></div>');
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -49,7 +49,7 @@ jQuery(function($) {
|
||||
var $result = $('#czl-test-result');
|
||||
|
||||
$button.prop('disabled', true);
|
||||
$result.html('<?php _e('测试中...', 'woo-czl-express'); ?>');
|
||||
$result.html('<?php _e('测试中...', 'czlexpress-for-woocommerce'); ?>');
|
||||
|
||||
$.post(ajaxurl, {
|
||||
action: 'czl_test_shipping_rate',
|
||||
@ -57,11 +57,11 @@ jQuery(function($) {
|
||||
}, function(response) {
|
||||
$button.prop('disabled', false);
|
||||
if (response.success) {
|
||||
var html = '<div class="notice notice-success"><p><?php _e('运费查询成功:', 'woo-czl-express'); ?></p>';
|
||||
html += '<pre>' + JSON.stringify(response.data, null, 2) + '</pre></div>';
|
||||
var html = '<div class="notice notice-success"><p><?php _e('运费查询成功:', 'czlexpress-for-woocommerce'); ?></p>';
|
||||
html += '<pre>' + wp.escapeHtml(JSON.stringify(response.data, null, 2)) + '</pre></div>';
|
||||
$result.html(html);
|
||||
} else {
|
||||
$result.html('<div class="notice notice-error"><p>' + response.data.message + '</p></div>');
|
||||
$result.html('<div class="notice notice-error"><p>' + wp.escapeHtml(response.data.message) + '</p></div>');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -23,8 +23,8 @@ foreach ($supported_currencies as $code => $name) {
|
||||
|
||||
<div class="czl-page-description">
|
||||
<p>
|
||||
<?php _e('在这里设置人民币(CNY)与其他货币的汇率。运费将根据这些汇率自动转换。', 'woo-czl-express'); ?>
|
||||
<?php printf(__('当前商店使用的货币是: %s', 'woo-czl-express'), '<strong>' . $current_currency . '</strong>'); ?>
|
||||
<?php _e('在这里设置人民币(CNY)与其他货币的汇率。运费将根据这些汇率自动转换。', 'czlexpress-for-woocommerce'); ?>
|
||||
<?php printf(__('当前商店使用的货币是: %s', 'czlexpress-for-woocommerce'), '<strong>' . $current_currency . '</strong>'); ?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@ -35,9 +35,9 @@ foreach ($supported_currencies as $code => $name) {
|
||||
<table class="widefat czl-exchange-rates" id="czl-exchange-rates">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="column-currency"><?php _e('货币', 'woo-czl-express'); ?></th>
|
||||
<th class="column-rate"><?php _e('汇率 (1 CNY =)', 'woo-czl-express'); ?></th>
|
||||
<th class="column-actions"><?php _e('操作', 'woo-czl-express'); ?></th>
|
||||
<th class="column-currency"><?php _e('货币', 'czlexpress-for-woocommerce'); ?></th>
|
||||
<th class="column-rate"><?php _e('汇率 (1 CNY =)', 'czlexpress-for-woocommerce'); ?></th>
|
||||
<th class="column-actions"><?php _e('操作', 'czlexpress-for-woocommerce'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -66,7 +66,7 @@ foreach ($supported_currencies as $code => $name) {
|
||||
value="<?php echo esc_attr($rate); ?>" step="0.000001" min="0" class="regular-text">
|
||||
</td>
|
||||
<td class="column-actions">
|
||||
<button type="button" class="button remove-rate" title="<?php esc_attr_e('删除此汇率', 'woo-czl-express'); ?>">
|
||||
<button type="button" class="button remove-rate" title="<?php esc_attr_e('删除此汇率', 'czlexpress-for-woocommerce'); ?>">
|
||||
<span class="dashicons dashicons-trash"></span>
|
||||
</button>
|
||||
</td>
|
||||
@ -79,7 +79,7 @@ foreach ($supported_currencies as $code => $name) {
|
||||
<td colspan="3">
|
||||
<button type="button" class="button add-rate">
|
||||
<span class="dashicons dashicons-plus-alt2"></span>
|
||||
<?php _e('添加汇率', 'woo-czl-express'); ?>
|
||||
<?php _e('添加汇率', 'czlexpress-for-woocommerce'); ?>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
@ -87,7 +87,7 @@ foreach ($supported_currencies as $code => $name) {
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<?php submit_button(__('保存汇率设置', 'woo-czl-express')); ?>
|
||||
<?php submit_button(__('保存汇率设置', 'czlexpress-for-woocommerce')); ?>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@ -113,7 +113,7 @@ foreach ($supported_currencies as $code => $name) {
|
||||
<input type="number" name="rates[{{index}}][rate]" value="" step="0.000001" min="0" class="regular-text">
|
||||
</td>
|
||||
<td class="column-actions">
|
||||
<button type="button" class="button remove-rate" title="<?php esc_attr_e('删除此汇率', 'woo-czl-express'); ?>">
|
||||
<button type="button" class="button remove-rate" title="<?php esc_attr_e('删除此汇率', 'czlexpress-for-woocommerce'); ?>">
|
||||
<span class="dashicons dashicons-trash"></span>
|
||||
</button>
|
||||
</td>
|
||||
|
@ -22,12 +22,28 @@ $orders = $orders_query->get_orders();
|
||||
// 获取运单信息
|
||||
global $wpdb;
|
||||
$shipments = array();
|
||||
$shipment_results = $wpdb->get_results("
|
||||
|
||||
// 尝试从缓存获取数据
|
||||
$cache_key = 'czl_shipments_data';
|
||||
$shipments_data = wp_cache_get($cache_key);
|
||||
|
||||
if (false === $shipments_data) {
|
||||
// 如果缓存中没有数据,则从数据库获取
|
||||
$shipment_results = $wpdb->get_results($wpdb->prepare("
|
||||
SELECT order_id, tracking_number, czl_order_id, reference_number, status as shipment_status, label_url
|
||||
FROM {$wpdb->prefix}czl_shipments
|
||||
");
|
||||
foreach ($shipment_results as $shipment) {
|
||||
WHERE 1=%d
|
||||
", 1));
|
||||
|
||||
// 处理结果
|
||||
foreach ($shipment_results as $shipment) {
|
||||
$shipments[$shipment->order_id] = $shipment;
|
||||
}
|
||||
|
||||
// 将数据存入缓存,设置5分钟过期
|
||||
wp_cache_set($cache_key, $shipments, '', 300);
|
||||
} else {
|
||||
$shipments = $shipments_data;
|
||||
}
|
||||
|
||||
// 添加必要的JavaScript变量
|
||||
@ -37,22 +53,22 @@ wp_enqueue_script('jquery');
|
||||
var czl_ajax = {
|
||||
ajax_url: '<?php echo admin_url('admin-ajax.php'); ?>',
|
||||
nonce: '<?php echo wp_create_nonce('czl_ajax_nonce'); ?>',
|
||||
creating_text: '<?php _e('正在创建运单...', 'woo-czl-express'); ?>',
|
||||
success_text: '<?php _e('运单创建成功', 'woo-czl-express'); ?>',
|
||||
error_text: '<?php _e('运单创建失败', 'woo-czl-express'); ?>'
|
||||
creating_text: '<?php _e('正在创建运单...', 'czlexpress-for-woocommerce'); ?>',
|
||||
success_text: '<?php _e('运单创建成功', 'czlexpress-for-woocommerce'); ?>',
|
||||
error_text: '<?php _e('运单创建失败', 'czlexpress-for-woocommerce'); ?>'
|
||||
};
|
||||
</script>
|
||||
|
||||
<div class="wrap">
|
||||
<h1><?php _e('CZL Express 订单管理', 'woo-czl-express'); ?></h1>
|
||||
<h1><?php _e('CZL Express 订单管理', 'czlexpress-for-woocommerce'); ?></h1>
|
||||
|
||||
<div class="tablenav top">
|
||||
<div class="alignleft actions">
|
||||
<select id="bulk-action-selector-top">
|
||||
<option value="-1"><?php _e('批量操作', 'woo-czl-express'); ?></option>
|
||||
<option value="create_shipment"><?php _e('创建运单', 'woo-czl-express'); ?></option>
|
||||
<option value="-1"><?php _e('批量操作', 'czlexpress-for-woocommerce'); ?></option>
|
||||
<option value="create_shipment"><?php _e('创建运单', 'czlexpress-for-woocommerce'); ?></option>
|
||||
</select>
|
||||
<button class="button" id="doaction"><?php _e('应用', 'woo-czl-express'); ?></button>
|
||||
<button class="button" id="doaction"><?php _e('应用', 'czlexpress-for-woocommerce'); ?></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -62,19 +78,19 @@ wp_enqueue_script('jquery');
|
||||
<td class="manage-column column-cb check-column">
|
||||
<input type="checkbox" id="cb-select-all-1">
|
||||
</td>
|
||||
<th><?php _e('订单号', 'woo-czl-express'); ?></th>
|
||||
<th><?php _e('日期', 'woo-czl-express'); ?></th>
|
||||
<th><?php _e('状态', 'woo-czl-express'); ?></th>
|
||||
<th><?php _e('收件人', 'woo-czl-express'); ?></th>
|
||||
<th><?php _e('配送方式', 'woo-czl-express'); ?></th>
|
||||
<th><?php _e('运单信息', 'woo-czl-express'); ?></th>
|
||||
<th><?php _e('操作', 'woo-czl-express'); ?></th>
|
||||
<th><?php _e('订单号', 'czlexpress-for-woocommerce'); ?></th>
|
||||
<th><?php _e('日期', 'czlexpress-for-woocommerce'); ?></th>
|
||||
<th><?php _e('状态', 'czlexpress-for-woocommerce'); ?></th>
|
||||
<th><?php _e('收件人', 'czlexpress-for-woocommerce'); ?></th>
|
||||
<th><?php _e('配送方式', 'czlexpress-for-woocommerce'); ?></th>
|
||||
<th><?php _e('运单信息', 'czlexpress-for-woocommerce'); ?></th>
|
||||
<th><?php _e('操作', 'czlexpress-for-woocommerce'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
if (empty($orders)) {
|
||||
echo '<tr><td colspan="8">' . __('没有找到订单', 'woo-czl-express') . '</td></tr>';
|
||||
echo '<tr><td colspan="8">' . __('没有找到订单', 'czlexpress-for-woocommerce') . '</td></tr>';
|
||||
} else {
|
||||
foreach ($orders as $order):
|
||||
$order_id = $order->get_id();
|
||||
@ -112,7 +128,7 @@ wp_enqueue_script('jquery');
|
||||
</td>
|
||||
<td>
|
||||
<?php if ($shipment && !empty($shipment->tracking_number)): ?>
|
||||
<strong><?php _e('运单号:', 'woo-czl-express'); ?></strong>
|
||||
<strong><?php _e('运单号:', 'czlexpress-for-woocommerce'); ?></strong>
|
||||
<a href="https://exp.czl.net/track/?query=<?php echo esc_attr($shipment->tracking_number); ?>" target="_blank">
|
||||
<?php echo esc_html($shipment->tracking_number); ?>
|
||||
</a>
|
||||
@ -122,30 +138,30 @@ wp_enqueue_script('jquery');
|
||||
style="margin-left: 5px;">
|
||||
<span class="dashicons dashicons-edit" style="font-size: 16px; height: 16px; width: 16px;"></span>
|
||||
</button><br>
|
||||
<strong><?php _e('CZL订单号:', 'woo-czl-express'); ?></strong>
|
||||
<strong><?php _e('CZL订单号:', 'czlexpress-for-woocommerce'); ?></strong>
|
||||
<?php echo esc_html($shipment->czl_order_id); ?><br>
|
||||
<strong><?php _e('参考号:', 'woo-czl-express'); ?></strong>
|
||||
<strong><?php _e('参考号:', 'czlexpress-for-woocommerce'); ?></strong>
|
||||
<?php echo esc_html($shipment->reference_number); ?><br>
|
||||
<strong><?php _e('运单状态:', 'woo-czl-express'); ?></strong>
|
||||
<strong><?php _e('运单状态:', 'czlexpress-for-woocommerce'); ?></strong>
|
||||
<?php echo esc_html($shipment->shipment_status); ?>
|
||||
<?php else: ?>
|
||||
<?php _e('未创建运单', 'woo-czl-express'); ?>
|
||||
<?php _e('未创建运单', 'czlexpress-for-woocommerce'); ?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php if (!$shipment || empty($shipment->tracking_number)): ?>
|
||||
<button type="button" class="button czl-create-btn"
|
||||
data-order-id="<?php echo $order_id; ?>">
|
||||
<?php _e('创建运单', 'woo-czl-express'); ?>
|
||||
<?php _e('创建运单', 'czlexpress-for-woocommerce'); ?>
|
||||
</button>
|
||||
<?php elseif (!empty($shipment->czl_order_id)): ?>
|
||||
<button type="button" class="button"
|
||||
onclick="printLabel('<?php echo $shipment->czl_order_id; ?>')">
|
||||
<?php _e('打印标签', 'woo-czl-express'); ?>
|
||||
<?php _e('打印标签', 'czlexpress-for-woocommerce'); ?>
|
||||
</button>
|
||||
<button type="button" class="button update-tracking-btn"
|
||||
data-order-id="<?php echo $order_id; ?>">
|
||||
<?php _e('更新轨迹', 'woo-czl-express'); ?>
|
||||
<?php _e('更新轨迹', 'czlexpress-for-woocommerce'); ?>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
@ -162,17 +178,17 @@ wp_enqueue_script('jquery');
|
||||
<div style="padding:20px;">
|
||||
<div class="form-field" style="margin-bottom:15px;">
|
||||
<label for="new-tracking-number" style="display:block;margin-bottom:8px;font-weight:600;">
|
||||
<?php _e('新跟踪单号:', 'woo-czl-express'); ?>
|
||||
<?php _e('新跟踪单号:', 'czlexpress-for-woocommerce'); ?>
|
||||
</label>
|
||||
<input type="text" id="new-tracking-number" style="width:100%;padding:5px;">
|
||||
<input type="hidden" id="edit-order-id" value="">
|
||||
</div>
|
||||
<div style="text-align:right;margin-top:20px;">
|
||||
<button type="button" class="button" onclick="self.parent.tb_remove();" style="margin-right:5px;">
|
||||
<?php _e('取消', 'woo-czl-express'); ?>
|
||||
<?php _e('取消', 'czlexpress-for-woocommerce'); ?>
|
||||
</button>
|
||||
<button type="button" class="button button-primary" id="save-tracking-number">
|
||||
<?php _e('保存', 'woo-czl-express'); ?>
|
||||
<?php _e('保存', 'czlexpress-for-woocommerce'); ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@ -192,7 +208,7 @@ jQuery(document).ready(function($) {
|
||||
|
||||
// 打开对话框
|
||||
tb_show(
|
||||
'<?php _e('修改跟踪单号', 'woo-czl-express'); ?>',
|
||||
'<?php _e('修改跟踪单号', 'czlexpress-for-woocommerce'); ?>',
|
||||
'#TB_inline?width=300&height=180&inlineId=edit-tracking-dialog'
|
||||
);
|
||||
|
||||
@ -233,11 +249,11 @@ jQuery(document).ready(function($) {
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
alert('跟踪单号更新成功');
|
||||
alert(wp.escapeHtml(response.data.message || '跟踪单号更新成功'));
|
||||
self.parent.tb_remove();
|
||||
window.location.reload();
|
||||
} else {
|
||||
alert(response.data || '更新失败');
|
||||
alert(wp.escapeHtml(response.data || '更新失败'));
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
|
@ -10,7 +10,7 @@ $groups = get_option('czl_product_groups', array());
|
||||
<?php settings_errors(); ?>
|
||||
|
||||
<div class="czl-page-description">
|
||||
<p><?php _e('在这里管理运输方式的分组显示。相同分组的运输方式将合并显示,并显示最低价格。', 'woo-czl-express'); ?></p>
|
||||
<p><?php _e('在这里管理运输方式的分组显示。相同分组的运输方式将合并显示,并显示最低价格。', 'czlexpress-for-woocommerce'); ?></p>
|
||||
</div>
|
||||
|
||||
<form method="post" action="">
|
||||
@ -20,10 +20,10 @@ $groups = get_option('czl_product_groups', array());
|
||||
<table class="widefat czl-product-groups" id="czl-product-groups">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="column-enabled"><?php _e('启用', 'woo-czl-express'); ?></th>
|
||||
<th class="column-name"><?php _e('分组名称', 'woo-czl-express'); ?></th>
|
||||
<th class="column-prefixes"><?php _e('匹配前缀', 'woo-czl-express'); ?></th>
|
||||
<th class="column-actions"><?php _e('操作', 'woo-czl-express'); ?></th>
|
||||
<th class="column-enabled"><?php _e('启用', 'czlexpress-for-woocommerce'); ?></th>
|
||||
<th class="column-name"><?php _e('分组名称', 'czlexpress-for-woocommerce'); ?></th>
|
||||
<th class="column-prefixes"><?php _e('匹配前缀', 'czlexpress-for-woocommerce'); ?></th>
|
||||
<th class="column-actions"><?php _e('操作', 'czlexpress-for-woocommerce'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -41,10 +41,10 @@ $groups = get_option('czl_product_groups', array());
|
||||
<td class="column-prefixes">
|
||||
<textarea name="groups[<?php echo esc_attr($key); ?>][prefixes]" rows="3" class="large-text"
|
||||
><?php echo esc_textarea(implode("\n", $group['prefixes'])); ?></textarea>
|
||||
<p class="description"><?php _e('每行输入一个前缀,运输方式名称以此前缀开头将被归入此分组', 'woo-czl-express'); ?></p>
|
||||
<p class="description"><?php _e('每行输入一个前缀,运输方式名称以此前缀开头将被归入此分组', 'czlexpress-for-woocommerce'); ?></p>
|
||||
</td>
|
||||
<td class="column-actions">
|
||||
<button type="button" class="button remove-group" title="<?php esc_attr_e('删除此分组', 'woo-czl-express'); ?>">
|
||||
<button type="button" class="button remove-group" title="<?php esc_attr_e('删除此分组', 'czlexpress-for-woocommerce'); ?>">
|
||||
<span class="dashicons dashicons-trash"></span>
|
||||
</button>
|
||||
</td>
|
||||
@ -52,7 +52,7 @@ $groups = get_option('czl_product_groups', array());
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<tr class="no-items">
|
||||
<td colspan="4"><?php _e('没有找到分组配置', 'woo-czl-express'); ?></td>
|
||||
<td colspan="4"><?php _e('没有找到分组配置', 'czlexpress-for-woocommerce'); ?></td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
@ -61,7 +61,7 @@ $groups = get_option('czl_product_groups', array());
|
||||
<td colspan="4">
|
||||
<button type="button" class="button add-group">
|
||||
<span class="dashicons dashicons-plus-alt2"></span>
|
||||
<?php _e('添加分组', 'woo-czl-express'); ?>
|
||||
<?php _e('添加分组', 'czlexpress-for-woocommerce'); ?>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
@ -69,7 +69,7 @@ $groups = get_option('czl_product_groups', array());
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<?php submit_button(__('保存分组设置', 'woo-czl-express'), 'primary', 'submit', true); ?>
|
||||
<?php submit_button(__('保存分组设置', 'czlexpress-for-woocommerce'), 'primary', 'submit', true); ?>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@ -79,14 +79,14 @@ $groups = get_option('czl_product_groups', array());
|
||||
<input type="checkbox" name="groups[{{index}}][enabled]" value="1" checked>
|
||||
</td>
|
||||
<td class="column-name">
|
||||
<input type="text" name="groups[{{index}}][groupName]" value="" class="regular-text" placeholder="<?php esc_attr_e('输入分组名称', 'woo-czl-express'); ?>">
|
||||
<input type="text" name="groups[{{index}}][groupName]" value="" class="regular-text" placeholder="<?php esc_attr_e('输入分组名称', 'czlexpress-for-woocommerce'); ?>">
|
||||
</td>
|
||||
<td class="column-prefixes">
|
||||
<textarea name="groups[{{index}}][prefixes]" rows="3" class="large-text" placeholder="<?php esc_attr_e('每行输入一个前缀', 'woo-czl-express'); ?>"></textarea>
|
||||
<p class="description"><?php _e('每行输入一个前缀,运输方式名称以此前缀开头将被归入此分组', 'woo-czl-express'); ?></p>
|
||||
<textarea name="groups[{{index}}][prefixes]" rows="3" class="large-text" placeholder="<?php esc_attr_e('每行输入一个前缀', 'czlexpress-for-woocommerce'); ?>"></textarea>
|
||||
<p class="description"><?php _e('每行输入一个前缀,运输方式名称以此前缀开头将被归入此分组', 'czlexpress-for-woocommerce'); ?></p>
|
||||
</td>
|
||||
<td class="column-actions">
|
||||
<button type="button" class="button remove-group" title="<?php esc_attr_e('删除此分组', 'woo-czl-express'); ?>">
|
||||
<button type="button" class="button remove-group" title="<?php esc_attr_e('删除此分组', 'czlexpress-for-woocommerce'); ?>">
|
||||
<span class="dashicons dashicons-trash"></span>
|
||||
</button>
|
||||
</td>
|
||||
@ -187,7 +187,7 @@ jQuery(function($) {
|
||||
$row.fadeOut(300, function() {
|
||||
$row.remove();
|
||||
if ($table.find('tbody tr').length === 0) {
|
||||
$table.find('tbody').append('<tr class="no-items"><td colspan="4"><?php _e('没有找到分组配置', 'woo-czl-express'); ?></td></tr>');
|
||||
$table.find('tbody').append('<tr class="no-items"><td colspan="4"><?php _e('没有找到分组配置', 'czlexpress-for-woocommerce'); ?></td></tr>');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -1,16 +1,16 @@
|
||||
<?php
|
||||
/**
|
||||
* Plugin Name: CZL Express for WooCommerce
|
||||
* Plugin URI: https://exp.czl.net
|
||||
* Plugin URI: https://github.com/woodchen-ink/woocommerce-czlexpress
|
||||
* Description: CZL Express shipping integration for WooCommerce. Provides real-time shipping rates, shipment creation, and package tracking for CZL Express delivery service.
|
||||
* Version: 1.0.0
|
||||
* Requires at least: 5.8
|
||||
* Requires PHP: 7.2
|
||||
* Requires at least: 6.7
|
||||
* Requires PHP: 8.0
|
||||
* Author: CZL Express
|
||||
* Author URI: https://exp.czl.net
|
||||
* License: GPL v2 or later
|
||||
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* Text Domain: woo-czl-express
|
||||
* Text Domain: czlexpress-for-woocommerce
|
||||
* Domain Path: /languages
|
||||
* WC requires at least: 6.0.0
|
||||
* WC tested up to: 8.3.0
|
||||
@ -35,27 +35,27 @@ if (!defined('ABSPATH')) {
|
||||
}
|
||||
|
||||
// 防止重复加载
|
||||
if (defined('WOO_CZL_EXPRESS_VERSION')) {
|
||||
if (defined('CZL_EXPRESS_VERSION')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 定义插件常量
|
||||
define('WOO_CZL_EXPRESS_VERSION', '1.0.0');
|
||||
define('WOO_CZL_EXPRESS_PATH', plugin_dir_path(__FILE__));
|
||||
define('WOO_CZL_EXPRESS_URL', plugin_dir_url(__FILE__));
|
||||
define('CZL_EXPRESS_VERSION', '1.0.0');
|
||||
define('CZL_EXPRESS_PATH', plugin_dir_path(__FILE__));
|
||||
define('CZL_EXPRESS_URL', plugin_dir_url(__FILE__));
|
||||
|
||||
// 在插件激活时创建数据表
|
||||
register_activation_hook(__FILE__, 'wc_czlexpress_activate');
|
||||
register_activation_hook(__FILE__, 'czl_express_activate');
|
||||
|
||||
function wc_czlexpress_activate() {
|
||||
function czl_express_activate() {
|
||||
// 确保加载安装类
|
||||
require_once WOO_CZL_EXPRESS_PATH . 'includes/class-czl-install.php';
|
||||
require_once CZL_EXPRESS_PATH . 'includes/class-czl-install.php';
|
||||
|
||||
// 创建数据表和默认选项
|
||||
CZL_Install::init();
|
||||
|
||||
// 记录版本号
|
||||
update_option('czl_express_version', WOO_CZL_EXPRESS_VERSION);
|
||||
update_option('czl_express_version', CZL_EXPRESS_VERSION);
|
||||
|
||||
// 注册定时任务
|
||||
if (!wp_next_scheduled('czl_sync_tracking_numbers_hook')) {
|
||||
@ -80,11 +80,11 @@ add_action('before_woocommerce_init', function() {
|
||||
});
|
||||
|
||||
// 检查环境
|
||||
function wc_czlexpress_check_environment() {
|
||||
function czl_express_check_environment() {
|
||||
if (!class_exists('WooCommerce')) {
|
||||
add_action('admin_notices', function() {
|
||||
echo '<div class="error"><p>' .
|
||||
__('CZL Express requires WooCommerce to be installed and active', 'woocommerce-czlexpress') .
|
||||
esc_html__('CZL Express requires WooCommerce to be installed and active', 'czlexpress-for-woocommerce') .
|
||||
'</p></div>';
|
||||
});
|
||||
return false;
|
||||
@ -93,7 +93,7 @@ function wc_czlexpress_check_environment() {
|
||||
if (version_compare(WC_VERSION, '6.0.0', '<')) {
|
||||
add_action('admin_notices', function() {
|
||||
echo '<div class="error"><p>' .
|
||||
__('CZL Express requires WooCommerce 6.0.0 or higher', 'woocommerce-czlexpress') .
|
||||
esc_html__('CZL Express requires WooCommerce 6.0.0 or higher', 'czlexpress-for-woocommerce') .
|
||||
'</p></div>';
|
||||
});
|
||||
return false;
|
||||
@ -103,21 +103,21 @@ function wc_czlexpress_check_environment() {
|
||||
}
|
||||
|
||||
// 初始化插件
|
||||
function woo_czl_express_init() {
|
||||
if (wc_czlexpress_check_environment()) {
|
||||
function czl_express_init() {
|
||||
if (czl_express_check_environment()) {
|
||||
// 加载语言文件
|
||||
load_plugin_textdomain(
|
||||
'woo-czl-express',
|
||||
'czlexpress-for-woocommerce',
|
||||
false,
|
||||
dirname(plugin_basename(__FILE__)) . '/languages'
|
||||
);
|
||||
|
||||
// 加载必要的类文件
|
||||
require_once WOO_CZL_EXPRESS_PATH . 'includes/class-woo-czl-express.php';
|
||||
require_once WOO_CZL_EXPRESS_PATH . 'includes/class-czl-api.php';
|
||||
require_once WOO_CZL_EXPRESS_PATH . 'includes/class-czl-order.php';
|
||||
require_once CZL_EXPRESS_PATH . 'includes/class-czlexpress.php';
|
||||
require_once CZL_EXPRESS_PATH . 'includes/class-czl-api.php';
|
||||
require_once CZL_EXPRESS_PATH . 'includes/class-czl-order.php';
|
||||
|
||||
WooCzlExpress::instance();
|
||||
CZLExpress::instance();
|
||||
|
||||
// 添加AJAX处理
|
||||
add_action('wp_ajax_czl_create_shipment', 'czl_ajax_create_shipment');
|
||||
@ -135,15 +135,16 @@ function woo_czl_express_init() {
|
||||
// 注册自定义订单状态
|
||||
function register_czl_order_statuses() {
|
||||
register_post_status('wc-in_transit', array(
|
||||
'label' => _x('In Transit', 'Order status', 'woo-czl-express'),
|
||||
'label' => _x('In Transit', 'Order status', 'czlexpress-for-woocommerce'),
|
||||
'public' => true,
|
||||
'show_in_admin_status_list' => true,
|
||||
'show_in_admin_all_list' => true,
|
||||
'exclude_from_search' => false,
|
||||
/* translators: %s: number of orders */
|
||||
'label_count' => _n_noop(
|
||||
'In Transit <span class="count">(%s)</span>',
|
||||
'In Transit <span class="count">(%s)</span>',
|
||||
'woo-czl-express'
|
||||
'czlexpress-for-woocommerce'
|
||||
)
|
||||
));
|
||||
|
||||
@ -155,7 +156,7 @@ function register_czl_order_statuses() {
|
||||
foreach ($order_statuses as $key => $status) {
|
||||
$new_statuses[$key] = $status;
|
||||
if ($key === 'wc-processing') {
|
||||
$new_statuses['wc-in_transit'] = _x('In Transit', 'Order status', 'woo-czl-express');
|
||||
$new_statuses['wc-in_transit'] = _x('In Transit', 'Order status', 'czlexpress-for-woocommerce');
|
||||
}
|
||||
}
|
||||
|
||||
@ -176,9 +177,9 @@ function czl_enqueue_admin_scripts($hook) {
|
||||
// 加载自定义脚本
|
||||
wp_enqueue_script(
|
||||
'czl-admin-script',
|
||||
WOO_CZL_EXPRESS_URL . 'assets/js/admin.js',
|
||||
CZL_EXPRESS_URL . 'assets/js/admin.js',
|
||||
array('jquery'),
|
||||
WOO_CZL_EXPRESS_VERSION,
|
||||
CZL_EXPRESS_VERSION,
|
||||
true
|
||||
);
|
||||
|
||||
@ -238,6 +239,16 @@ function czl_ajax_update_tracking_number() {
|
||||
try {
|
||||
global $wpdb;
|
||||
|
||||
// 获取运单信息
|
||||
$shipment = $wpdb->get_row($wpdb->prepare(
|
||||
"SELECT id FROM {$wpdb->prefix}czl_shipments WHERE order_id = %d",
|
||||
$order_id
|
||||
));
|
||||
|
||||
if (!$shipment) {
|
||||
throw new Exception('运单不存在');
|
||||
}
|
||||
|
||||
// 更新数据库中的跟踪单号
|
||||
$updated = $wpdb->update(
|
||||
$wpdb->prefix . 'czl_shipments',
|
||||
@ -264,7 +275,13 @@ function czl_ajax_update_tracking_number() {
|
||||
));
|
||||
}
|
||||
|
||||
wp_send_json_success();
|
||||
// 清除相关缓存
|
||||
$tracking = new CZL_Tracking();
|
||||
$tracking->clear_tracking_cache($shipment->id, $tracking_number, $order_id);
|
||||
|
||||
wp_send_json_success(array(
|
||||
'message' => '运单号更新成功'
|
||||
));
|
||||
|
||||
} catch (Exception $e) {
|
||||
wp_send_json_error($e->getMessage());
|
||||
@ -300,7 +317,7 @@ function czl_do_update_tracking_info($order_id) {
|
||||
}
|
||||
add_action('czl_do_update_tracking_info', 'czl_do_update_tracking_info');
|
||||
|
||||
add_action('plugins_loaded', 'woo_czl_express_init');
|
||||
add_action('plugins_loaded', 'czl_express_init');
|
||||
|
||||
// 自动创建运单的钩子
|
||||
add_action('woocommerce_order_status_processing', function($order_id) {
|
||||
@ -318,7 +335,7 @@ function czl_add_cron_interval($schedules) {
|
||||
// 添加每30分钟执行一次的间隔
|
||||
$schedules['czl_thirty_minutes'] = array(
|
||||
'interval' => 1800, // 30分钟 = 1800秒
|
||||
'display' => __('Every 30 minutes', 'woo-czl-express')
|
||||
'display' => esc_html__('Every 30 minutes', 'czlexpress-for-woocommerce')
|
||||
);
|
||||
return $schedules;
|
||||
}
|
@ -10,7 +10,7 @@ class CZL_Ajax {
|
||||
check_ajax_referer('czl_test_api', 'nonce');
|
||||
|
||||
if (!current_user_can('manage_options')) {
|
||||
wp_send_json_error(array('message' => __('Permission denied', 'woo-czl-express')));
|
||||
wp_send_json_error(array('message' => __('Permission denied', 'czlexpress-for-woocommerce')));
|
||||
}
|
||||
|
||||
$tester = new CZL_API_Test();
|
||||
@ -27,7 +27,7 @@ class CZL_Ajax {
|
||||
check_ajax_referer('czl_test_api', 'nonce');
|
||||
|
||||
if (!current_user_can('manage_options')) {
|
||||
wp_send_json_error(array('message' => __('Permission denied', 'woo-czl-express')));
|
||||
wp_send_json_error(array('message' => __('Permission denied', 'czlexpress-for-woocommerce')));
|
||||
}
|
||||
|
||||
$tester = new CZL_API_Test();
|
||||
|
@ -15,7 +15,7 @@ class CZL_API_Test {
|
||||
$this->api->get_token();
|
||||
return array(
|
||||
'success' => true,
|
||||
'message' => __('Successfully connected to CZL Express API', 'woo-czl-express')
|
||||
'message' => __('Successfully connected to CZL Express API', 'czlexpress-for-woocommerce')
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
return array(
|
||||
|
@ -100,7 +100,7 @@ class CZL_API {
|
||||
$body = json_decode(wp_remote_retrieve_body($response), true);
|
||||
|
||||
if (empty($body['success'])) {
|
||||
throw new Exception(!empty($body['message']) ? $body['message'] : '认证失败');
|
||||
throw new Exception(!empty($body['message']) ? esc_html($body['message']) : esc_html__('认证失败', 'woocommerce-czlexpress'));
|
||||
}
|
||||
|
||||
$this->token = $body['data']['token'];
|
||||
@ -126,7 +126,7 @@ class CZL_API {
|
||||
);
|
||||
|
||||
if ($data !== null) {
|
||||
$args['body'] = json_encode($data);
|
||||
$args['body'] = wp_json_encode($data);
|
||||
}
|
||||
|
||||
$response = wp_remote_request($this->api_url . $endpoint, $args);
|
||||
@ -138,7 +138,7 @@ class CZL_API {
|
||||
$body = json_decode(wp_remote_retrieve_body($response), true);
|
||||
|
||||
if (empty($body['success'])) {
|
||||
throw new Exception(!empty($body['message']) ? $body['message'] : '请求失败');
|
||||
throw new Exception(!empty($body['message']) ? esc_html($body['message']) : esc_html__('请求失败', 'woocommerce-czlexpress'));
|
||||
}
|
||||
|
||||
return $body['data'];
|
||||
@ -195,7 +195,7 @@ class CZL_API {
|
||||
return $data;
|
||||
|
||||
} catch (Exception $e) {
|
||||
error_log('CZL Express API Error: ' . $e->getMessage());
|
||||
error_log('CZL Express API Error: ' . esc_html($e->getMessage()));
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@ -229,7 +229,7 @@ class CZL_API {
|
||||
|
||||
$response = wp_remote_post('https://tms.czl.net/createOrderApi.htm', array(
|
||||
'body' => array(
|
||||
'Param' => json_encode($order_data)
|
||||
'Param' => wp_json_encode($order_data)
|
||||
),
|
||||
'timeout' => 30
|
||||
));
|
||||
@ -247,13 +247,13 @@ class CZL_API {
|
||||
}
|
||||
|
||||
if (empty($result['ack']) || $result['ack'] !== 'true') {
|
||||
throw new Exception(!empty($result['message']) ? urldecode($result['message']) : '未知错误');
|
||||
throw new Exception(!empty($result['message']) ? esc_html($result['message']) : esc_html__('未知错误', 'woocommerce-czlexpress'));
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
} catch (Exception $e) {
|
||||
error_log('CZL Express Error: Create order failed - ' . $e->getMessage());
|
||||
error_log('CZL Express Error: Create order failed - ' . esc_html($e->getMessage()));
|
||||
error_log('CZL Express Error Stack Trace: ' . $e->getTraceAsString());
|
||||
throw $e;
|
||||
}
|
||||
@ -284,7 +284,7 @@ class CZL_API {
|
||||
return $result[0]['data'][0];
|
||||
|
||||
} catch (Exception $e) {
|
||||
error_log('CZL Express API Error: ' . $e->getMessage());
|
||||
error_log('CZL Express API Error: ' . esc_html($e->getMessage()));
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@ -338,7 +338,7 @@ class CZL_API {
|
||||
);
|
||||
|
||||
} catch (Exception $e) {
|
||||
error_log('CZL Express API Error: ' . $e->getMessage());
|
||||
error_log('CZL Express API Error: ' . esc_html($e->getMessage()));
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@ -365,7 +365,7 @@ class CZL_API {
|
||||
return $result['data'];
|
||||
|
||||
} catch (Exception $e) {
|
||||
error_log('CZL Express API Error: ' . $e->getMessage());
|
||||
error_log('CZL Express API Error: ' . esc_html($e->getMessage()));
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@ -415,83 +415,65 @@ class CZL_API {
|
||||
$this->customer_userid = $result['customer_userid'];
|
||||
|
||||
} catch (Exception $e) {
|
||||
error_log('CZL Express Error: Authentication failed - ' . $e->getMessage());
|
||||
error_log('CZL Express Error: Authentication failed - ' . esc_html($e->getMessage()));
|
||||
throw new Exception('认证失败,请联系CZL Express');
|
||||
}
|
||||
}
|
||||
|
||||
private function make_request($url, $data = array(), $method = 'POST') {
|
||||
try {
|
||||
$ch = curl_init();
|
||||
|
||||
$curl_options = array(
|
||||
CURLOPT_URL => $url,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_HEADER => false,
|
||||
CURLOPT_SSL_VERIFYPEER => true,
|
||||
CURLOPT_SSL_VERIFYHOST => 2,
|
||||
CURLOPT_TIMEOUT => 60, // 增加超时时间到60秒
|
||||
CURLOPT_CONNECTTIMEOUT => 30, // 连接超时时间30秒
|
||||
CURLOPT_VERBOSE => true, // 启用详细日志
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
'Accept: */*',
|
||||
'Accept-Language: zh-cn',
|
||||
'Cache-Control: no-cache',
|
||||
'Content-Type: application/x-www-form-urlencoded;charset=UTF-8'
|
||||
)
|
||||
$args = array(
|
||||
'method' => $method,
|
||||
'timeout' => 60,
|
||||
'redirection' => 5,
|
||||
'httpversion' => '1.1',
|
||||
'blocking' => true,
|
||||
'headers' => array(
|
||||
'Accept' => '*/*',
|
||||
'Accept-Language' => 'zh-cn',
|
||||
'Cache-Control' => 'no-cache',
|
||||
'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8'
|
||||
),
|
||||
'cookies' => array()
|
||||
);
|
||||
|
||||
if ($method === 'POST') {
|
||||
$curl_options[CURLOPT_POST] = true;
|
||||
if (!empty($data)) {
|
||||
// 确保数据正确编码
|
||||
$post_data = is_array($data) ? http_build_query($data) : $data;
|
||||
$curl_options[CURLOPT_POSTFIELDS] = $post_data;
|
||||
}
|
||||
if ($method === 'POST' && !empty($data)) {
|
||||
$args['body'] = is_array($data) ? $data : wp_json_encode($data);
|
||||
}
|
||||
|
||||
curl_setopt_array($ch, $curl_options);
|
||||
// 使用wp_remote_request替代curl
|
||||
$response = wp_remote_request($url, $args);
|
||||
|
||||
// 捕获详细日志
|
||||
$verbose = fopen('php://temp', 'w+');
|
||||
curl_setopt($ch, CURLOPT_STDERR, $verbose);
|
||||
|
||||
$response = curl_exec($ch);
|
||||
$error = curl_error($ch);
|
||||
$errno = curl_errno($ch);
|
||||
|
||||
// 记录详细日志
|
||||
rewind($verbose);
|
||||
$verbose_log = stream_get_contents($verbose);
|
||||
error_log('CZL Express: Curl verbose log - ' . $verbose_log);
|
||||
fclose($verbose);
|
||||
|
||||
if ($errno) {
|
||||
error_log('CZL Express: Curl error - ' . $error);
|
||||
throw new Exception('请求失败: ' . $error);
|
||||
if (is_wp_error($response)) {
|
||||
throw new Exception('请求失败: ' . $response->get_error_message());
|
||||
}
|
||||
|
||||
if ($response === false) {
|
||||
throw new Exception('请求失败');
|
||||
$body = wp_remote_retrieve_body($response);
|
||||
|
||||
if (empty($body)) {
|
||||
throw new Exception('请求失败: 空响应');
|
||||
}
|
||||
|
||||
error_log('CZL Express: Raw response - ' . $response);
|
||||
// 记录响应日志
|
||||
if (defined('WP_DEBUG_LOG') && WP_DEBUG_LOG) {
|
||||
error_log('CZL Express: Raw response - ' . $body);
|
||||
}
|
||||
|
||||
$result = json_decode($response, true);
|
||||
$result = json_decode($body, true);
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
if (defined('WP_DEBUG_LOG') && WP_DEBUG_LOG) {
|
||||
error_log('CZL Express: JSON decode error - ' . json_last_error_msg());
|
||||
}
|
||||
throw new Exception('响应数据格式错误');
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
} catch (Exception $e) {
|
||||
error_log('CZL Express Error: Request failed - ' . $e->getMessage());
|
||||
throw $e;
|
||||
} finally {
|
||||
if (isset($ch)) {
|
||||
curl_close($ch);
|
||||
if (defined('WP_DEBUG_LOG') && WP_DEBUG_LOG) {
|
||||
error_log('CZL Express Error: Request failed - ' . esc_html($e->getMessage()));
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
@ -500,7 +482,9 @@ class CZL_API {
|
||||
*/
|
||||
public function authenticate() {
|
||||
try {
|
||||
if (defined('WP_DEBUG_LOG') && WP_DEBUG_LOG) {
|
||||
error_log('CZL Express: Starting authentication');
|
||||
}
|
||||
|
||||
$auth_url = 'https://tms.czl.net/selectAuth.htm';
|
||||
$auth_data = array(
|
||||
@ -508,31 +492,34 @@ class CZL_API {
|
||||
'password' => $this->password
|
||||
);
|
||||
|
||||
if (defined('WP_DEBUG_LOG') && WP_DEBUG_LOG) {
|
||||
error_log('CZL Express: Auth request data - ' . print_r($auth_data, true));
|
||||
|
||||
$ch = curl_init($auth_url);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($auth_data));
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Accept-Language: zh-cn',
|
||||
'Connection: Keep-Alive',
|
||||
'Cache-Control: no-cache'
|
||||
));
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
||||
|
||||
$response = curl_exec($ch);
|
||||
error_log('CZL Express: Auth raw response - ' . $response);
|
||||
|
||||
if (curl_errno($ch)) {
|
||||
throw new Exception('认证请求失败: ' . curl_error($ch));
|
||||
}
|
||||
|
||||
curl_close($ch);
|
||||
$response = wp_remote_post($auth_url, array(
|
||||
'body' => $auth_data,
|
||||
'timeout' => 30,
|
||||
'headers' => array(
|
||||
'Accept-Language' => 'zh-cn',
|
||||
'Connection' => 'Keep-Alive',
|
||||
'Cache-Control' => 'no-cache'
|
||||
)
|
||||
));
|
||||
|
||||
if (is_wp_error($response)) {
|
||||
throw new Exception('认证请求失败: ' . $response->get_error_message());
|
||||
}
|
||||
|
||||
$body = wp_remote_retrieve_body($response);
|
||||
if (defined('WP_DEBUG_LOG') && WP_DEBUG_LOG) {
|
||||
error_log('CZL Express: Auth raw response - ' . $body);
|
||||
}
|
||||
|
||||
// 解析响应
|
||||
$result = json_decode(str_replace("'", '"', $response), true);
|
||||
$result = json_decode(str_replace("'", '"', $body), true);
|
||||
if (defined('WP_DEBUG_LOG') && WP_DEBUG_LOG) {
|
||||
error_log('CZL Express: Auth decoded response - ' . print_r($result, true));
|
||||
}
|
||||
|
||||
if (empty($result) || !isset($result['customer_id'])) {
|
||||
throw new Exception('认证失败: 无效的响应数据');
|
||||
@ -547,17 +534,21 @@ class CZL_API {
|
||||
);
|
||||
|
||||
} catch (Exception $e) {
|
||||
error_log('CZL Express Error: Authentication failed - ' . $e->getMessage());
|
||||
if (defined('WP_DEBUG_LOG') && WP_DEBUG_LOG) {
|
||||
error_log('CZL Express Error: Authentication failed - ' . esc_html($e->getMessage()));
|
||||
}
|
||||
return array(
|
||||
'ack' => false,
|
||||
'message' => $e->getMessage()
|
||||
'message' => esc_html($e->getMessage())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function create_shipment($params) {
|
||||
try {
|
||||
if (defined('WP_DEBUG_LOG') && WP_DEBUG_LOG) {
|
||||
error_log('CZL Express: Starting create shipment');
|
||||
}
|
||||
|
||||
// 先进行认证
|
||||
$auth_result = $this->authenticate();
|
||||
@ -571,71 +562,57 @@ class CZL_API {
|
||||
|
||||
// 准备请求数据
|
||||
$request_data = array(
|
||||
'param' => json_encode($params)
|
||||
'param' => wp_json_encode($params)
|
||||
);
|
||||
|
||||
if (defined('WP_DEBUG_LOG') && WP_DEBUG_LOG) {
|
||||
error_log('CZL Express: Create shipment request data - ' . print_r($request_data, true));
|
||||
|
||||
// 发送请求
|
||||
$curl = curl_init();
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => 'https://tms.czl.net/createOrderApi.htm',
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 30,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_2_0,
|
||||
CURLOPT_CUSTOMREQUEST => 'POST',
|
||||
CURLOPT_POSTFIELDS => http_build_query($request_data),
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
'Accept: */*',
|
||||
'Accept-Language: zh-cn',
|
||||
'Cache-Control: no-cache',
|
||||
'Content-Type: application/x-www-form-urlencoded;charset=UTF-8'
|
||||
),
|
||||
CURLOPT_VERBOSE => true,
|
||||
CURLOPT_STDERR => fopen('php://temp', 'w+')
|
||||
));
|
||||
|
||||
// 获取详细的CURL日志
|
||||
$verbose = fopen('php://temp', 'w+');
|
||||
curl_setopt($curl, CURLOPT_STDERR, $verbose);
|
||||
|
||||
$response = curl_exec($curl);
|
||||
$err = curl_error($curl);
|
||||
|
||||
// 记录CURL详细日志
|
||||
rewind($verbose);
|
||||
$verboseLog = stream_get_contents($verbose);
|
||||
error_log('CZL Express: Curl verbose log - ' . $verboseLog);
|
||||
|
||||
if ($err) {
|
||||
throw new Exception('CURL错误: ' . $err);
|
||||
}
|
||||
|
||||
error_log('CZL Express: Raw response - ' . $response);
|
||||
// 发送请求
|
||||
$response = wp_remote_post('https://tms.czl.net/createOrderApi.htm', array(
|
||||
'body' => $request_data,
|
||||
'timeout' => 30,
|
||||
'headers' => array(
|
||||
'Accept' => '*/*',
|
||||
'Accept-Language' => 'zh-cn',
|
||||
'Cache-Control' => 'no-cache',
|
||||
'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8'
|
||||
)
|
||||
));
|
||||
|
||||
$result = json_decode($response, true);
|
||||
if (is_wp_error($response)) {
|
||||
throw new Exception('CURL错误: ' . $response->get_error_message());
|
||||
}
|
||||
|
||||
$body = wp_remote_retrieve_body($response);
|
||||
if (defined('WP_DEBUG_LOG') && WP_DEBUG_LOG) {
|
||||
error_log('CZL Express: Raw response - ' . $body);
|
||||
}
|
||||
|
||||
$result = json_decode($body, true);
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
throw new Exception('JSON解析错误: ' . json_last_error_msg());
|
||||
}
|
||||
|
||||
if (defined('WP_DEBUG_LOG') && WP_DEBUG_LOG) {
|
||||
error_log('CZL Express: Create shipment response - ' . print_r($result, true));
|
||||
}
|
||||
|
||||
// 检查API错误信息
|
||||
if (isset($result['message']) && !empty($result['message'])) {
|
||||
if (defined('WP_DEBUG_LOG') && WP_DEBUG_LOG) {
|
||||
error_log('CZL Express: API error message - ' . $result['message']);
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
} catch (Exception $e) {
|
||||
error_log('CZL Express API Error: ' . $e->getMessage());
|
||||
throw $e;
|
||||
} finally {
|
||||
if (isset($curl)) {
|
||||
curl_close($curl);
|
||||
if (defined('WP_DEBUG_LOG') && WP_DEBUG_LOG) {
|
||||
error_log('CZL Express API Error: ' . esc_html($e->getMessage()));
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
@ -666,7 +643,7 @@ class CZL_API {
|
||||
);
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new Exception('获取跟踪单号失败: ' . $e->getMessage());
|
||||
throw new Exception('获取跟踪单号失败: ' . esc_html($e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -752,11 +729,11 @@ class CZL_API {
|
||||
);
|
||||
|
||||
} catch (Exception $e) {
|
||||
error_log('CZL Express API Error: ' . $e->getMessage());
|
||||
error_log('CZL Express API Error: ' . esc_html($e->getMessage()));
|
||||
return array(
|
||||
'success' => false,
|
||||
'data' => null,
|
||||
'message' => $e->getMessage()
|
||||
'message' => esc_html($e->getMessage())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ class CZL_Label {
|
||||
if ($url) {
|
||||
$actions['czl_print_label'] = array(
|
||||
'url' => wp_nonce_url(admin_url('admin-ajax.php?action=czl_print_label&order_id=' . $order->get_id()), 'czl_print_label'),
|
||||
'name' => __('打印运单', 'woo-czl-express'),
|
||||
'name' => __('打印运单', 'czlexpress-for-woocommerce'),
|
||||
'action' => 'czl_print_label'
|
||||
);
|
||||
}
|
||||
@ -70,19 +70,19 @@ class CZL_Label {
|
||||
*/
|
||||
public static function handle_print_request() {
|
||||
if (!current_user_can('edit_shop_orders')) {
|
||||
wp_die(__('您没有权限执行此操作', 'woo-czl-express'));
|
||||
wp_die(__('您没有权限执行此操作', 'czlexpress-for-woocommerce'));
|
||||
}
|
||||
|
||||
check_admin_referer('czl_print_label');
|
||||
|
||||
$order_id = isset($_GET['order_id']) ? absint($_GET['order_id']) : 0;
|
||||
if (!$order_id) {
|
||||
wp_die(__('订单ID无效', 'woo-czl-express'));
|
||||
wp_die(__('订单ID无效', 'czlexpress-for-woocommerce'));
|
||||
}
|
||||
|
||||
$label_url = self::get_label_url($order_id);
|
||||
if (!$label_url) {
|
||||
wp_die(__('未找到运单标签', 'woo-czl-express'));
|
||||
wp_die(__('未找到运单标签', 'czlexpress-for-woocommerce'));
|
||||
}
|
||||
|
||||
wp_redirect($label_url);
|
||||
|
@ -39,28 +39,34 @@ class CZL_Order_Handler {
|
||||
update_post_meta($order_id, '_czl_order_id', $response['order_id']);
|
||||
update_post_meta($order_id, '_czl_tracking_number', $response['tracking_number']);
|
||||
|
||||
// 添加订单备注
|
||||
$note = sprintf(
|
||||
__('CZL Express运单创建成功。运单号: %s', 'woo-czl-express'),
|
||||
$response['tracking_number']
|
||||
// 在数据库中创建运单记录
|
||||
global $wpdb;
|
||||
$wpdb->insert(
|
||||
$wpdb->prefix . 'czl_shipments',
|
||||
array(
|
||||
'order_id' => $order_id,
|
||||
'tracking_number' => $response['tracking_number'],
|
||||
'czl_order_id' => $response['order_id'],
|
||||
'status' => 'pending',
|
||||
'created_at' => current_time('mysql')
|
||||
),
|
||||
array('%d', '%s', '%s', '%s', '%s')
|
||||
);
|
||||
$order->add_order_note($note);
|
||||
|
||||
// 获取并保存运单标签URL
|
||||
$label_url = $this->api->get_label($response['order_id']);
|
||||
if ($label_url) {
|
||||
update_post_meta($order_id, '_czl_label_url', $label_url);
|
||||
}
|
||||
}
|
||||
$shipment_id = $wpdb->insert_id;
|
||||
|
||||
// 清除相关缓存
|
||||
$tracking = new CZL_Tracking();
|
||||
$tracking->clear_tracking_cache($shipment_id, $response['tracking_number'], $order_id);
|
||||
|
||||
return $response;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$error_message = sprintf(
|
||||
__('CZL Express运单创建失败: %s', 'woo-czl-express'),
|
||||
$e->getMessage()
|
||||
);
|
||||
$order->add_order_note($error_message);
|
||||
error_log('CZL Express Error: ' . $error_message);
|
||||
error_log('CZL Express Error: Failed to create shipment - ' . $e->getMessage());
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -94,7 +100,7 @@ class CZL_Order_Handler {
|
||||
$response = $this->api->cancel_order($czl_order_id);
|
||||
|
||||
// 添加订单备注
|
||||
$note = __('CZL Express运单已取消', 'woo-czl-express');
|
||||
$note = __('CZL Express运单已取消', 'czlexpress-for-woocommerce');
|
||||
$order->add_order_note($note);
|
||||
|
||||
// 清除运单信息
|
||||
@ -104,7 +110,7 @@ class CZL_Order_Handler {
|
||||
|
||||
} catch (Exception $e) {
|
||||
$error_message = sprintf(
|
||||
__('CZL Express运单取消失败: %s', 'woo-czl-express'),
|
||||
__('CZL Express运单取消失败: %s', 'czlexpress-for-woocommerce'),
|
||||
$e->getMessage()
|
||||
);
|
||||
$order->add_order_note($error_message);
|
||||
|
@ -131,16 +131,16 @@ if (!class_exists('CZL_Order')) {
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
error_log('CZL Express Error: Create shipment failed - ' . $e->getMessage());
|
||||
error_log('CZL Express Error Stack Trace: ' . $e->getTraceAsString());
|
||||
error_log('CZL Express Error: Create shipment failed - ' . esc_html($e->getMessage()));
|
||||
error_log('CZL Express Error Stack Trace: ' . esc_html($e->getTraceAsString()));
|
||||
|
||||
// 添加错误提示到订单备注
|
||||
if (isset($order)) {
|
||||
$order->add_order_note('运单创建失败: ' . $e->getMessage());
|
||||
$order->add_order_note('运单创建失败: ' . esc_html($e->getMessage()));
|
||||
}
|
||||
|
||||
// 抛出异常以便上层处理
|
||||
throw new Exception($e->getMessage());
|
||||
throw new Exception(esc_html($e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,33 +14,33 @@ class CZL_Product_Fields {
|
||||
// 中文品名字段
|
||||
woocommerce_wp_text_input(array(
|
||||
'id' => '_czl_name_cn',
|
||||
'label' => __('中文品名', 'woo-czl-express'),
|
||||
'label' => __('Chinese Name', 'czlexpress-for-woocommerce'),
|
||||
'desc_tip' => true,
|
||||
'description' => __('输入产品的中文名称,用于物流申报', 'woo-czl-express')
|
||||
'description' => __('Enter the Chinese name of the product', 'czlexpress-for-woocommerce')
|
||||
));
|
||||
|
||||
// 海关编码字段
|
||||
woocommerce_wp_text_input(array(
|
||||
'id' => '_czl_hs_code',
|
||||
'label' => __('海关编码 (HS Code)', 'woo-czl-express'),
|
||||
'label' => __('HS Code', 'czlexpress-for-woocommerce'),
|
||||
'desc_tip' => true,
|
||||
'description' => __('输入产品的海关编码 (HS Code)', 'woo-czl-express')
|
||||
'description' => __('Enter the HS code for customs declaration', 'czlexpress-for-woocommerce')
|
||||
));
|
||||
|
||||
// 用途字段
|
||||
woocommerce_wp_text_input(array(
|
||||
'id' => '_czl_usage',
|
||||
'label' => __('用途', 'woo-czl-express'),
|
||||
'label' => __('Usage', 'czlexpress-for-woocommerce'),
|
||||
'desc_tip' => true,
|
||||
'description' => __('输入产品的用途,例如:日常使用、装饰等', 'woo-czl-express')
|
||||
'description' => __('Enter the product usage, e.g., daily use, decoration, etc.', 'czlexpress-for-woocommerce')
|
||||
));
|
||||
|
||||
// 材质字段
|
||||
woocommerce_wp_text_input(array(
|
||||
'id' => '_czl_material',
|
||||
'label' => __('材质', 'woo-czl-express'),
|
||||
'label' => __('Material', 'czlexpress-for-woocommerce'),
|
||||
'desc_tip' => true,
|
||||
'description' => __('输入产品的材质,例如:塑料、金属、布料等', 'woo-czl-express')
|
||||
'description' => __('Enter the product material, e.g., plastic, metal, fabric, etc.', 'czlexpress-for-woocommerce')
|
||||
));
|
||||
|
||||
echo '</div>';
|
||||
|
@ -20,12 +20,12 @@ class CZL_Rate_Calculator {
|
||||
// 如果没有配置,使用默认分组
|
||||
if (empty($groups)) {
|
||||
$groups = array(
|
||||
'ups_blue' => array(
|
||||
'ups_expedited' => array(
|
||||
'enabled' => true,
|
||||
'groupName' => 'UPS Expedited',
|
||||
'prefixes' => array('UPS 蓝单')
|
||||
),
|
||||
'ups_red' => array(
|
||||
'ups_saver' => array(
|
||||
'enabled' => true,
|
||||
'groupName' => 'UPS Saver',
|
||||
'prefixes' => array('UPS 红单')
|
||||
@ -47,58 +47,34 @@ class CZL_Rate_Calculator {
|
||||
),
|
||||
'europe_normal' => array(
|
||||
'enabled' => true,
|
||||
'groupName' => 'European and American general package tax line',
|
||||
'groupName' => __('Customs duty line', 'czlexpress-for-woocommerce'),
|
||||
'prefixes' => array(
|
||||
'欧美经济专线(普货)',
|
||||
'欧美标准专线(普货)',
|
||||
'欧洲经济专线(普货)',
|
||||
'欧洲标准专线(普货)'
|
||||
__('欧美经济专线(普货)', 'czlexpress-for-woocommerce'),
|
||||
__('欧洲经济专线(普货)', 'czlexpress-for-woocommerce')
|
||||
)
|
||||
),
|
||||
'europe_b' => array(
|
||||
'europe_fast' => array(
|
||||
'enabled' => true,
|
||||
'groupName' => 'European and American B-class tax line',
|
||||
'groupName' => __('Fast customs duty line', 'czlexpress-for-woocommerce'),
|
||||
'prefixes' => array(
|
||||
'欧美经济专线(B类)',
|
||||
'欧美标准专线(B类)',
|
||||
'欧洲经济专线(B类)',
|
||||
'欧洲标准专线(B类)'
|
||||
__('欧美标准专线(普货)', 'czlexpress-for-woocommerce'),
|
||||
__('欧洲标准专线(普货)', 'czlexpress-for-woocommerce')
|
||||
)
|
||||
),
|
||||
'europe_battery' => array(
|
||||
'ems' => array(
|
||||
'enabled' => true,
|
||||
'groupName' => 'European and American battery tax line',
|
||||
'prefixes' => array(
|
||||
'欧美经济专线(带电)',
|
||||
'欧美标准专线(带电)',
|
||||
'欧洲经济专线(带电)',
|
||||
'欧洲标准专线(带电)'
|
||||
)
|
||||
),
|
||||
'dubai_dhl' => array(
|
||||
'enabled' => true,
|
||||
'groupName' => 'Dubai DHL',
|
||||
'prefixes' => array('迪拜DHL')
|
||||
),
|
||||
'dubai_ups' => array(
|
||||
'enabled' => true,
|
||||
'groupName' => 'Dubai UPS',
|
||||
'prefixes' => array('迪拜UPS')
|
||||
),
|
||||
'dubai_fedex' => array(
|
||||
'enabled' => true,
|
||||
'groupName' => 'Dubai FEDEX',
|
||||
'prefixes' => array('迪拜FEDEX')
|
||||
),
|
||||
'post' => array(
|
||||
'enabled' => true,
|
||||
'groupName' => 'Post',
|
||||
'prefixes' => array('E特快', 'EMS')
|
||||
'groupName' => __('EMS', 'czlexpress-for-woocommerce'),
|
||||
'prefixes' => array(__('EMS', 'czlexpress-for-woocommerce'))
|
||||
),
|
||||
'czl_uae' => array(
|
||||
'enabled' => true,
|
||||
'groupName' => 'CZL UAE Line',
|
||||
'prefixes' => array('CZL阿联酋')
|
||||
'prefixes' => array('CZL阿联酋经济专线')
|
||||
),
|
||||
'czl_uae_fast' => array(
|
||||
'enabled' => true,
|
||||
'groupName' => 'CZL UAE Fast Line',
|
||||
'prefixes' => array('CZL阿联酋特快专线')
|
||||
)
|
||||
);
|
||||
update_option('czl_product_groups', $groups);
|
||||
|
@ -26,25 +26,25 @@ class CZL_Settings {
|
||||
'basic' => array(
|
||||
array(
|
||||
'name' => 'czl_api_url',
|
||||
'label' => __('API URL', 'woo-czl-express'),
|
||||
'label' => __('API URL', 'czlexpress-for-woocommerce'),
|
||||
'type' => 'text',
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'name' => 'czl_username',
|
||||
'label' => __('Username', 'woo-czl-express'),
|
||||
'label' => __('Username', 'czlexpress-for-woocommerce'),
|
||||
'type' => 'text',
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'name' => 'czl_password',
|
||||
'label' => __('Password', 'woo-czl-express'),
|
||||
'label' => __('Password', 'czlexpress-for-woocommerce'),
|
||||
'type' => 'password',
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'name' => 'czl_exchange_rate',
|
||||
'label' => __('Exchange Rate', 'woo-czl-express'),
|
||||
'label' => __('Exchange Rate', 'czlexpress-for-woocommerce'),
|
||||
'type' => 'number',
|
||||
'default' => '1',
|
||||
'step' => '0.0001',
|
||||
|
@ -8,9 +8,9 @@ class WC_CZL_Shipping_Method extends WC_Shipping_Method {
|
||||
|
||||
$this->id = 'czl_express';
|
||||
$this->instance_id = absint($instance_id);
|
||||
$this->title = __('CZL Express', 'woo-czl-express');
|
||||
$this->method_title = __('CZL Express', 'woo-czl-express');
|
||||
$this->method_description = __('CZL Express shipping integration', 'woo-czl-express');
|
||||
$this->title = __('CZL Express', 'czlexpress-for-woocommerce');
|
||||
$this->method_title = __('CZL Express', 'czlexpress-for-woocommerce');
|
||||
$this->method_description = __('CZL Express shipping integration', 'czlexpress-for-woocommerce');
|
||||
|
||||
$this->supports = array(
|
||||
'shipping-zones',
|
||||
@ -42,43 +42,44 @@ class WC_CZL_Shipping_Method extends WC_Shipping_Method {
|
||||
public function init_form_fields() {
|
||||
$this->instance_form_fields = array(
|
||||
'enabled' => array(
|
||||
'title' => __('Enable/Disable', 'woo-czl-express'),
|
||||
'title' => __('Enable/Disable', 'czlexpress-for-woocommerce'),
|
||||
'type' => 'checkbox',
|
||||
'label' => __('Enable this shipping method', 'woo-czl-express'),
|
||||
'label' => __('Enable this shipping method', 'czlexpress-for-woocommerce'),
|
||||
'default' => 'yes'
|
||||
),
|
||||
'title' => array(
|
||||
'title' => __('Method Title', 'woo-czl-express'),
|
||||
'title' => __('Method Title', 'czlexpress-for-woocommerce'),
|
||||
'type' => 'text',
|
||||
'description' => __('This controls the title which the user sees during checkout.', 'woo-czl-express'),
|
||||
'default' => __('CZL Express', 'woo-czl-express'),
|
||||
'description' => __('This controls the title which the user sees during checkout.', 'czlexpress-for-woocommerce'),
|
||||
'default' => __('CZL Express', 'czlexpress-for-woocommerce'),
|
||||
'desc_tip' => true
|
||||
),
|
||||
'show_all_rates' => array(
|
||||
'title' => __('显示方式', 'woo-czl-express'),
|
||||
'title' => __('Display Mode', 'czlexpress-for-woocommerce'),
|
||||
'type' => 'select',
|
||||
'description' => __('选择是显示分组运费还是显示所有具体线路', 'woo-czl-express'),
|
||||
'description' => __('Choose to display grouped shipping rates or all specific routes', 'czlexpress-for-woocommerce'),
|
||||
'default' => 'no',
|
||||
'options' => array(
|
||||
'no' => __('显示分组运费', 'woo-czl-express'),
|
||||
'yes' => __('显示所有线路', 'woo-czl-express')
|
||||
'no' => __('Show Grouped Rates', 'czlexpress-for-woocommerce'),
|
||||
'yes' => __('Show All Routes', 'czlexpress-for-woocommerce')
|
||||
)
|
||||
),
|
||||
'sort_by' => array(
|
||||
'title' => __('排序方式', 'woo-czl-express'),
|
||||
'title' => __('Sort Order', 'czlexpress-for-woocommerce'),
|
||||
'type' => 'select',
|
||||
'description' => __('选择运费显示的排序方式', 'woo-czl-express'),
|
||||
'description' => __('Choose how to sort shipping rates', 'czlexpress-for-woocommerce'),
|
||||
'default' => 'price',
|
||||
'options' => array(
|
||||
'price' => __('按价格排序', 'woo-czl-express'),
|
||||
'time' => __('按时效排序', 'woo-czl-express')
|
||||
'price' => __('Sort by Price', 'czlexpress-for-woocommerce'),
|
||||
'time' => __('Sort by Delivery Time', 'czlexpress-for-woocommerce')
|
||||
)
|
||||
),
|
||||
'exchange_rate' => array(
|
||||
'title' => __('汇率设置', 'woo-czl-express'),
|
||||
'title' => __('Exchange Rate', 'czlexpress-for-woocommerce'),
|
||||
'type' => 'text',
|
||||
'description' => sprintf(
|
||||
__('设置CNY到%s的汇率。例如:如果1CNY=%s0.14,输入0.14', 'woo-czl-express'),
|
||||
/* translators: 1: currency code, 2: currency symbol */
|
||||
__('Set exchange rate from CNY to %1$s. Example: if 1 CNY = %2$s0.14, enter 0.14', 'czlexpress-for-woocommerce'),
|
||||
get_woocommerce_currency(),
|
||||
get_woocommerce_currency_symbol()
|
||||
),
|
||||
@ -144,9 +145,9 @@ class WC_CZL_Shipping_Method extends WC_Shipping_Method {
|
||||
if (is_cart() || is_checkout()) {
|
||||
wp_enqueue_style(
|
||||
'czl-shipping-method',
|
||||
WOO_CZL_EXPRESS_URL . 'assets/css/shipping-method.css',
|
||||
CZL_EXPRESS_URL . 'assets/css/shipping-method.css',
|
||||
array(),
|
||||
WOO_CZL_EXPRESS_VERSION
|
||||
CZL_EXPRESS_VERSION
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -100,8 +100,11 @@ class CZL_Tracking {
|
||||
// 更新WooCommerce订单状态
|
||||
$order = wc_get_order($shipment->order_id);
|
||||
if ($order) {
|
||||
$order->update_status($new_status, __('Package status updated from tracking info', 'woo-czl-express'));
|
||||
$order->update_status($new_status, esc_html__('Package status updated from tracking info', 'czlexpress-for-woocommerce'));
|
||||
}
|
||||
|
||||
// 清除相关缓存
|
||||
$this->clear_tracking_cache($shipment->id, $tracking_number, $shipment->order_id);
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
@ -109,6 +112,34 @@ class CZL_Tracking {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除运单相关的所有缓存
|
||||
*
|
||||
* @param int $shipment_id 运单ID
|
||||
* @param string $tracking_number 运单号
|
||||
* @param int $order_id 订单ID
|
||||
*/
|
||||
public function clear_tracking_cache($shipment_id, $tracking_number, $order_id) {
|
||||
// 清除运单缓存
|
||||
wp_cache_delete('czl_shipment_' . $shipment_id);
|
||||
wp_cache_delete('czl_tracking_' . $tracking_number);
|
||||
|
||||
// 清除订单相关缓存
|
||||
wp_cache_delete('czl_order_shipments_' . $order_id);
|
||||
wp_cache_delete('czl_order_tracking_' . $order_id);
|
||||
|
||||
// 清除轨迹历史缓存
|
||||
wp_cache_delete('czl_tracking_history_' . $shipment_id);
|
||||
wp_cache_delete('czl_latest_tracking_' . $tracking_number);
|
||||
|
||||
// 清除运单列表缓存
|
||||
wp_cache_delete('czl_active_shipments');
|
||||
wp_cache_delete('czl_pending_shipments');
|
||||
|
||||
// 触发缓存清除动作,允许其他部分清除相关缓存
|
||||
do_action('czl_tracking_cache_cleared', $shipment_id, $tracking_number, $order_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 在订单详情页显示跟踪信息
|
||||
*/
|
||||
@ -123,16 +154,16 @@ class CZL_Tracking {
|
||||
$tracking_info = $api->get_tracking($tracking_number);
|
||||
|
||||
if (!empty($tracking_info)) {
|
||||
echo '<h2>' . __('物流跟踪信息', 'woo-czl-express') . '</h2>';
|
||||
echo '<h2>' . esc_html__('物流跟踪信息', 'czlexpress-for-woocommerce') . '</h2>';
|
||||
echo '<div class="czl-tracking-info">';
|
||||
echo '<p><strong>' . __('运单号:', 'woo-czl-express') . '</strong>' . esc_html($tracking_number) . '</p>';
|
||||
echo '<p><strong>' . esc_html__('运单号:', 'czlexpress-for-woocommerce') . '</strong>' . esc_html($tracking_number) . '</p>';
|
||||
|
||||
if (!empty($tracking_info['trackDetails'])) {
|
||||
echo '<table class="czl-tracking-details">';
|
||||
echo '<thead><tr>';
|
||||
echo '<th>' . __('时间', 'woo-czl-express') . '</th>';
|
||||
echo '<th>' . __('地点', 'woo-czl-express') . '</th>';
|
||||
echo '<th>' . __('状态', 'woo-czl-express') . '</th>';
|
||||
echo '<th>' . esc_html__('时间', 'czlexpress-for-woocommerce') . '</th>';
|
||||
echo '<th>' . esc_html__('地点', 'czlexpress-for-woocommerce') . '</th>';
|
||||
echo '<th>' . esc_html__('状态', 'czlexpress-for-woocommerce') . '</th>';
|
||||
echo '</tr></thead><tbody>';
|
||||
|
||||
foreach ($tracking_info['trackDetails'] as $detail) {
|
||||
@ -160,7 +191,7 @@ class CZL_Tracking {
|
||||
$tracking_number = get_post_meta($order->get_id(), '_czl_tracking_number', true);
|
||||
if ($tracking_number) {
|
||||
$tracking_url = 'https://exp.czl.net/track/?query=' . urlencode($tracking_number);
|
||||
echo '<p><strong>' . __('物流跟踪:', 'woo-czl-express') . '</strong>';
|
||||
echo '<p><strong>' . esc_html__('物流跟踪:', 'czlexpress-for-woocommerce') . '</strong>';
|
||||
echo '<a href="' . esc_url($tracking_url) . '" target="_blank">' . esc_html($tracking_number) . '</a></p>';
|
||||
}
|
||||
}
|
||||
@ -176,11 +207,11 @@ class CZL_Tracking {
|
||||
|
||||
?>
|
||||
<div class="czl-admin-tracking-info">
|
||||
<h3><?php _e('CZL Express 运单信息', 'woo-czl-express'); ?></h3>
|
||||
<h3><?php esc_html_e('CZL Express 运单信息', 'czlexpress-for-woocommerce'); ?></h3>
|
||||
<p>
|
||||
<?php
|
||||
printf(
|
||||
__('运单号: %s', 'woo-czl-express'),
|
||||
esc_html__('运单号: %s', 'czlexpress-for-woocommerce'),
|
||||
'<a href="https://exp.czl.net/track/?query=' . esc_attr($tracking_number) . '" target="_blank">' .
|
||||
esc_html($tracking_number) . '</a>'
|
||||
);
|
||||
@ -191,14 +222,14 @@ class CZL_Tracking {
|
||||
// 显示子单号
|
||||
$child_numbers = $order->get_meta('_czl_child_numbers');
|
||||
if (!empty($child_numbers)) {
|
||||
echo '<p><strong>' . __('子单号:', 'woo-czl-express') . '</strong> ' .
|
||||
echo '<p><strong>' . esc_html__('子单号:', 'czlexpress-for-woocommerce') . '</strong> ' .
|
||||
implode(', ', array_map('esc_html', $child_numbers)) . '</p>';
|
||||
}
|
||||
|
||||
// 显示参考号
|
||||
$reference_number = $order->get_meta('_czl_reference_number');
|
||||
if (!empty($reference_number)) {
|
||||
echo '<p><strong>' . __('参考号:', 'woo-czl-express') . '</strong> ' .
|
||||
echo '<p><strong>' . esc_html__('参考号:', 'czlexpress-for-woocommerce') . '</strong> ' .
|
||||
esc_html($reference_number) . '</p>';
|
||||
}
|
||||
|
||||
@ -208,32 +239,32 @@ class CZL_Tracking {
|
||||
$remote_text = '';
|
||||
switch ($is_remote) {
|
||||
case 'Y':
|
||||
$remote_text = __('偏远地区', 'woo-czl-express');
|
||||
$remote_text = esc_html__('偏远地区', 'czlexpress-for-woocommerce');
|
||||
break;
|
||||
case 'A':
|
||||
$remote_text = __('FedEx偏远A级', 'woo-czl-express');
|
||||
$remote_text = esc_html__('FedEx偏远A级', 'czlexpress-for-woocommerce');
|
||||
break;
|
||||
case 'B':
|
||||
$remote_text = __('FedEx偏远B级', 'woo-czl-express');
|
||||
$remote_text = esc_html__('FedEx偏远B级', 'czlexpress-for-woocommerce');
|
||||
break;
|
||||
case 'C':
|
||||
$remote_text = __('FedEx偏远C级', 'woo-czl-express');
|
||||
$remote_text = esc_html__('FedEx偏远C级', 'czlexpress-for-woocommerce');
|
||||
break;
|
||||
case 'N':
|
||||
$remote_text = __('非偏远地区', 'woo-czl-express');
|
||||
$remote_text = esc_html__('非偏远地区', 'czlexpress-for-woocommerce');
|
||||
break;
|
||||
}
|
||||
if ($remote_text) {
|
||||
echo '<p><strong>' . __('地区类型:', 'woo-czl-express') . '</strong> ' .
|
||||
esc_html($remote_text) . '</p>';
|
||||
echo '<p><strong>' . esc_html__('地区类型:', 'czlexpress-for-woocommerce') . '</strong> ' .
|
||||
$remote_text . '</p>';
|
||||
}
|
||||
}
|
||||
|
||||
// 显示住宅信息
|
||||
$is_residential = $order->get_meta('_czl_is_residential');
|
||||
if ($is_residential === 'Y') {
|
||||
echo '<p><strong>' . __('地址类型:', 'woo-czl-express') . '</strong> ' .
|
||||
__('住宅地址', 'woo-czl-express') . '</p>';
|
||||
echo '<p><strong>' . esc_html__('地址类型:', 'czlexpress-for-woocommerce') . '</strong> ' .
|
||||
esc_html__('住宅地址', 'czlexpress-for-woocommerce') . '</p>';
|
||||
}
|
||||
|
||||
// 显示轨迹信息
|
||||
@ -241,7 +272,7 @@ class CZL_Tracking {
|
||||
if (!empty($tracking_history['trackDetails'])) {
|
||||
?>
|
||||
<div class="czl-tracking-details">
|
||||
<h4><?php _e('最新轨迹', 'woo-czl-express'); ?></h4>
|
||||
<h4><?php esc_html_e('最新轨迹', 'czlexpress-for-woocommerce'); ?></h4>
|
||||
<?php
|
||||
$latest = reset($tracking_history['trackDetails']);
|
||||
?>
|
||||
|
@ -1,5 +1,8 @@
|
||||
<?php
|
||||
class WooCzlExpress {
|
||||
/**
|
||||
* CZL Express 主类
|
||||
*/
|
||||
class CZLExpress {
|
||||
private static $instance = null;
|
||||
private $order_handler;
|
||||
|
||||
@ -11,7 +14,6 @@ class WooCzlExpress {
|
||||
}
|
||||
|
||||
public function __construct() {
|
||||
register_activation_hook(WOO_CZL_EXPRESS_PATH . 'woo-commerce-czlexpress.php', array('CZL_Install', 'init'));
|
||||
$this->init();
|
||||
add_action('admin_init', array($this, 'register_settings'));
|
||||
add_action('wp_ajax_czl_test_connection', array($this, 'handle_test_connection'));
|
||||
@ -39,7 +41,7 @@ class WooCzlExpress {
|
||||
// 添加状态迁移钩子
|
||||
add_action('init', array($this, 'migrate_order_statuses'), 20);
|
||||
|
||||
// 保留批量创建功能,因为这是我们自己的订单管理页面的功能
|
||||
// 保留批量创建功能
|
||||
add_action('wp_ajax_czl_bulk_create_shipment', array($this, 'handle_bulk_create_shipment'));
|
||||
}
|
||||
|
||||
@ -58,17 +60,17 @@ class WooCzlExpress {
|
||||
}
|
||||
|
||||
private function load_dependencies() {
|
||||
require_once WOO_CZL_EXPRESS_PATH . 'includes/class-czl-api.php';
|
||||
require_once WOO_CZL_EXPRESS_PATH . 'includes/class-czl-rate-calculator.php';
|
||||
require_once WOO_CZL_EXPRESS_PATH . 'includes/class-czl-shipping-method.php';
|
||||
require_once WOO_CZL_EXPRESS_PATH . 'includes/class-czl-install.php';
|
||||
require_once WOO_CZL_EXPRESS_PATH . 'includes/class-czl-settings.php';
|
||||
require_once WOO_CZL_EXPRESS_PATH . 'includes/class-czl-order-handler.php';
|
||||
require_once WOO_CZL_EXPRESS_PATH . 'includes/class-czl-order-data.php';
|
||||
require_once WOO_CZL_EXPRESS_PATH . 'includes/class-czl-label.php';
|
||||
require_once WOO_CZL_EXPRESS_PATH . 'includes/class-czl-tracking.php';
|
||||
require_once WOO_CZL_EXPRESS_PATH . 'includes/class-czl-product-fields.php';
|
||||
require_once WOO_CZL_EXPRESS_PATH . 'includes/class-czl-order.php';
|
||||
require_once CZL_EXPRESS_PATH . 'includes/class-czl-api.php';
|
||||
require_once CZL_EXPRESS_PATH . 'includes/class-czl-rate-calculator.php';
|
||||
require_once CZL_EXPRESS_PATH . 'includes/class-czl-shipping-method.php';
|
||||
require_once CZL_EXPRESS_PATH . 'includes/class-czl-install.php';
|
||||
require_once CZL_EXPRESS_PATH . 'includes/class-czl-settings.php';
|
||||
require_once CZL_EXPRESS_PATH . 'includes/class-czl-order-handler.php';
|
||||
require_once CZL_EXPRESS_PATH . 'includes/class-czl-order-data.php';
|
||||
require_once CZL_EXPRESS_PATH . 'includes/class-czl-label.php';
|
||||
require_once CZL_EXPRESS_PATH . 'includes/class-czl-tracking.php';
|
||||
require_once CZL_EXPRESS_PATH . 'includes/class-czl-product-fields.php';
|
||||
require_once CZL_EXPRESS_PATH . 'includes/class-czl-order.php';
|
||||
}
|
||||
|
||||
private function init_hooks() {
|
||||
@ -91,7 +93,7 @@ class WooCzlExpress {
|
||||
|
||||
public function init_shipping_method() {
|
||||
if (!class_exists('WC_CZL_Shipping_Method')) {
|
||||
require_once WOO_CZL_EXPRESS_PATH . 'includes/class-czl-shipping-method.php';
|
||||
require_once CZL_EXPRESS_PATH . 'includes/class-czl-shipping-method.php';
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,45 +106,45 @@ class WooCzlExpress {
|
||||
|
||||
public function add_admin_menu() {
|
||||
add_menu_page(
|
||||
__('CZL Express', 'woo-czl-express'),
|
||||
__('CZL Express', 'woo-czl-express'),
|
||||
esc_html__('CZL Express', 'czlexpress-for-woocommerce'),
|
||||
esc_html__('CZL Express', 'czlexpress-for-woocommerce'),
|
||||
'manage_woocommerce',
|
||||
'woo-czl-express',
|
||||
'czlexpress-for-woocommerce',
|
||||
array($this, 'render_settings_page'),
|
||||
'dashicons-airplane'
|
||||
);
|
||||
|
||||
add_submenu_page(
|
||||
'woo-czl-express',
|
||||
__('基本设置', 'woo-czl-express'),
|
||||
__('基本设置', 'woo-czl-express'),
|
||||
'czlexpress-for-woocommerce',
|
||||
esc_html__('基本设置', 'czlexpress-for-woocommerce'),
|
||||
esc_html__('基本设置', 'czlexpress-for-woocommerce'),
|
||||
'manage_woocommerce',
|
||||
'woo-czl-express',
|
||||
'czlexpress-for-woocommerce',
|
||||
array($this, 'render_settings_page')
|
||||
);
|
||||
|
||||
add_submenu_page(
|
||||
'woo-czl-express',
|
||||
__('订单管理', 'woo-czl-express'),
|
||||
__('订单管理', 'woo-czl-express'),
|
||||
'czlexpress-for-woocommerce',
|
||||
esc_html__('订单管理', 'czlexpress-for-woocommerce'),
|
||||
esc_html__('订单管理', 'czlexpress-for-woocommerce'),
|
||||
'manage_woocommerce',
|
||||
'czl-express-orders',
|
||||
array($this, 'render_orders_page')
|
||||
);
|
||||
|
||||
add_submenu_page(
|
||||
'woo-czl-express',
|
||||
__('产品分组', 'woo-czl-express'),
|
||||
__('产品分组', 'woo-czl-express'),
|
||||
'czlexpress-for-woocommerce',
|
||||
esc_html__('产品分组', 'czlexpress-for-woocommerce'),
|
||||
esc_html__('产品分组', 'czlexpress-for-woocommerce'),
|
||||
'manage_options',
|
||||
'czl-product-groups',
|
||||
array($this, 'render_product_groups_page')
|
||||
);
|
||||
|
||||
add_submenu_page(
|
||||
'woo-czl-express',
|
||||
__('汇率设置', 'woo-czl-express'),
|
||||
__('汇率设置', 'woo-czl-express'),
|
||||
'czlexpress-for-woocommerce',
|
||||
esc_html__('汇率设置', 'czlexpress-for-woocommerce'),
|
||||
esc_html__('汇率设置', 'czlexpress-for-woocommerce'),
|
||||
'manage_options',
|
||||
'czl-exchange-rates',
|
||||
array($this, 'render_exchange_rates_page')
|
||||
@ -171,15 +173,15 @@ class WooCzlExpress {
|
||||
}
|
||||
|
||||
update_option('czl_product_groups', $groups);
|
||||
add_settings_error('czl_messages', 'czl_message', __('产品分组设置已保存', 'woo-czl-express'), 'updated');
|
||||
add_settings_error('czl_messages', 'czl_message', esc_html__('产品分组设置已保存', 'czlexpress-for-woocommerce'), 'updated');
|
||||
}
|
||||
|
||||
// 显示设置页面
|
||||
require_once WOO_CZL_EXPRESS_PATH . 'admin/views/product-groups.php';
|
||||
require_once CZL_EXPRESS_PATH . 'admin/views/product-groups.php';
|
||||
}
|
||||
|
||||
public function admin_page() {
|
||||
require_once WOO_CZL_EXPRESS_PATH . 'admin/views/admin-page.php';
|
||||
require_once CZL_EXPRESS_PATH . 'admin/views/admin-page.php';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -190,9 +192,9 @@ class WooCzlExpress {
|
||||
$tracking_number = get_post_meta($order->get_id(), '_czl_tracking_number', true);
|
||||
|
||||
if ($tracking_number) {
|
||||
$actions['czl_cancel_shipment'] = __('取消CZL运单', 'woo-czl-express');
|
||||
$actions['czl_cancel_shipment'] = esc_html__('取消CZL运单', 'czlexpress-for-woocommerce');
|
||||
} else {
|
||||
$actions['czl_create_shipment'] = __('创建CZL运单', 'woo-czl-express');
|
||||
$actions['czl_create_shipment'] = esc_html__('创建CZL运单', 'czlexpress-for-woocommerce');
|
||||
}
|
||||
|
||||
return $actions;
|
||||
@ -218,7 +220,7 @@ class WooCzlExpress {
|
||||
// 添加设置分节
|
||||
add_settings_section(
|
||||
'czl_api_settings',
|
||||
__('API设置', 'woo-czl-express'),
|
||||
esc_html__('API设置', 'czlexpress-for-woocommerce'),
|
||||
null,
|
||||
'czl_options'
|
||||
);
|
||||
@ -226,7 +228,7 @@ class WooCzlExpress {
|
||||
// 添加设置字段
|
||||
add_settings_field(
|
||||
'czl_username',
|
||||
__('用户名', 'woo-czl-express'),
|
||||
esc_html__('用户名', 'czlexpress-for-woocommerce'),
|
||||
array($this, 'username_field_callback'),
|
||||
'czl_options',
|
||||
'czl_api_settings'
|
||||
@ -234,7 +236,7 @@ class WooCzlExpress {
|
||||
|
||||
add_settings_field(
|
||||
'czl_password',
|
||||
__('密码', 'woo-czl-express'),
|
||||
esc_html__('密码', 'czlexpress-for-woocommerce'),
|
||||
array($this, 'password_field_callback'),
|
||||
'czl_options',
|
||||
'czl_api_settings'
|
||||
@ -243,14 +245,14 @@ class WooCzlExpress {
|
||||
// 添加运费调整设置分节
|
||||
add_settings_section(
|
||||
'czl_rate_settings',
|
||||
__('运费设置', 'woo-czl-express'),
|
||||
esc_html__('运费设置', 'czlexpress-for-woocommerce'),
|
||||
null,
|
||||
'czl_options'
|
||||
);
|
||||
|
||||
add_settings_field(
|
||||
'czl_rate_adjustment',
|
||||
__('运费调整公式', 'woo-czl-express'),
|
||||
esc_html__('运费调整公式', 'czlexpress-for-woocommerce'),
|
||||
array($this, 'rate_adjustment_field_callback'),
|
||||
'czl_options',
|
||||
'czl_rate_settings'
|
||||
@ -272,11 +274,11 @@ class WooCzlExpress {
|
||||
?>
|
||||
<input type="text" name="czl_rate_adjustment" value="<?php echo esc_attr($value); ?>" class="regular-text">
|
||||
<p class="description">
|
||||
<?php _e('设置运费调整公式,支持百分比和固定金额。例如:', 'woo-czl-express'); ?><br>
|
||||
<?php esc_html_e('设置运费调整公式,支持百分比和固定金额。例如:', 'czlexpress-for-woocommerce'); ?><br>
|
||||
- 10% + 10 (运费乘以1.1后加10)<br>
|
||||
- 20% (运费乘以1.2)<br>
|
||||
- +15 (运费加15)<br>
|
||||
<?php _e('留空表示不调整运费', 'woo-czl-express'); ?>
|
||||
<?php esc_html_e('留空表示不调整运费', 'czlexpress-for-woocommerce'); ?>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
@ -289,7 +291,7 @@ class WooCzlExpress {
|
||||
|
||||
if (empty($username) || empty($password)) {
|
||||
wp_send_json_error(array(
|
||||
'message' => __('请先配置API账号和密码', 'woo-czl-express')
|
||||
'message' => esc_html__('请先配置API账号和密码', 'czlexpress-for-woocommerce')
|
||||
));
|
||||
}
|
||||
|
||||
@ -311,11 +313,11 @@ class WooCzlExpress {
|
||||
|
||||
if (!empty($data) && isset($data['code']) && $data['code'] == 200) {
|
||||
wp_send_json_success(array(
|
||||
'message' => __('API连接测试成功', 'woo-czl-express')
|
||||
'message' => esc_html__('API连接测试成功', 'czlexpress-for-woocommerce')
|
||||
));
|
||||
} else {
|
||||
wp_send_json_error(array(
|
||||
'message' => __('API连接测试失败,请检查账号密码是否正确', 'woo-czl-express')
|
||||
'message' => esc_html__('API连接测试失败,请检查账号密码是否正确', 'czlexpress-for-woocommerce')
|
||||
));
|
||||
}
|
||||
}
|
||||
@ -326,7 +328,7 @@ class WooCzlExpress {
|
||||
}
|
||||
|
||||
// 显示设置页面
|
||||
require_once WOO_CZL_EXPRESS_PATH . 'admin/views/settings.php';
|
||||
require_once CZL_EXPRESS_PATH . 'admin/views/settings.php';
|
||||
}
|
||||
|
||||
public function render_exchange_rates_page() {
|
||||
@ -352,11 +354,11 @@ class WooCzlExpress {
|
||||
}
|
||||
}
|
||||
|
||||
add_settings_error('czl_messages', 'czl_message', __('汇率设置已保存', 'woo-czl-express'), 'updated');
|
||||
add_settings_error('czl_messages', 'czl_message', esc_html__('汇率设置已保存', 'czlexpress-for-woocommerce'), 'updated');
|
||||
}
|
||||
|
||||
// 显示设置页面
|
||||
require_once WOO_CZL_EXPRESS_PATH . 'admin/views/exchange-rates.php';
|
||||
require_once CZL_EXPRESS_PATH . 'admin/views/exchange-rates.php';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -371,23 +373,31 @@ class WooCzlExpress {
|
||||
}
|
||||
|
||||
register_post_status('wc-in_transit', array(
|
||||
'label' => _x('In Transit', 'Order status', 'woo-czl-express'),
|
||||
'label' => _x('In Transit', 'Order status', 'czlexpress-for-woocommerce'),
|
||||
'public' => true,
|
||||
'exclude_from_search' => false,
|
||||
'show_in_admin_all_list' => true,
|
||||
'show_in_admin_status_list' => true,
|
||||
'label_count' => _n_noop('In Transit <span class="count">(%s)</span>',
|
||||
'In Transit <span class="count">(%s)</span>', 'woo-czl-express')
|
||||
/* translators: %s: number of orders in transit */
|
||||
'label_count' => _n_noop(
|
||||
'In Transit <span class="count">(%s)</span>',
|
||||
'In Transit <span class="count">(%s)</span>',
|
||||
'czlexpress-for-woocommerce'
|
||||
)
|
||||
));
|
||||
|
||||
register_post_status('wc-delivered', array(
|
||||
'label' => _x('Delivered', 'Order status', 'woo-czl-express'),
|
||||
'label' => _x('Delivered', 'Order status', 'czlexpress-for-woocommerce'),
|
||||
'public' => true,
|
||||
'exclude_from_search' => false,
|
||||
'show_in_admin_all_list' => true,
|
||||
'show_in_admin_status_list' => true,
|
||||
'label_count' => _n_noop('Delivered <span class="count">(%s)</span>',
|
||||
'Delivered <span class="count">(%s)</span>', 'woo-czl-express')
|
||||
/* translators: %s: number of delivered orders */
|
||||
'label_count' => _n_noop(
|
||||
'Delivered <span class="count">(%s)</span>',
|
||||
'Delivered <span class="count">(%s)</span>',
|
||||
'czlexpress-for-woocommerce'
|
||||
)
|
||||
));
|
||||
|
||||
$registered = true;
|
||||
@ -405,8 +415,8 @@ class WooCzlExpress {
|
||||
}
|
||||
|
||||
$new_statuses = array(
|
||||
'wc-in_transit' => _x('In Transit', 'Order status', 'woo-czl-express'),
|
||||
'wc-delivered' => _x('Delivered', 'Order status', 'woo-czl-express')
|
||||
'wc-in_transit' => _x('In Transit', 'Order status', 'czlexpress-for-woocommerce'),
|
||||
'wc-delivered' => _x('Delivered', 'Order status', 'czlexpress-for-woocommerce')
|
||||
);
|
||||
|
||||
$order_statuses = array_merge($order_statuses, $new_statuses);
|
||||
@ -430,12 +440,12 @@ class WooCzlExpress {
|
||||
}
|
||||
|
||||
?>
|
||||
<h2><?php _e('物流轨迹', 'woo-czl-express'); ?></h2>
|
||||
<h2><?php esc_html_e('物流轨迹', 'czlexpress-for-woocommerce'); ?></h2>
|
||||
<div class="czl-tracking-info">
|
||||
<p>
|
||||
<?php
|
||||
printf(
|
||||
__('运单号: %s', 'woo-czl-express'),
|
||||
esc_html__('运单号: %s', 'czlexpress-for-woocommerce'),
|
||||
'<a href="https://exp.czl.net/track/?query=' . esc_attr($tracking_number) . '" target="_blank">' .
|
||||
esc_html($tracking_number) . '</a>'
|
||||
);
|
||||
@ -483,11 +493,11 @@ class WooCzlExpress {
|
||||
|
||||
?>
|
||||
<div class="czl-admin-tracking-info">
|
||||
<h3><?php _e('CZL Express 运单信息', 'woo-czl-express'); ?></h3>
|
||||
<h3><?php esc_html_e('CZL Express 运单信息', 'czlexpress-for-woocommerce'); ?></h3>
|
||||
<p>
|
||||
<?php
|
||||
printf(
|
||||
__('运单号: %s', 'woo-czl-express'),
|
||||
esc_html__('运单号: %s', 'czlexpress-for-woocommerce'),
|
||||
'<a href="https://exp.czl.net/track/?query=' . esc_attr($tracking_number) . '" target="_blank">' .
|
||||
esc_html($tracking_number) . '</a>'
|
||||
);
|
||||
@ -504,13 +514,13 @@ class WooCzlExpress {
|
||||
|
||||
// 检查权限
|
||||
if (!current_user_can('manage_woocommerce')) {
|
||||
throw new Exception(__('权限不足', 'woo-czl-express'));
|
||||
throw new Exception(esc_html__('权限不足', 'czlexpress-for-woocommerce'));
|
||||
}
|
||||
|
||||
// 验证订单ID
|
||||
$order_id = isset($_POST['order_id']) ? absint($_POST['order_id']) : 0;
|
||||
if (!$order_id) {
|
||||
throw new Exception(__('无效的订单ID', 'woo-czl-express'));
|
||||
throw new Exception(esc_html__('无效的订单ID', 'czlexpress-for-woocommerce'));
|
||||
}
|
||||
|
||||
// 获取WooCommerce订单对象
|
||||
@ -525,7 +535,7 @@ class WooCzlExpress {
|
||||
|
||||
if (!empty($result['tracking_number'])) {
|
||||
wp_send_json_success(array(
|
||||
'message' => __('运单创建成功', 'woo-czl-express'),
|
||||
'message' => esc_html__('运单创建成功', 'czlexpress-for-woocommerce'),
|
||||
'tracking_number' => $result['tracking_number']
|
||||
));
|
||||
} else {
|
||||
@ -537,14 +547,14 @@ class WooCzlExpress {
|
||||
if (isset($order)) {
|
||||
$order->add_order_note(
|
||||
sprintf(
|
||||
__('CZL Express运单创建失败: %s', 'woo-czl-express'),
|
||||
esc_html__('CZL Express运单创建失败: %s', 'czlexpress-for-woocommerce'),
|
||||
$e->getMessage()
|
||||
),
|
||||
true
|
||||
);
|
||||
}
|
||||
wp_send_json_error(array(
|
||||
'message' => $e->getMessage() // 直接返回错误信息
|
||||
'message' => $e->getMessage()
|
||||
));
|
||||
}
|
||||
}
|
||||
@ -558,13 +568,13 @@ class WooCzlExpress {
|
||||
check_ajax_referer('czl_bulk_create_shipment', 'nonce');
|
||||
|
||||
if (!current_user_can('manage_woocommerce')) {
|
||||
throw new Exception(__('权限不足', 'woo-czl-express'));
|
||||
throw new Exception(esc_html__('权限不足', 'czlexpress-for-woocommerce'));
|
||||
}
|
||||
|
||||
// 获取订单ID
|
||||
$order_ids = isset($_POST['order_ids']) ? array_map('intval', (array)$_POST['order_ids']) : array();
|
||||
if (empty($order_ids)) {
|
||||
throw new Exception(__('请选择订单', 'woo-czl-express'));
|
||||
throw new Exception(esc_html__('请选择订单', 'czlexpress-for-woocommerce'));
|
||||
}
|
||||
|
||||
$success = 0;
|
||||
@ -589,7 +599,7 @@ class WooCzlExpress {
|
||||
|
||||
wp_send_json_success(array(
|
||||
'message' => sprintf(
|
||||
__('处理完成。成功:%d,失败:%d', 'woo-czl-express'),
|
||||
esc_html__('处理完成。成功:%1$d,失败:%2$d', 'czlexpress-for-woocommerce'),
|
||||
$success,
|
||||
$failed
|
||||
),
|
||||
@ -609,11 +619,11 @@ class WooCzlExpress {
|
||||
public function render_orders_page() {
|
||||
// 检查权限
|
||||
if (!current_user_can('manage_woocommerce')) {
|
||||
wp_die(__('您没有足够的权限访问此页面', 'woo-czl-express'));
|
||||
wp_die(esc_html__('您没有足够的权限访问此页面', 'czlexpress-for-woocommerce'));
|
||||
}
|
||||
|
||||
// 加载订单列表页面模板
|
||||
require_once WOO_CZL_EXPRESS_PATH . 'admin/views/orders.php';
|
||||
require_once CZL_EXPRESS_PATH . 'admin/views/orders.php';
|
||||
}
|
||||
|
||||
/**
|
@ -1,27 +0,0 @@
|
||||
class WC_CZLExpress_Order {
|
||||
|
||||
public function save_tracking_info($order_id, $tracking_number, $label_url) {
|
||||
// 使用新的HPOS API保存跟踪信息
|
||||
$order = wc_get_order($order_id);
|
||||
|
||||
if ($order) {
|
||||
// 使用新的元数据API
|
||||
$order->update_meta_data('_czlexpress_tracking_number', $tracking_number);
|
||||
$order->update_meta_data('_czlexpress_label_url', $label_url);
|
||||
$order->save();
|
||||
}
|
||||
}
|
||||
|
||||
public function get_tracking_info($order_id) {
|
||||
$order = wc_get_order($order_id);
|
||||
|
||||
if ($order) {
|
||||
return array(
|
||||
'tracking_number' => $order->get_meta('_czlexpress_tracking_number'),
|
||||
'label_url' => $order->get_meta('_czlexpress_label_url')
|
||||
);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
class WC_CZLExpress_Orders_List {
|
||||
|
||||
public function get_orders($args = array()) {
|
||||
// 使用新的订单查询API
|
||||
$query = new \Automattic\WooCommerce\Internal\DataStores\Orders\OrdersTableQuery($args);
|
||||
return $query->get_orders();
|
||||
}
|
||||
|
||||
public function get_order_items($order_id) {
|
||||
$order = wc_get_order($order_id);
|
||||
return $order ? $order->get_items() : array();
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
class WC_CZLExpress_Shipping {
|
||||
|
||||
public function get_shipping_info($order_id) {
|
||||
$order = wc_get_order($order_id);
|
||||
|
||||
if ($order) {
|
||||
return array(
|
||||
'weight' => $order->get_meta('_czlexpress_weight'),
|
||||
'remote_fee' => $order->get_meta('_czlexpress_remote_fee'),
|
||||
'shipping_method' => $order->get_meta('_czlexpress_shipping_method')
|
||||
);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
120
languages/czlexpress-for-woocommerce.pot
Normal file
120
languages/czlexpress-for-woocommerce.pot
Normal file
@ -0,0 +1,120 @@
|
||||
# Copyright (C) 2024 CZL Express
|
||||
# This file is distributed under the GPL v2 or later.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: CZL Express for WooCommerce 1.0.0\n"
|
||||
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/czlexpress-for-woocommerce\n"
|
||||
"Last-Translator: woodchen <woodchen@czl.net>\n"
|
||||
"Language-Team: woodchen <woodchen@czl.net>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"POT-Creation-Date: 2024-12-20T10:00:00+00:00\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"X-Generator: WP-CLI 2.8.1\n"
|
||||
"X-Domain: czlexpress-for-woocommerce\n"
|
||||
|
||||
#. Plugin Name of the plugin
|
||||
msgid "CZL Express for WooCommerce"
|
||||
msgstr ""
|
||||
|
||||
#. Plugin URI of the plugin
|
||||
msgid "https://exp.czl.net"
|
||||
msgstr ""
|
||||
|
||||
#. Description of the plugin
|
||||
msgid "CZL Express shipping integration for WooCommerce. Provides real-time shipping rates, shipment creation, and package tracking for CZL Express delivery service."
|
||||
msgstr ""
|
||||
|
||||
#. Author of the plugin
|
||||
msgid "CZL Express"
|
||||
msgstr ""
|
||||
|
||||
#. Author URI of the plugin
|
||||
msgid "https://exp.czl.net"
|
||||
msgstr ""
|
||||
|
||||
#: czlexpress-for-woocommerce.php:89
|
||||
msgid "CZL Express requires WooCommerce to be installed and active"
|
||||
msgstr ""
|
||||
|
||||
#: czlexpress-for-woocommerce.php:99
|
||||
msgid "CZL Express requires WooCommerce 6.0.0 or higher"
|
||||
msgstr ""
|
||||
|
||||
#: includes/class-czlexpress.php:123
|
||||
msgid "Settings"
|
||||
msgstr ""
|
||||
|
||||
#: includes/class-czlexpress.php:124
|
||||
msgid "Documentation"
|
||||
msgstr ""
|
||||
|
||||
#: includes/class-czlexpress.php:125
|
||||
msgid "Support"
|
||||
msgstr ""
|
||||
|
||||
#: includes/class-czl-order.php:156
|
||||
msgid "Package created successfully"
|
||||
msgstr ""
|
||||
|
||||
#: includes/class-czl-order.php:158
|
||||
msgid "Failed to create package"
|
||||
msgstr ""
|
||||
|
||||
#: includes/class-czl-order.php:187
|
||||
msgid "Tracking information updated successfully"
|
||||
msgstr ""
|
||||
|
||||
#: includes/class-czl-order.php:189
|
||||
msgid "Failed to update tracking information"
|
||||
msgstr ""
|
||||
|
||||
#: includes/class-czl-order.php:234
|
||||
msgctxt "Order status"
|
||||
msgid "In Transit"
|
||||
msgstr ""
|
||||
|
||||
#: includes/class-czl-settings.php:45
|
||||
msgid "CZL Express API Settings"
|
||||
msgstr ""
|
||||
|
||||
#: includes/class-czl-settings.php:52
|
||||
msgid "Enable/Disable"
|
||||
msgstr ""
|
||||
|
||||
#: includes/class-czl-settings.php:54
|
||||
msgid "Enable this shipping method"
|
||||
msgstr ""
|
||||
|
||||
#: includes/class-czl-settings.php:58
|
||||
msgid "API Key"
|
||||
msgstr ""
|
||||
|
||||
#: includes/class-czl-settings.php:60
|
||||
msgid "Enter your CZL Express API key"
|
||||
msgstr ""
|
||||
|
||||
#: includes/class-czl-settings.php:64
|
||||
msgid "API Secret"
|
||||
msgstr ""
|
||||
|
||||
#: includes/class-czl-settings.php:66
|
||||
msgid "Enter your CZL Express API secret"
|
||||
msgstr ""
|
||||
|
||||
#: includes/class-czl-settings.php:70
|
||||
msgid "Test Mode"
|
||||
msgstr ""
|
||||
|
||||
#: includes/class-czl-settings.php:72
|
||||
msgid "Enable test mode"
|
||||
msgstr ""
|
||||
|
||||
#: includes/class-czl-settings.php:76
|
||||
msgid "Debug Log"
|
||||
msgstr ""
|
||||
|
||||
#: includes/class-czl-settings.php:78
|
||||
msgid "Enable logging"
|
||||
msgstr ""
|
@ -1,76 +0,0 @@
|
||||
# Copyright (C) 2024 CZL Express
|
||||
# This file is distributed under the GPL v2 or later.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: CZL Express for WooCommerce 1.0.0\n"
|
||||
"Report-Msgid-Bugs-To: https://exp.czl.net\n"
|
||||
"POT-Creation-Date: 2024-01-01 00:00:00+00:00\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"PO-Revision-Date: 2024-01-01 00:00:00+00:00\n"
|
||||
"Last-Translator: CZL Express\n"
|
||||
"Language-Team: CZL Express\n"
|
||||
"Language: zh_CN\n"
|
||||
"Plural-Forms: nplurals=1; plural=0;\n"
|
||||
|
||||
#: woocommerce-czlexpress.php:89
|
||||
msgid "CZL Express requires WooCommerce to be installed and active"
|
||||
msgstr "CZL Express 需要安装并激活 WooCommerce"
|
||||
|
||||
#: woocommerce-czlexpress.php:98
|
||||
msgid "CZL Express requires WooCommerce 6.0.0 or higher"
|
||||
msgstr "CZL Express 需要 WooCommerce 6.0.0 或更高版本"
|
||||
|
||||
#: woocommerce-czlexpress.php:142
|
||||
msgctxt "Order status"
|
||||
msgid "In Transit"
|
||||
msgstr "运输中"
|
||||
|
||||
#: woocommerce-czlexpress.php:187
|
||||
msgid "Creating shipment..."
|
||||
msgstr "正在创建运单..."
|
||||
|
||||
#: woocommerce-czlexpress.php:188
|
||||
msgid "Shipment created successfully"
|
||||
msgstr "运单创建成功"
|
||||
|
||||
#: woocommerce-czlexpress.php:189
|
||||
msgid "Failed to create shipment"
|
||||
msgstr "运单创建失败"
|
||||
|
||||
#: woocommerce-czlexpress.php:199
|
||||
msgid "Permission denied"
|
||||
msgstr "权限不足"
|
||||
|
||||
#: woocommerce-czlexpress.php:203
|
||||
msgid "Invalid order ID"
|
||||
msgstr "无效的订单ID"
|
||||
|
||||
#: woocommerce-czlexpress.php:247
|
||||
msgid "Invalid parameters"
|
||||
msgstr "无效的参数"
|
||||
|
||||
#: woocommerce-czlexpress.php:255
|
||||
msgid "Database update failed"
|
||||
msgstr "数据库更新失败"
|
||||
|
||||
#: woocommerce-czlexpress.php:268
|
||||
msgid "Tracking number updated to: %s"
|
||||
msgstr "跟踪单号已更新为:%s"
|
||||
|
||||
#: woocommerce-czlexpress.php:289
|
||||
msgid "Insufficient permissions"
|
||||
msgstr "权限不足"
|
||||
|
||||
#: woocommerce-czlexpress.php:293
|
||||
msgid "Invalid order ID"
|
||||
msgstr "无效的订单ID"
|
||||
|
||||
#: woocommerce-czlexpress.php:297
|
||||
msgid "Update scheduled"
|
||||
msgstr "更新已计划"
|
||||
|
||||
#: woocommerce-czlexpress.php:341
|
||||
msgid "Every 30 minutes"
|
||||
msgstr "每30分钟"
|
@ -1,74 +0,0 @@
|
||||
# Copyright (C) 2024 CZL Express
|
||||
# This file is distributed under the GPL v2 or later.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: CZL Express for WooCommerce 1.0.0\n"
|
||||
"Report-Msgid-Bugs-To: https://exp.czl.net\n"
|
||||
"POT-Creation-Date: 2024-01-01 00:00:00+00:00\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"PO-Revision-Date: 2024-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: CZL Express\n"
|
||||
"Language-Team: CZL Express\n"
|
||||
|
||||
#: woocommerce-czlexpress.php:89
|
||||
msgid "CZL Express requires WooCommerce to be installed and active"
|
||||
msgstr ""
|
||||
|
||||
#: woocommerce-czlexpress.php:98
|
||||
msgid "CZL Express requires WooCommerce 6.0.0 or higher"
|
||||
msgstr ""
|
||||
|
||||
#: woocommerce-czlexpress.php:142
|
||||
msgctxt "Order status"
|
||||
msgid "In Transit"
|
||||
msgstr ""
|
||||
|
||||
#: woocommerce-czlexpress.php:187
|
||||
msgid "Creating shipment..."
|
||||
msgstr ""
|
||||
|
||||
#: woocommerce-czlexpress.php:188
|
||||
msgid "Shipment created successfully"
|
||||
msgstr ""
|
||||
|
||||
#: woocommerce-czlexpress.php:189
|
||||
msgid "Failed to create shipment"
|
||||
msgstr ""
|
||||
|
||||
#: woocommerce-czlexpress.php:199
|
||||
msgid "Permission denied"
|
||||
msgstr ""
|
||||
|
||||
#: woocommerce-czlexpress.php:203
|
||||
msgid "Invalid order ID"
|
||||
msgstr ""
|
||||
|
||||
#: woocommerce-czlexpress.php:247
|
||||
msgid "Invalid parameters"
|
||||
msgstr ""
|
||||
|
||||
#: woocommerce-czlexpress.php:255
|
||||
msgid "Database update failed"
|
||||
msgstr ""
|
||||
|
||||
#: woocommerce-czlexpress.php:268
|
||||
msgid "Tracking number updated to: %s"
|
||||
msgstr ""
|
||||
|
||||
#: woocommerce-czlexpress.php:289
|
||||
msgid "Insufficient permissions"
|
||||
msgstr ""
|
||||
|
||||
#: woocommerce-czlexpress.php:293
|
||||
msgid "Invalid order ID"
|
||||
msgstr ""
|
||||
|
||||
#: woocommerce-czlexpress.php:297
|
||||
msgid "Update scheduled"
|
||||
msgstr ""
|
||||
|
||||
#: woocommerce-czlexpress.php:341
|
||||
msgid "Every 30 minutes"
|
||||
msgstr ""
|
@ -1,4 +1,6 @@
|
||||
# woocommerce-czlexpress
|
||||
# CZL Express for WooCommerce
|
||||
|
||||
CZL Express shipping integration for WooCommerce. Provides real-time shipping rates, shipment creation, and package tracking.
|
||||
|
||||
## 描述
|
||||
|
||||
|
114
readme.txt
114
readme.txt
@ -1,128 +1,62 @@
|
||||
=== CZL Express for WooCommerce ===
|
||||
Contributors: czlexpress
|
||||
Tags: woocommerce, shipping, czl express, tracking, delivery, shipping method, china shipping, international shipping
|
||||
Tags: woocommerce, shipping, tracking, czl express, delivery
|
||||
Requires at least: 5.8
|
||||
Tested up to: 6.4.2
|
||||
Requires PHP: 7.2
|
||||
Tested up to: 6.7
|
||||
Requires PHP: 8.0
|
||||
Stable tag: 1.0.0
|
||||
License: GPLv2 or later
|
||||
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
||||
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
|
||||
Integrate CZL Express shipping service with your WooCommerce store. Get real-time shipping rates, create shipments, and track packages.
|
||||
CZL Express shipping integration for WooCommerce. Provides real-time shipping rates, shipment creation, and package tracking.
|
||||
|
||||
== Description ==
|
||||
|
||||
CZL Express for WooCommerce provides seamless integration between your WooCommerce store and CZL Express shipping service. This plugin helps you automate your shipping process and provide better service to your customers.
|
||||
CZL Express for WooCommerce integrates CZL Express delivery services with your WooCommerce store. This plugin enables automatic shipping rate calculations, easy shipment creation, and real-time package tracking.
|
||||
|
||||
Features:
|
||||
|
||||
= Key Features =
|
||||
* Real-time shipping rates calculation
|
||||
* Automatic shipment creation
|
||||
* Package tracking integration
|
||||
* Custom product grouping for shipping rates
|
||||
* Support for multiple currencies (CNY to other currencies)
|
||||
* Automatic order status updates
|
||||
* Customer-facing tracking information
|
||||
* Full HPOS (High-Performance Order Storage) support
|
||||
* WooCommerce remote logging support
|
||||
* Multi-language support
|
||||
|
||||
= Advanced Features =
|
||||
* Custom product grouping for different shipping methods
|
||||
* Flexible pricing rules with markup support (e.g., "10% + 10")
|
||||
* Quick order creation in CZL Express system
|
||||
* Label printing support
|
||||
* Automatic tracking number synchronization (every 30 minutes)
|
||||
* Automatic tracking information updates (hourly)
|
||||
* Customer-visible shipping updates
|
||||
|
||||
= Requirements =
|
||||
* WordPress 6.0 or higher
|
||||
* WooCommerce 6.0.0 or higher
|
||||
* PHP 7.4 or higher
|
||||
* MySQL 5.6 or higher
|
||||
* CZL Express account and API credentials
|
||||
* Order status synchronization
|
||||
* Bulk shipment processing
|
||||
* Customizable shipping options
|
||||
|
||||
== Installation ==
|
||||
|
||||
1. Upload the plugin files to the `/wp-content/plugins/woocommerce-czlexpress` directory, or install the plugin through the WordPress plugins screen directly.
|
||||
2. Activate the plugin through the 'Plugins' screen in WordPress.
|
||||
3. Go to the plugin's settings page and configure your CZL Express API credentials and exchange rate.
|
||||
4. In WooCommerce > Settings > Shipping, configure your shipping zones:
|
||||
* Create a new zone
|
||||
* Select the desired regions
|
||||
* Add "CZL Express" as a shipping method
|
||||
* Configure the shipping method settings
|
||||
5. Go to "CZL Express" > "Product Groups" to set up your product groups:
|
||||
* Remove default groups if needed
|
||||
* Add custom groups (e.g., "SF Line", "SF Small Packet")
|
||||
6. The shipping rates will automatically calculate when customers enter their address.
|
||||
1. Upload the plugin files to the `/wp-content/plugins/czlexpress-for-woocommerce` directory, or install the plugin through the WordPress plugins screen directly.
|
||||
2. Activate the plugin through the 'Plugins' screen in WordPress
|
||||
3. Use the WooCommerce->Settings->Shipping->CZL Express screen to configure the plugin
|
||||
4. Enter your CZL Express API credentials in the settings
|
||||
|
||||
== Frequently Asked Questions ==
|
||||
|
||||
= Do I need a CZL Express account? =
|
||||
|
||||
Yes, you need a CZL Express account and API credentials to use this plugin. Visit [https://exp.czl.net](https://exp.czl.net) to create an account.
|
||||
Yes, you need a CZL Express account and API credentials to use this plugin.
|
||||
|
||||
= How do I get API credentials? =
|
||||
|
||||
Contact CZL Express support to obtain your API credentials.
|
||||
Contact CZL Express customer service to obtain your API credentials.
|
||||
|
||||
= Can I test the plugin before going live? =
|
||||
= Is this plugin compatible with the latest WooCommerce version? =
|
||||
|
||||
Yes, the plugin includes a test mode that allows you to test the integration without creating real shipments.
|
||||
|
||||
= How are shipping rates calculated? =
|
||||
|
||||
Shipping rates are calculated in real-time based on:
|
||||
* Package weight and dimensions
|
||||
* Destination address
|
||||
* Selected shipping method
|
||||
* Product grouping settings
|
||||
|
||||
= Can I add a markup to shipping rates? =
|
||||
|
||||
Yes, you can add both percentage and fixed amount markups. For example:
|
||||
* "10%" - Add 10% to the base rate
|
||||
* "+ 10" - Add 10 to the base rate
|
||||
* "10% + 10" - Add 10% plus 10 to the base rate
|
||||
|
||||
= How often is tracking information updated? =
|
||||
|
||||
* Tracking numbers are synced every 30 minutes
|
||||
* Tracking details are updated hourly
|
||||
* Manual updates are also available
|
||||
|
||||
= Does it support multiple currencies? =
|
||||
|
||||
Yes, rates are fetched in CNY and automatically converted to your store's currency using the configured exchange rate.
|
||||
Yes, this plugin is regularly tested and updated to maintain compatibility with the latest WooCommerce version.
|
||||
|
||||
== Screenshots ==
|
||||
|
||||
1. Plugin settings page - Configure API credentials and general settings
|
||||
2. Shipping method configuration - Set up shipping zones and methods
|
||||
3. Product group management - Create and manage product groups
|
||||
4. Order with tracking information - View tracking details in orders
|
||||
5. Shipping rate display - How customers see shipping options
|
||||
6. Order management - Create shipments and print labels
|
||||
7. Tracking information - Customer-facing tracking updates
|
||||
1. Plugin settings page
|
||||
2. Shipping rate configuration
|
||||
3. Order management interface
|
||||
4. Tracking information display
|
||||
|
||||
== Changelog ==
|
||||
|
||||
= 1.0.0 =
|
||||
* Initial release
|
||||
* Full WooCommerce HPOS support
|
||||
* Real-time shipping rates
|
||||
* Automatic shipment creation
|
||||
* Package tracking integration
|
||||
* Product grouping support
|
||||
* Multi-currency support
|
||||
* Automatic tracking updates
|
||||
|
||||
== Upgrade Notice ==
|
||||
|
||||
= 1.0.0 =
|
||||
Initial release of CZL Express for WooCommerce.
|
||||
|
||||
== Support ==
|
||||
|
||||
For support, please visit [https://exp.czl.net](https://exp.czl.net) or contact our support team.
|
||||
Initial release of CZL Express for WooCommerce plugin.
|
@ -8,14 +8,14 @@ defined('ABSPATH') || exit;
|
||||
<tr class="shipping-method-group">
|
||||
<td>
|
||||
<input type="radio"
|
||||
name="shipping_method[<?php echo $index; ?>]"
|
||||
data-index="<?php echo $index; ?>"
|
||||
name="shipping_method[<?php echo esc_attr($index); ?>]"
|
||||
data-index="<?php echo esc_attr($index); ?>"
|
||||
value="<?php echo esc_attr($rate->id); ?>"
|
||||
class="shipping_method"
|
||||
<?php checked($rate->id, $chosen_method); ?> />
|
||||
</td>
|
||||
<td>
|
||||
<label for="shipping_method_<?php echo $index; ?>">
|
||||
<label for="shipping_method_<?php echo esc_attr($index); ?>">
|
||||
<?php echo wp_kses_post($rate->label); ?>
|
||||
<?php if (!empty($rate->has_sub_methods)): ?>
|
||||
<span class="toggle-sub-methods dashicons dashicons-arrow-down-alt2"></span>
|
||||
@ -24,8 +24,13 @@ defined('ABSPATH') || exit;
|
||||
|
||||
<?php if ($rate->remote_fee > 0): ?>
|
||||
<div class="remote-fee-notice">
|
||||
<?php printf(__('Remote Area Fee: %s', 'woo-czl-express'),
|
||||
wc_price($rate->remote_fee)); ?>
|
||||
<?php
|
||||
/* translators: %s: Remote area fee amount */
|
||||
printf(
|
||||
esc_html__('Remote Area Fee: %s', 'czlexpress-for-woocommerce'),
|
||||
wp_kses_post(wc_price($rate->remote_fee))
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
@ -34,9 +39,9 @@ defined('ABSPATH') || exit;
|
||||
<table class="sub-methods-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php _e('Method', 'woo-czl-express'); ?></th>
|
||||
<th><?php _e('Delivery Time', 'woo-czl-express'); ?></th>
|
||||
<th><?php _e('Cost', 'woo-czl-express'); ?></th>
|
||||
<th><?php esc_html_e('Method', 'czlexpress-for-woocommerce'); ?></th>
|
||||
<th><?php esc_html_e('Delivery Time', 'czlexpress-for-woocommerce'); ?></th>
|
||||
<th><?php esc_html_e('Cost', 'czlexpress-for-woocommerce'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -44,7 +49,7 @@ defined('ABSPATH') || exit;
|
||||
<tr>
|
||||
<td><?php echo esc_html($sub_method['method_title']); ?></td>
|
||||
<td><?php echo esc_html($sub_method['delivery_time']); ?></td>
|
||||
<td><?php echo wc_price($sub_method['cost']); ?></td>
|
||||
<td><?php echo wp_kses_post(wc_price($sub_method['cost'])); ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
@ -52,5 +57,5 @@ defined('ABSPATH') || exit;
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td><?php echo wc_price($rate->cost); ?></td>
|
||||
<td><?php echo wp_kses_post(wc_price($rate->cost)); ?></td>
|
||||
</tr>
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user