产品评论 API
列出产品评论
此端点返回产品评论(评论),也可以显示来自特定产品或特定分类的结果。
GET /products/reviews
GET /products/reviews?category_id=1,2,3
GET /products/reviews?product_id=1,2,3
GET /products/reviews?orderby=rating&order=desc
| 属性 | 类型 | 是否必需 | 描述 |
|---|---|---|---|
page | integer | 否 | 集合的当前页。 |
per_page | integer | 否 | 结果集中要返回的最大项目数。 |
offset | integer | 否 | 将结果集偏移特定数量的项目。 |
order | string | 否 | 排序属性升序或降序。允许的值:asc, desc |
orderby | string | 否 | 按对象属性对集合进行排序。允许的值:date, date_gmt, id, rating, product |
category_id | string | 否 | 将结果集限制为来自特定分类 ID 的评论。 |
product_id | string | 否 | 将结果集限制为来自特定产品 ID 的评论。 |
curl "https://example-store.com/wp-json/wc/store/v1/products/collection-data?calculate_price_range=true&calculate_attribute_counts=pa_size,pa_color&calculate_rating_counts=true"
示例响应:
[
{
"id": 83,
"date_created": "2022-01-12T15:42:14",
"formatted_date_created": "January 12, 2022",
"date_created_gmt": "2022-01-12T15:42:14",
"product_id": 33,
"product_name": "Beanie with Logo",
"product_permalink": "https://store.local/product/beanie-with-logo/",
"product_image": {
"id": 56,
"src": "https://store.local/wp-content/uploads/2021/11/beanie-with-logo-1.jpg",
"thumbnail": "https://store.local/wp-content/uploads/2021/11/beanie-with-logo-1-324x324.jpg",
"srcset": "https://store.local/wp-content/uploads/2021/11/beanie-with-logo-1.jpg 800w, https://store.local/wp-content/uploads/2021/11/beanie-with-logo-1-324x324.jpg 324w, https://store.local/wp-content/uploads/2021/11/beanie-with-logo-1-100x100.jpg 100w, https://store.local/wp-content/uploads/2021/11/beanie-with-logo-1-416x416.jpg 416w, https://store.local/wp-content/uploads/2021/11/beanie-with-logo-1-300x300.jpg 300w, https://store.local/wp-content/uploads/2021/11/beanie-with-logo-1-150x150.jpg 150w, https://store.local/wp-content/uploads/2021/11/beanie-with-logo-1-768x768.jpg 768w",
"sizes": "(max-width: 800px) 100vw, 800px",
"name": "beanie-with-logo-1.jpg",
"alt": ""
},
"reviewer": "reviewer-name",
"review": "<p>This is a fantastic product.</p>\n",
"rating": 5,
"verified": true,
"reviewer_avatar_urls": {
"24": "https://secure.gravatar.com/avatar/12345?s=24&d=mm&r=g",
"48": "https://secure.gravatar.com/avatar/12345?s=48&d=mm&r=g",
"96": "https://secure.gravatar.com/avatar/12345?s=96&d=mm&r=g"
}
}
]