将当前页面内容以 Markdown 格式复制到剪贴板
配送方式
配送方式 API 允许您查看单个配送方式。
配送方式属性
| 属性 | 类型 | 描述 |
|---|---|---|
id | 字符串 | 方法 ID。只读 |
title | 字符串 | 配送方式标题。只读 |
description | 字符串 | 配送方式描述。只读 |
获取一个配送方式
此 API 允许您获取和查看特定的配送方式。
GET /wp-json/wc/v3/shipping_methods/<id>
- cURL
- JavaScript
- PHP
- Python
- Ruby
- JSON Response
curl https://example.com/wp-json/wc/v3/shipping_methods/flat_rate \
-u consumer_key:consumer_secret
WooCommerce.get( 'shipping_methods/flat_rate' )
.then( ( response ) => {
console.log( response.data );
} )
.catch( ( error ) => {
console.log( error.response.data );
} );
<?php print_r($woocommerce->get('shipping_methods/flat_rate')); ?>
print(wcapi.get("shipping_methods/flat_rate").json())
woocommerce.get("shipping_methods/flat_rate").parsed_response
{
"id": "flat_rate",
"title": "Flat rate",
"description": "Lets you charge a fixed rate for shipping.",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v3/shipping_methods/flat_rate"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v3/shipping_methods"
}
]
}
}
列出所有配送方式
此 API 帮助您查看所有配送方式。
GET /wp-json/wc/v3/shipping_methods
- cURL
- JavaScript
- PHP
- Python
- Ruby
- JSON Response
curl https://example.com/wp-json/wc/v3/shipping_methods \
-u consumer_key:consumer_secret
WooCommerce.get( 'shipping_methods' )
.then( ( response ) => {
console.log( response.data );
} )
.catch( ( error ) => {
console.log( error.response.data );
} );
<?php print_r($woocommerce->get('shipping_methods')); ?>
print(wcapi.get("shipping_methods").json())
woocommerce.get("shipping_methods").parsed_response
[
{
"id": "flat_rate",
"title": "Flat rate",
"description": "Lets you charge a fixed rate for shipping.",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v3/shipping_methods/flat_rate"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v3/shipping_methods"
}
]
}
},
{
"id": "free_shipping",
"title": "Free shipping",
"description": "Free shipping is a special method which can be triggered with coupons and minimum spends.",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v3/shipping_methods/free_shipping"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v3/shipping_methods"
}
]
}
},
{
"id": "local_pickup",
"title": "Local pickup",
"description": "Allow customers to pick up orders themselves. By default, when using local pickup store base taxes will apply regardless of customer address.",
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v3/shipping_methods/local_pickup"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v3/shipping_methods"
}
]
}
}
]