@@ -12,10 +12,21 @@ The product categories API allows you to create, view, update, and delete indivi
12
12
| ` parent ` | integer | The id for the parent of the resource. |
13
13
| ` description ` | string | HTML description of the resource. |
14
14
| ` 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 ) |
16
16
| ` menu_order ` | integer | Menu order, used to custom sort the resource. |
17
17
| ` count ` | integer | Number of published products for the resource. <i class =" label label-info " >read-only</i > |
18
18
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
+
19
30
## Create a product category ##
20
31
21
32
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 \
36
47
-u consumer_key:consumer_secret \
37
48
-H " Content-Type: application/json" \
38
49
-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
+ }
40
54
}'
41
55
```
42
56
43
57
``` javascript
44
58
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
+ }
46
63
};
47
64
48
65
WooCommerce .post (' products/categories' , data, function (err , data , res ) {
@@ -53,7 +70,10 @@ WooCommerce.post('products/categories', data, function(err, data, res) {
53
70
``` php
54
71
<?php
55
72
$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
+ ]
57
77
];
58
78
59
79
print_r($woocommerce->post('products/categories', $data));
@@ -62,15 +82,21 @@ print_r($woocommerce->post('products/categories', $data));
62
82
63
83
``` python
64
84
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
+ }
66
89
}
67
90
68
91
print (wcapi.post(" products/categories" , data).json())
69
92
```
70
93
71
94
``` ruby
72
95
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
+ }
74
100
}
75
101
76
102
woocommerce.post(" products/categories" , data).parsed_response
@@ -86,18 +112,25 @@ woocommerce.post("products/categories", data).parsed_response
86
112
"parent" : 0 ,
87
113
"description" : " " ,
88
114
"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
+ },
90
123
"menu_order" : 0 ,
91
- "count" : 12 ,
124
+ "count" : 18 ,
92
125
"_links" : {
93
126
"self" : [
94
127
{
95
- "href" : " https://example.com /wp-json/wc/v1/products/categories/9"
128
+ "href" : " https://example/wp-json/wc/v1/products/categories/9"
96
129
}
97
130
],
98
131
"collection" : [
99
132
{
100
- "href" : " https://example.com /wp-json/wc/v1/products/categories"
133
+ "href" : " https://example/wp-json/wc/v1/products/categories"
101
134
}
102
135
]
103
136
}
@@ -148,18 +181,25 @@ woocommerce.get("products/categories/9").parsed_response
148
181
"parent" : 0 ,
149
182
"description" : " " ,
150
183
"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
+ },
152
192
"menu_order" : 0 ,
153
- "count" : 12 ,
193
+ "count" : 18 ,
154
194
"_links" : {
155
195
"self" : [
156
196
{
157
- "href" : " https://example.com /wp-json/wc/v1/products/categories/9"
197
+ "href" : " https://example/wp-json/wc/v1/products/categories/9"
158
198
}
159
199
],
160
200
"collection" : [
161
201
{
162
- "href" : " https://example.com /wp-json/wc/v1/products/categories"
202
+ "href" : " https://example/wp-json/wc/v1/products/categories"
163
203
}
164
204
]
165
205
}
@@ -211,7 +251,7 @@ woocommerce.get("products/categories").parsed_response
211
251
"parent" : 11 ,
212
252
"description" : " " ,
213
253
"display" : " default" ,
214
- "image" : " " ,
254
+ "image" : [] ,
215
255
"menu_order" : 0 ,
216
256
"count" : 4 ,
217
257
"_links" : {
@@ -239,18 +279,25 @@ woocommerce.get("products/categories").parsed_response
239
279
"parent" : 0 ,
240
280
"description" : " " ,
241
281
"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
+ },
243
290
"menu_order" : 0 ,
244
- "count" : 12 ,
291
+ "count" : 18 ,
245
292
"_links" : {
246
293
"self" : [
247
294
{
248
- "href" : " https://example.com /wp-json/wc/v1/products/categories/9"
295
+ "href" : " https://example/wp-json/wc/v1/products/categories/9"
249
296
}
250
297
],
251
298
"collection" : [
252
299
{
253
- "href" : " https://example.com /wp-json/wc/v1/products/categories"
300
+ "href" : " https://example/wp-json/wc/v1/products/categories"
254
301
}
255
302
]
256
303
}
@@ -262,7 +309,7 @@ woocommerce.get("products/categories").parsed_response
262
309
"parent" : 9 ,
263
310
"description" : " " ,
264
311
"display" : " default" ,
265
- "image" : " " ,
312
+ "image" : [] ,
266
313
"menu_order" : 0 ,
267
314
"count" : 6 ,
268
315
"_links" : {
@@ -290,7 +337,7 @@ woocommerce.get("products/categories").parsed_response
290
337
"parent" : 0 ,
291
338
"description" : " " ,
292
339
"display" : " default" ,
293
- "image" : " " ,
340
+ "image" : [] ,
294
341
"menu_order" : 0 ,
295
342
"count" : 7 ,
296
343
"_links" : {
@@ -313,7 +360,7 @@ woocommerce.get("products/categories").parsed_response
313
360
"parent" : 0 ,
314
361
"description" : " " ,
315
362
"display" : " default" ,
316
- "image" : " " ,
363
+ "image" : [] ,
317
364
"menu_order" : 0 ,
318
365
"count" : 5 ,
319
366
"_links" : {
@@ -336,7 +383,7 @@ woocommerce.get("products/categories").parsed_response
336
383
"parent" : 11 ,
337
384
"description" : " " ,
338
385
"display" : " default" ,
339
- "image" : " " ,
386
+ "image" : [] ,
340
387
"menu_order" : 0 ,
341
388
"count" : 3 ,
342
389
"_links" : {
@@ -364,7 +411,7 @@ woocommerce.get("products/categories").parsed_response
364
411
"parent" : 9 ,
365
412
"description" : " " ,
366
413
"display" : " default" ,
367
- "image" : " " ,
414
+ "image" : [] ,
368
415
"menu_order" : 0 ,
369
416
"count" : 6 ,
370
417
"_links" : {
@@ -483,18 +530,25 @@ woocommerce.put("products/categories/9", data).parsed_response
483
530
"parent" : 0 ,
484
531
"description" : " All kinds of clothes." ,
485
532
"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
+ },
487
541
"menu_order" : 0 ,
488
- "count" : 12 ,
542
+ "count" : 18 ,
489
543
"_links" : {
490
544
"self" : [
491
545
{
492
- "href" : " https://example.com /wp-json/wc/v1/products/categories/9"
546
+ "href" : " https://example/wp-json/wc/v1/products/categories/9"
493
547
}
494
548
],
495
549
"collection" : [
496
550
{
497
- "href" : " https://example.com /wp-json/wc/v1/products/categories"
551
+ "href" : " https://example/wp-json/wc/v1/products/categories"
498
552
}
499
553
]
500
554
}
@@ -547,18 +601,25 @@ woocommerce.delete("products/categories/9", force: true).parsed_response
547
601
"parent" : 0 ,
548
602
"description" : " All kinds of clothes." ,
549
603
"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
+ },
551
612
"menu_order" : 0 ,
552
- "count" : 12 ,
613
+ "count" : 18 ,
553
614
"_links" : {
554
615
"self" : [
555
616
{
556
- "href" : " https://example.com /wp-json/wc/v1/products/categories/9"
617
+ "href" : " https://example/wp-json/wc/v1/products/categories/9"
557
618
}
558
619
],
559
620
"collection" : [
560
621
{
561
- "href" : " https://example.com /wp-json/wc/v1/products/categories"
622
+ "href" : " https://example/wp-json/wc/v1/products/categories"
562
623
}
563
624
]
564
625
}
@@ -726,7 +787,7 @@ woocommerce.post("products/categories/batch", data).parsed_response
726
787
"parent" : 11 ,
727
788
"description" : " " ,
728
789
"display" : " default" ,
729
- "image" : " " ,
790
+ "image" : [] ,
730
791
"menu_order" : 0 ,
731
792
"count" : 0 ,
732
793
"_links" : {
@@ -754,7 +815,7 @@ woocommerce.post("products/categories/batch", data).parsed_response
754
815
"parent" : 0 ,
755
816
"description" : " " ,
756
817
"display" : " default" ,
757
- "image" : " " ,
818
+ "image" : [] ,
758
819
"menu_order" : 0 ,
759
820
"count" : 0 ,
760
821
"_links" : {
@@ -779,7 +840,7 @@ woocommerce.post("products/categories/batch", data).parsed_response
779
840
"parent" : 9 ,
780
841
"description" : " Nice hoodies" ,
781
842
"display" : " default" ,
782
- "image" : " " ,
843
+ "image" : [] ,
783
844
"menu_order" : 0 ,
784
845
"count" : 6 ,
785
846
"_links" : {
@@ -809,7 +870,7 @@ woocommerce.post("products/categories/batch", data).parsed_response
809
870
"parent" : 0 ,
810
871
"description" : " " ,
811
872
"display" : " default" ,
812
- "image" : " " ,
873
+ "image" : [] ,
813
874
"menu_order" : 0 ,
814
875
"count" : 7 ,
815
876
"_links" : {
@@ -832,7 +893,7 @@ woocommerce.post("products/categories/batch", data).parsed_response
832
893
"parent" : 0 ,
833
894
"description" : " " ,
834
895
"display" : " default" ,
835
- "image" : " " ,
896
+ "image" : [] ,
836
897
"menu_order" : 0 ,
837
898
"count" : 5 ,
838
899
"_links" : {
0 commit comments