将当前页面内容以 Markdown 格式复制到剪贴板
配送区域位置
配送区域位置 API 允许您查看和批量更新配送区域的位置。
配送位置属性
| 属性 | 类型 | 描述 |
|---|---|---|
code | 字符串 | 配送区域位置代码。 |
type | 字符串 | 配送区域位置类型。选项:postcode, state, country 和 continent。默认为 country。 |
查看所有配送区域的位置
此 API 可帮助您查看所有配送区域的位置。
GET /wp-json/wc/v3/shipping/zones/<id>/locations
- cURL
- JavaScript
- PHP
- Python
- Ruby
- JSON Response
curl https://example.com/wp-json/wc/v3/shipping/zones/5/locations \
-u consumer_key:consumer_secret
WooCommerce.get( 'shipping/zones/5/locations' )
.then( ( response ) => {
console.log( response.data );
} )
.catch( ( error ) => {
console.log( error.response.data );
} );
<?php print_r($woocommerce->get('shipping/zones/5/locations')); ?>
print(wcapi.get("shipping/zones/5/locations").json())
woocommerce.get("shipping/zones/5/locations").parsed_response
[
{
"code": "BR",
"type": "country",
"_links": {
"collection": [
{
"href": "https://example.com/wp-json/wc/v3/shipping/zones/5/locations"
}
],
"describes": [
{
"href": "https://example.com/wp-json/wc/v3/shipping/zones/5"
}
]
}
}
]
更新配送区域的位置
此 API 允许您更改配送区域的位置。
PUT /wp-json/wc/v3/shipping/zones/<id>/locations
- cURL
- JavaScript
- PHP
- Python
- Ruby
- JSON Response
curl -X PUT https://example.com/wp-json/wc/v3/shipping/zones/5/locations \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '[
{
"code": "BR:SP",
"type": "state"
},
{
"code": "BR:RJ",
"type": "state"
}
]'
var data = [
{
code: 'BR:SP',
type: 'state',
},
{
code: 'BR:RJ',
type: 'state',
},
];
WooCommerce.put( 'shipping/zones/5/locations', data )
.then( ( response ) => {
console.log( response.data );
} )
.catch( ( error ) => {
console.log( error.response.data );
} );
<?php
$data = [
[
'code' => 'BR:SP',
'type' => 'state'
],
[
'code' => 'BR:RJ',
'type' => 'state'
]
];
print_r($woocommerce->put('shipping/zones/5/locations', $data));
?>
data = [
{
"code": "BR:SP",
"type": "state"
},
{
"code": "BR:RJ",
"type": "state"
}
]
print(wcapi.put("shipping/zones/5/locations", data).json())
data = [
{
code: "BR:SP",
type: "state"
},
{
code: "BR:RJ",
type: "state"
}
]
woocommerce.put("shipping/zones/5/locations", data).parsed_response
[
{
"code": "BR:SP",
"type": "state",
"_links": {
"collection": [
{
"href": "https://example.com/wp-json/wc/v3/shipping/zones/5/locations"
}
],
"describes": [
{
"href": "https://example.com/wp-json/wc/v3/shipping/zones/5"
}
]
}
},
{
"code": "BR:RJ",
"type": "state",
"_links": {
"collection": [
{
"href": "https://example.com/wp-json/wc/v3/shipping/zones/5/locations"
}
],
"describes": [
{
"href": "https://example.com/wp-json/wc/v3/shipping/zones/5"
}
]
}
}
]