mirror of
https://github.com/woodchen-ink/czlexpress-for-woocommerce.git
synced 2025-07-18 14:01:58 +08:00
- 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.
67 lines
1.8 KiB
PHP
67 lines
1.8 KiB
PHP
<?php
|
|
class CZL_API_Test {
|
|
private $api;
|
|
|
|
public function __construct() {
|
|
$this->api = new CZL_API();
|
|
}
|
|
|
|
/**
|
|
* 测试API连接
|
|
*/
|
|
public function test_connection() {
|
|
try {
|
|
// 尝试获取token
|
|
$this->api->get_token();
|
|
return array(
|
|
'success' => true,
|
|
'message' => __('Successfully connected to CZL Express API', 'czlexpress-for-woocommerce')
|
|
);
|
|
} catch (Exception $e) {
|
|
return array(
|
|
'success' => false,
|
|
'message' => $e->getMessage()
|
|
);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 测试运费查询
|
|
*/
|
|
public function test_shipping_rate() {
|
|
$test_package = array(
|
|
'destination' => array(
|
|
'country' => 'US',
|
|
'state' => 'CA',
|
|
'city' => 'Los Angeles',
|
|
'address' => '123 Test St',
|
|
'postcode' => '90001'
|
|
),
|
|
'contents' => array(
|
|
array(
|
|
'data' => new WC_Product_Simple(array(
|
|
'weight' => 1,
|
|
'length' => 10,
|
|
'width' => 10,
|
|
'height' => 10,
|
|
'price' => 100
|
|
)),
|
|
'quantity' => 1
|
|
)
|
|
)
|
|
);
|
|
|
|
try {
|
|
$rates = $this->api->get_shipping_rate($test_package);
|
|
return array(
|
|
'success' => true,
|
|
'data' => $rates
|
|
);
|
|
} catch (Exception $e) {
|
|
return array(
|
|
'success' => false,
|
|
'message' => $e->getMessage()
|
|
);
|
|
}
|
|
}
|
|
}
|