将当前页面内容以 Markdown 格式复制到剪贴板
订单备注
订单备注 API 允许您创建、查看和删除单个订单备注。 订单备注由管理员以及通过程序方式添加,用于存储关于订单或订单事件的数据。
订单备注属性
| 属性 | 类型 | 描述 |
|---|---|---|
id | integer | 该资源的唯一标识符。只读 |
author | string | 订单备注作者。只读 |
date_created | date-time | 创建订单备注的日期,采用站点的时区。只读 |
date_created_gmt | date-time | 创建订单备注的日期,以 GMT 格式表示。只读 |
note | string | 订单备注内容。必填 |
customer_note | boolean | 如果为 true,则该备注将显示给客户,并会通知他们。如果为 false,则该备注仅供管理员参考。默认为 false。 |
added_by_user | boolean | 如果为 true,则此备注将归属于当前用户。如果为 false,则该备注将归属于系统。默认为 false。 |
创建订单备注
此 API 帮助您为订单创建新的备注。
POST /wp-json/wc/v3/orders/<id>/notes
- cURL
- JavaScript
- PHP
- Python
- Ruby
- JSON Response
curl -X POST https://example.com/wp-json/wc/v3/orders/723/notes \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"note": "Order ok!!!"
}'
const data = {
note: 'Order ok!!!',
};
WooCommerce.post( 'orders/723/notes', data )
.then( ( response ) => {
console.log( response.data );
} )
.catch( ( error ) => {
console.log( error.response.data );
} );
<?php
$data = [
'note' => 'Order ok!!!'
];
print_r($woocommerce->post('orders/723/notes', $data));
?>
data = {
"note": "Order ok!!!"
}
print(wcapi.post("orders/723/notes", data).json())
data = {
note: "Order ok!!!"
}
woocommerce.post("orders/723/notes", data).parsed_response
{
"id": 281,
"author": "system",
"date_created": "2017-03-21T16:46:41",
"date_created_gmt": "2017-03-21T19:46:41",
"note": "Order ok!!!",
"customer_note": false,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v3/orders/723/notes/281"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v3/orders/723/notes"
}
],
"up": [
{
"href": "https://example.com/wp-json/wc/v3/orders/723"
}
]
}
}
获取订单备注
此 API 允许您检索并查看特定订单的备注。
GET /wp-json/wc/v3/orders/<id>/notes/<note_id>
- cURL
- JavaScript
- PHP
- Python
- Ruby
- JSON Response
curl https://example.com/wp-json/wc/v3/orders/723/notes/281 \
-u consumer_key:consumer_secret
WooCommerce.get( 'orders/723/notes/281' )
.then( ( response ) => {
console.log( response.data );
} )
.catch( ( error ) => {
console.log( error.response.data );
} );
<?php print_r($woocommerce->get('orders/723/notes/281')); ?>
print(wcapi.get("orders/723/notes/281").json())
woocommerce.get("orders/723/notes/281").parsed_response
{
"id": 281,
"author": "system",
"date_created": "2017-03-21T16:46:41",
"date_created_gmt": "2017-03-21T19:46:41",
"note": "Order ok!!!",
"customer_note": false,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v3/orders/723/notes/281"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v3/orders/723/notes"
}
],
"up": [
{
"href": "https://example.com/wp-json/wc/v3/orders/723"
}
]
}
}
查看所有订单备注
这个 API 可以帮助您查看某个订单的所有备注。
GET /wp-json/wc/v3/orders/<id>/notes
- cURL
- JavaScript
- PHP
- Python
- Ruby
- JSON Response
curl https://example.com/wp-json/wc/v3/orders/723/notes \
-u consumer_key:consumer_secret
WooCommerce.get( 'orders/723/notes' )
.then( ( response ) => {
console.log( response.data );
} )
.catch( ( error ) => {
console.log( error.response.data );
} );
<?php print_r($woocommerce->get('orders/723/notes')); ?>
print(wcapi.get("orders/723/notes").json())
woocommerce.get("orders/723/notes").parsed_response
[
{
"id": 281,
"author": "system",
"date_created": "2017-03-21T16:46:41",
"date_created_gmt": "2017-03-21T19:46:41",
"note": "Order ok!!!",
"customer_note": false,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v3/orders/723/notes/281"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v3/orders/723/notes"
}
],
"up": [
{
"href": "https://example.com/wp-json/wc/v3/orders/723"
}
]
}
},
{
"id": 280,
"author": "system",
"date_created": "2017-03-21T16:16:58",
"date_created_gmt": "2017-03-21T19:16:58",
"note": "Order status changed from On hold to Completed.",
"customer_note": false,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v3/orders/723/notes/280"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v3/orders/723/notes"
}
],
"up": [
{
"href": "https://example.com/wp-json/wc/v3/orders/723"
}
]
}
},
{
"id": 279,
"author": "system",
"date_created": "2017-03-21T16:16:46",
"date_created_gmt": "2017-03-21T19:16:46",
"note": "Awaiting BACS payment Order status changed from Pending payment to On hold.",
"customer_note": false,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v3/orders/723/notes/279"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v3/orders/723/notes"
}
],
"up": [
{
"href": "https://example.com/wp-json/wc/v3/orders/723"
}
]
}
}
]
可用参数
| 参数 | 类型 | 描述 |
|---|---|---|
context | 字符串 | 发送请求的上下文;决定响应中包含的字段。选项:view 和 edit。默认值为 view。 |
type | 字符串 | 将结果限制为客户或内部备注。选项:any、customer 和 internal。默认值为 any。 |
删除一个订单备注
这个 API 可以帮助您删除一个订单备注。
DELETE /wp-json/wc/v3/orders/<id>/notes/<note_id>
- cURL
- JavaScript
- PHP
- Python
- Ruby
- JSON Response
curl -X DELETE https://example.com/wp-json/wc/v3/orders/723/notes/281?force=true \
-u consumer_key:consumer_secret
WooCommerce.delete( 'orders/723/notes/281', {
force: true,
} )
.then( ( response ) => {
console.log( response.data );
} )
.catch( ( error ) => {
console.log( error.response.data );
} );
<?php print_r($woocommerce->delete('orders/723/notes/281', ['force' => true])); ?>
print(wcapi.delete("orders/723/notes/281", params={"force": True}).json())
woocommerce.delete("orders/723/notes/281", force: true).parsed_response
{
"id": 281,
"author": "system",
"date_created": "2017-03-21T16:46:41",
"date_created_gmt": "2017-03-21T19:46:41",
"note": "Order ok!!!",
"customer_note": false,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v3/orders/723/notes/281"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v3/orders/723/notes"
}
],
"up": [
{
"href": "https://example.com/wp-json/wc/v3/orders/723"
}
]
}
}
Available parameters
| Parameter | Type | Description |
|---|---|---|
force | string | Required to be true, as resource does not support trashing. |