Skip to content

Commit 51646e0

Browse files
Updated the categories examples for the new image data format
1 parent 8c31272 commit 51646e0

File tree

1 file changed

+98
-37
lines changed

1 file changed

+98
-37
lines changed

source/includes/wp-api-v1/_product-categories.md

Lines changed: 98 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,21 @@ The product categories API allows you to create, view, update, and delete indivi
1212
| `parent` | integer | The id for the parent of the resource. |
1313
| `description` | string | HTML description of the resource. |
1414
| `display` | string | Category archive display type. Default is `default`. Options: `default`, `products`, `subcategories` and `both` |
15-
| `image` | string | Image URL. |
15+
| `image` | array | Image data. See [Category Image properties](#category-image-properties) |
1616
| `menu_order` | integer | Menu order, used to custom sort the resource. |
1717
| `count` | integer | Number of published products for the resource. <i class="label label-info">read-only</i> |
1818

19+
### Category Image properties ###
20+
21+
| Attribute | Type | Description |
22+
|-----------------|-----------|---------------------------------------------------------------------------------------------------------|
23+
| `id` | integer | Image ID (attachment ID). In write-mode used to attach pre-existing images. |
24+
| `date_created` | date-time | The date the image was created, in the site's timezone. <i class="label label-info">read-only</i> |
25+
| `date_modified` | date-time | The date the image was last modified, in the site's timezone. <i class="label label-info">read-only</i> |
26+
| `src` | string | Image URL. In write-mode used to upload new images. |
27+
| `name` | string | Image name. |
28+
| `alt` | string | Image alternative text. |
29+
1930
## Create a product category ##
2031

2132
This API helps you to create a new product category.
@@ -36,13 +47,19 @@ curl -X POST https://example.com/wp-json/wc/v1/products/categories \
3647
-u consumer_key:consumer_secret \
3748
-H "Content-Type: application/json" \
3849
-d '{
39-
"name": "Clothing"
50+
"name": "Clothing",
51+
"image": {
52+
"src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg"
53+
}
4054
}'
4155
```
4256

4357
```javascript
4458
var data = {
45-
name: 'Clothing'
59+
name: 'Clothing',
60+
image: {
61+
src: 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg'
62+
}
4663
};
4764

4865
WooCommerce.post('products/categories', data, function(err, data, res) {
@@ -53,7 +70,10 @@ WooCommerce.post('products/categories', data, function(err, data, res) {
5370
```php
5471
<?php
5572
$data = [
56-
'name' => 'Clothing'
73+
'name' => 'Clothing',
74+
'image' => [
75+
'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg'
76+
]
5777
];
5878

5979
print_r($woocommerce->post('products/categories', $data));
@@ -62,15 +82,21 @@ print_r($woocommerce->post('products/categories', $data));
6282

6383
```python
6484
data = {
65-
"name": "Clothing"
85+
"name": "Clothing",
86+
"image": {
87+
"src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg"
88+
}
6689
}
6790

6891
print(wcapi.post("products/categories", data).json())
6992
```
7093

7194
```ruby
7295
data = {
73-
name: "Clothing"
96+
name: "Clothing",
97+
image: {
98+
src: "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg"
99+
}
74100
}
75101

76102
woocommerce.post("products/categories", data).parsed_response
@@ -86,18 +112,25 @@ woocommerce.post("products/categories", data).parsed_response
86112
"parent": 0,
87113
"description": "",
88114
"display": "default",
89-
"image": "",
115+
"image": {
116+
"id": 173,
117+
"date_created": "2016-05-31T23:51:03",
118+
"date_modified": "2016-05-31T23:51:03",
119+
"src": "https://example/wp-content/uploads/2016/05/T_3_front-1.jpg",
120+
"title": "",
121+
"alt": ""
122+
},
90123
"menu_order": 0,
91-
"count": 12,
124+
"count": 18,
92125
"_links": {
93126
"self": [
94127
{
95-
"href": "https://example.com/wp-json/wc/v1/products/categories/9"
128+
"href": "https://example/wp-json/wc/v1/products/categories/9"
96129
}
97130
],
98131
"collection": [
99132
{
100-
"href": "https://example.com/wp-json/wc/v1/products/categories"
133+
"href": "https://example/wp-json/wc/v1/products/categories"
101134
}
102135
]
103136
}
@@ -148,18 +181,25 @@ woocommerce.get("products/categories/9").parsed_response
148181
"parent": 0,
149182
"description": "",
150183
"display": "default",
151-
"image": "",
184+
"image": {
185+
"id": 173,
186+
"date_created": "2016-05-31T23:51:03",
187+
"date_modified": "2016-05-31T23:51:03",
188+
"src": "https://example/wp-content/uploads/2016/05/T_3_front-1.jpg",
189+
"title": "",
190+
"alt": ""
191+
},
152192
"menu_order": 0,
153-
"count": 12,
193+
"count": 18,
154194
"_links": {
155195
"self": [
156196
{
157-
"href": "https://example.com/wp-json/wc/v1/products/categories/9"
197+
"href": "https://example/wp-json/wc/v1/products/categories/9"
158198
}
159199
],
160200
"collection": [
161201
{
162-
"href": "https://example.com/wp-json/wc/v1/products/categories"
202+
"href": "https://example/wp-json/wc/v1/products/categories"
163203
}
164204
]
165205
}
@@ -211,7 +251,7 @@ woocommerce.get("products/categories").parsed_response
211251
"parent": 11,
212252
"description": "",
213253
"display": "default",
214-
"image": "",
254+
"image": [],
215255
"menu_order": 0,
216256
"count": 4,
217257
"_links": {
@@ -239,18 +279,25 @@ woocommerce.get("products/categories").parsed_response
239279
"parent": 0,
240280
"description": "",
241281
"display": "default",
242-
"image": "",
282+
"image": {
283+
"id": 173,
284+
"date_created": "2016-05-31T23:51:03",
285+
"date_modified": "2016-05-31T23:51:03",
286+
"src": "https://example/wp-content/uploads/2016/05/T_3_front-1.jpg",
287+
"title": "",
288+
"alt": ""
289+
},
243290
"menu_order": 0,
244-
"count": 12,
291+
"count": 18,
245292
"_links": {
246293
"self": [
247294
{
248-
"href": "https://example.com/wp-json/wc/v1/products/categories/9"
295+
"href": "https://example/wp-json/wc/v1/products/categories/9"
249296
}
250297
],
251298
"collection": [
252299
{
253-
"href": "https://example.com/wp-json/wc/v1/products/categories"
300+
"href": "https://example/wp-json/wc/v1/products/categories"
254301
}
255302
]
256303
}
@@ -262,7 +309,7 @@ woocommerce.get("products/categories").parsed_response
262309
"parent": 9,
263310
"description": "",
264311
"display": "default",
265-
"image": "",
312+
"image": [],
266313
"menu_order": 0,
267314
"count": 6,
268315
"_links": {
@@ -290,7 +337,7 @@ woocommerce.get("products/categories").parsed_response
290337
"parent": 0,
291338
"description": "",
292339
"display": "default",
293-
"image": "",
340+
"image": [],
294341
"menu_order": 0,
295342
"count": 7,
296343
"_links": {
@@ -313,7 +360,7 @@ woocommerce.get("products/categories").parsed_response
313360
"parent": 0,
314361
"description": "",
315362
"display": "default",
316-
"image": "",
363+
"image": [],
317364
"menu_order": 0,
318365
"count": 5,
319366
"_links": {
@@ -336,7 +383,7 @@ woocommerce.get("products/categories").parsed_response
336383
"parent": 11,
337384
"description": "",
338385
"display": "default",
339-
"image": "",
386+
"image": [],
340387
"menu_order": 0,
341388
"count": 3,
342389
"_links": {
@@ -364,7 +411,7 @@ woocommerce.get("products/categories").parsed_response
364411
"parent": 9,
365412
"description": "",
366413
"display": "default",
367-
"image": "",
414+
"image": [],
368415
"menu_order": 0,
369416
"count": 6,
370417
"_links": {
@@ -483,18 +530,25 @@ woocommerce.put("products/categories/9", data).parsed_response
483530
"parent": 0,
484531
"description": "All kinds of clothes.",
485532
"display": "default",
486-
"image": "",
533+
"image": {
534+
"id": 173,
535+
"date_created": "2016-05-31T23:51:03",
536+
"date_modified": "2016-05-31T23:51:03",
537+
"src": "https://example/wp-content/uploads/2016/05/T_3_front-1.jpg",
538+
"title": "",
539+
"alt": ""
540+
},
487541
"menu_order": 0,
488-
"count": 12,
542+
"count": 18,
489543
"_links": {
490544
"self": [
491545
{
492-
"href": "https://example.com/wp-json/wc/v1/products/categories/9"
546+
"href": "https://example/wp-json/wc/v1/products/categories/9"
493547
}
494548
],
495549
"collection": [
496550
{
497-
"href": "https://example.com/wp-json/wc/v1/products/categories"
551+
"href": "https://example/wp-json/wc/v1/products/categories"
498552
}
499553
]
500554
}
@@ -547,18 +601,25 @@ woocommerce.delete("products/categories/9", force: true).parsed_response
547601
"parent": 0,
548602
"description": "All kinds of clothes.",
549603
"display": "default",
550-
"image": "",
604+
"image": {
605+
"id": 173,
606+
"date_created": "2016-05-31T23:51:03",
607+
"date_modified": "2016-05-31T23:51:03",
608+
"src": "https://example/wp-content/uploads/2016/05/T_3_front-1.jpg",
609+
"title": "",
610+
"alt": ""
611+
},
551612
"menu_order": 0,
552-
"count": 12,
613+
"count": 18,
553614
"_links": {
554615
"self": [
555616
{
556-
"href": "https://example.com/wp-json/wc/v1/products/categories/9"
617+
"href": "https://example/wp-json/wc/v1/products/categories/9"
557618
}
558619
],
559620
"collection": [
560621
{
561-
"href": "https://example.com/wp-json/wc/v1/products/categories"
622+
"href": "https://example/wp-json/wc/v1/products/categories"
562623
}
563624
]
564625
}
@@ -726,7 +787,7 @@ woocommerce.post("products/categories/batch", data).parsed_response
726787
"parent": 11,
727788
"description": "",
728789
"display": "default",
729-
"image": "",
790+
"image": [],
730791
"menu_order": 0,
731792
"count": 0,
732793
"_links": {
@@ -754,7 +815,7 @@ woocommerce.post("products/categories/batch", data).parsed_response
754815
"parent": 0,
755816
"description": "",
756817
"display": "default",
757-
"image": "",
818+
"image": [],
758819
"menu_order": 0,
759820
"count": 0,
760821
"_links": {
@@ -779,7 +840,7 @@ woocommerce.post("products/categories/batch", data).parsed_response
779840
"parent": 9,
780841
"description": "Nice hoodies",
781842
"display": "default",
782-
"image": "",
843+
"image": [],
783844
"menu_order": 0,
784845
"count": 6,
785846
"_links": {
@@ -809,7 +870,7 @@ woocommerce.post("products/categories/batch", data).parsed_response
809870
"parent": 0,
810871
"description": "",
811872
"display": "default",
812-
"image": "",
873+
"image": [],
813874
"menu_order": 0,
814875
"count": 7,
815876
"_links": {
@@ -832,7 +893,7 @@ woocommerce.post("products/categories/batch", data).parsed_response
832893
"parent": 0,
833894
"description": "",
834895
"display": "default",
835-
"image": "",
896+
"image": [],
836897
"menu_order": 0,
837898
"count": 5,
838899
"_links": {

0 commit comments

Comments
 (0)