Skip to content

Commit 1d1b07c

Browse files
committedAug 10, 2015
Created docs for product attributes
1 parent ec565cb commit 1d1b07c

File tree

1 file changed

+368
-36
lines changed

1 file changed

+368
-36
lines changed
 

‎source/includes/v3/_products.md

+368-36
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,7 @@ woocommerce.post("products", data).parsed_response
979979

980980
## View A Product ##
981981

982-
This API lets you retrieve and view a specific product by ID or sku.
982+
This API lets you retrieve and view a specific product by ID.
983983

984984
### HTTP Request ###
985985

@@ -2089,22 +2089,22 @@ This API helps you delete a product.
20892089
</div>
20902090

20912091
```shell
2092-
curl -X DELETE https://example.com/wc-api/v3/products/546/?force=true \
2092+
curl -X DELETE https://example.com/wc-api/v3/products/546?force=true \
20932093
-u consumer_key:consumer_secret
20942094
```
20952095

20962096
```javascript
2097-
WooCommerce.delete('products/546/?force=true', function(err, data, res) {
2097+
WooCommerce.delete('products/546?force=true', function(err, data, res) {
20982098
console.log(res);
20992099
});
21002100
```
21012101

21022102
```python
2103-
print(wcapi.delete("products/546/?force=true").json())
2103+
print(wcapi.delete("products/546?force=true").json())
21042104
```
21052105

21062106
```ruby
2107-
woocommerce.delete("products/546").parsed_response
2107+
woocommerce.delete("products/546?force=true").parsed_response
21082108
```
21092109

21102110
> JSON response example:
@@ -2168,74 +2168,333 @@ woocommerce.get("products/count").parsed_response
21682168
| `type` | string | Products by type. eg: `simple` or `variable` |
21692169
| `category` | string | Products by category. |
21702170

2171-
## View List Of Product Reviews ##
2171+
## Create A Product Attribute ##
2172+
2173+
This API helps you to create a new product attribute.
2174+
2175+
### HTTP Request ###
2176+
2177+
<div class="api-endpoint">
2178+
<div class="endpoint-data">
2179+
<i class="label label-post">POST</i>
2180+
<h6>/wc-api/v3/products/attributes</h6>
2181+
</div>
2182+
</div>
2183+
2184+
```shell
2185+
curl -X POST https://example.com/wc-api/v3/products/attributes \
2186+
-u consumer_key:consumer_secret \
2187+
-H "Content-Type: application/json" \
2188+
-d '{
2189+
"product_attribute": {
2190+
"name": "Color",
2191+
"slug": "pa_color",
2192+
"type": "select",
2193+
"order_by": "menu_order",
2194+
"has_archives": true
2195+
}
2196+
}'
2197+
```
2198+
2199+
```javascript
2200+
var data = {
2201+
product_attribute: {
2202+
name: "Color",
2203+
slug: "pa_color",
2204+
type: "select",
2205+
order_by: "menu_order",
2206+
has_archives: true
2207+
}
2208+
};
2209+
2210+
WooCommerce.post('products/attributes', data, function(err, data, res) {
2211+
console.log(res);
2212+
});
2213+
```
2214+
2215+
```python
2216+
data = {
2217+
"product_attribute": {
2218+
"name": "Color",
2219+
"slug": "pa_color",
2220+
"type": "select",
2221+
"order_by": "menu_order",
2222+
"has_archives": True
2223+
}
2224+
}
2225+
2226+
print(wcapi.post("products/attributes", data).json())
2227+
```
2228+
2229+
```ruby
2230+
data = {
2231+
product_attribute: {
2232+
name: "Color",
2233+
slug: "pa_color",
2234+
type: "select",
2235+
order_by: "menu_order",
2236+
has_archives: true
2237+
}
2238+
}
2239+
2240+
woocommerce.post("products/attributes", data).parsed_response
2241+
```
2242+
2243+
> JSON response example:
2244+
2245+
```json
2246+
{
2247+
"product_attribute": {
2248+
"id": 1,
2249+
"name": "Color",
2250+
"slug": "pa_color",
2251+
"type": "select",
2252+
"order_by": "menu_order",
2253+
"has_archives": true
2254+
}
2255+
}
2256+
```
2257+
2258+
### Product Attribute Properties ###
2259+
2260+
| Attribute | Type | Description |
2261+
| -------------- | ------- | -------------------------------------------------------------------------------------------------------------------- |
2262+
| `id` | integer | Attribute ID <i class="label label-info">read-only</i> |
2263+
| `name` | string | Attribute name |
2264+
| `slug` | string | Attribute slug |
2265+
| `type` | string | Attribute type, the types available include by default are: `select` and `text` (some plugins can include new types) |
2266+
| `order_by` | string | Default sort order. Available: `menu_order`, `name`, `name_num` and `id` |
2267+
| `has_archives` | boolean | Enable/Disable attribute archives |
2268+
2269+
## View A Product Attribute ##
2270+
2271+
This API lets you retrieve and view a specific product attribute by ID.
21722272

21732273
<div class="api-endpoint">
21742274
<div class="endpoint-data">
21752275
<i class="label label-get">GET</i>
2176-
<h6>/wc-api/v3/products/&lt;id&gt;/reviews</h6>
2276+
<h6>/wc-api/v3/products/attributes/&lt;id&gt;</h6>
21772277
</div>
21782278
</div>
21792279

21802280
```shell
2181-
curl https://example.com/wc-api/v3/products/546/reviews \
2281+
curl https://example.com/wc-api/v3/products/attributes/1 \
21822282
-u consumer_key:consumer_secret
21832283
```
21842284

21852285
```javascript
2186-
WooCommerce.get('products/546/reviews', function(err, data, res) {
2286+
WooCommerce.get('products/attributes/1', function(err, data, res) {
21872287
console.log(res);
21882288
});
21892289
```
21902290

21912291
```python
2192-
print(wcapi.get("products/546/reviews").json())
2292+
print(wcapi.get("products/attributes/1").json())
21932293
```
21942294

21952295
```ruby
2196-
woocommerce.get("products/546/reviews").parsed_response
2296+
woocommerce.get("products/attributes/1").parsed_response
21972297
```
21982298

21992299
> JSON response example:
22002300
22012301
```json
22022302
{
2203-
"product_reviews": [
2303+
"product_attribute": {
2304+
"id": 1,
2305+
"name": "Color",
2306+
"slug": "pa_color",
2307+
"type": "select",
2308+
"order_by": "menu_order",
2309+
"has_archives": true
2310+
}
2311+
}
2312+
```
2313+
2314+
<aside class="notice">
2315+
View the <a href="#product-attribute-properties">Product Attribute Properties</a> for more details on this response.
2316+
</aside>
2317+
2318+
## View List Of Product Attributes ##
2319+
2320+
This API helps you to view all the product attributes.
2321+
2322+
### HTTP Request ###
2323+
2324+
<div class="api-endpoint">
2325+
<div class="endpoint-data">
2326+
<i class="label label-get">GET</i>
2327+
<h6>/wc-api/v3/products/attributes</h6>
2328+
</div>
2329+
</div>
2330+
2331+
```shell
2332+
curl https://example.com/wc-api/v3/products/attributes \
2333+
-u consumer_key:consumer_secret
2334+
```
2335+
2336+
```javascript
2337+
WooCommerce.get('products/attributes', function(err, data, res) {
2338+
console.log(res);
2339+
});
2340+
```
2341+
2342+
```python
2343+
print(wcapi.get("products/attributes").json())
2344+
```
2345+
2346+
```ruby
2347+
woocommerce.get("products/attributes").parsed_response
2348+
```
2349+
2350+
> JSON response example:
2351+
2352+
```json
2353+
{
2354+
"product_attributes": [
22042355
{
2205-
"id": 4,
2206-
"created_at": "2013-06-07T11:57:45Z",
2207-
"review": "This t-shirt is awesome! Would recommend to everyone!\n\nI'm ordering mine next week",
2208-
"rating": "5",
2209-
"reviewer_name": "Andrew",
2210-
"reviewer_email": "andrew@example.com",
2211-
"verified": false
2356+
"id": 1,
2357+
"name": "Color",
2358+
"slug": "pa_color",
2359+
"type": "select",
2360+
"order_by": "menu_order",
2361+
"has_archives": true
22122362
},
22132363
{
2214-
"id": 3,
2215-
"created_at": "2013-06-07T11:53:49Z",
2216-
"review": "Wonderful quality, and an awesome design. WooThemes ftw!",
2217-
"rating": "4",
2218-
"reviewer_name": "Cobus Bester",
2219-
"reviewer_email": "cobus@example.com",
2220-
"verified": false
2364+
"id": 2,
2365+
"name": "Size",
2366+
"slug": "pa_size",
2367+
"type": "select",
2368+
"order_by": "menu_order",
2369+
"has_archives": false
22212370
}
22222371
]
22232372
}
22242373
```
22252374

2226-
### Product Reviews Properties ###
2375+
<aside class="notice">
2376+
View the <a href="#product-attribute-properties">Product Attribute Properties</a> for more details on this response.
2377+
</aside>
22272378

2228-
| Attribute | Type | Description |
2229-
| ---------------- | ------- | ----------------------------------------------------------------------------------------- |
2230-
| `id` | integer | Review ID (comment ID) <i class="label label-info">read-only</i> |
2231-
| `created_at` | string | UTC DateTime when the review was created <i class="label label-info">read-only</i> |
2232-
| `rating` | string | Review rating (0 to 5) <i class="label label-info">read-only</i> |
2233-
| `reviewer_name` | string | Reviewer name <i class="label label-info">read-only</i> |
2234-
| `reviewer_email` | string | Reviewer email <i class="label label-info">read-only</i> |
2235-
| `verified` | boolean | Shows if the reviewer bought the product or not <i class="label label-info">read-only</i> |
2379+
## Update A Product Attribute ##
2380+
2381+
This API lets you make changes to a product attribute.
2382+
2383+
### HTTP Request ###
2384+
2385+
<div class="api-endpoint">
2386+
<div class="endpoint-data">
2387+
<i class="label label-put">PUT</i>
2388+
<h6>/wc-api/v3/products/attributes/&lt;id&gt;</h6>
2389+
</div>
2390+
</div>
2391+
2392+
```shell
2393+
curl -X PUT https://example.com/wc-api/v3/products/attributes/1 \
2394+
-u consumer_key:consumer_secret \
2395+
-H "Content-Type: application/json" \
2396+
-d '{
2397+
"product_attribute": {
2398+
"order_by": "name"
2399+
}
2400+
}'
2401+
```
2402+
2403+
```javascript
2404+
var data = {
2405+
product_attribute: {
2406+
order_by: 'name'
2407+
}
2408+
};
2409+
2410+
WooCommerce.put('products/attributes/1', data, function(err, data, res) {
2411+
console.log(res);
2412+
});
2413+
```
2414+
2415+
```python
2416+
data = {
2417+
"product_attribute": {
2418+
"order_by": "name"
2419+
}
2420+
}
2421+
2422+
print(wcapi.put("products/attributes/1", data).json())
2423+
```
2424+
2425+
```ruby
2426+
data = {
2427+
product_attribute: {
2428+
order_by: "name"
2429+
}
2430+
}
2431+
2432+
woocommerce.put("products/attributes/1", data).parsed_response
2433+
```
2434+
2435+
> JSON response example:
2436+
2437+
```json
2438+
{
2439+
"product_attribute": {
2440+
"id": 1,
2441+
"name": "Color",
2442+
"slug": "pa_color",
2443+
"type": "select",
2444+
"order_by": "name",
2445+
"has_archives": true
2446+
}
2447+
}
2448+
```
2449+
2450+
<aside class="notice">
2451+
View the <a href="#product-attribute-properties">Product Attribute Properties</a> for more details on this response.
2452+
</aside>
2453+
2454+
## Delete A Product Attribute ##
2455+
2456+
This API helps you delete a product attribute.
2457+
2458+
### HTTP Request ###
2459+
2460+
<div class="api-endpoint">
2461+
<div class="endpoint-data">
2462+
<i class="label label-delete">DELETE</i>
2463+
<h6>/wc-api/v3/products/attributes/&lt;id&gt;</h6>
2464+
</div>
2465+
</div>
2466+
2467+
```shell
2468+
curl -X DELETE https://example.com/wc-api/v3/products/attributes/1 \
2469+
-u consumer_key:consumer_secret
2470+
```
2471+
2472+
```javascript
2473+
WooCommerce.delete('products/attributes/1', function(err, data, res) {
2474+
console.log(res);
2475+
});
2476+
```
2477+
2478+
```python
2479+
print(wcapi.delete("products/attributes/1").json())
2480+
```
2481+
2482+
```ruby
2483+
woocommerce.delete("products/attributes/1").parsed_response
2484+
```
2485+
2486+
> JSON response example:
2487+
2488+
```json
2489+
{
2490+
"message": "Deleted product_attribute"
2491+
}
2492+
```
22362493

22372494
## View A Product Category ##
22382495

2496+
This API lets you retrieve a product category.
2497+
22392498
<div class="api-endpoint">
22402499
<div class="endpoint-data">
22412500
<i class="label label-get">GET</i>
@@ -2284,16 +2543,19 @@ woocommerce.get("products/categories/9").parsed_response
22842543
| Attribute | Type | Description |
22852544
| ------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
22862545
| `id` | integer | Category ID (term ID) <i class="label label-info">read-only</i> |
2287-
| `name` | string | Category Name <i class="label label-info">read-only</i> |
2546+
| `name` | string | Category name <i class="label label-info">read-only</i> |
22882547
| `slug` | string | Category slug <i class="label label-info">read-only</i> |
22892548
| `parent` | integer | Category parent <i class="label label-info">read-only</i> |
22902549
| `description` | string | Category description <i class="label label-info">read-only</i> |
22912550
| `display` | string | Category archive display type, the types available include: `default`, `products`, `subcategories` and `both` <i class="label label-info">read-only</i> |
22922551
| `image` | string | Category image URL <i class="label label-info">read-only</i> |
22932552
| `count` | boolean | Shows the quantity of products in this category <i class="label label-info">read-only</i> |
22942553

2554+
22952555
## View List Of Product Categories ##
22962556

2557+
This API lets you retrieve all product categories.
2558+
22972559
<div class="api-endpoint">
22982560
<div class="endpoint-data">
22992561
<i class="label label-get">GET</i>
@@ -2405,6 +2667,8 @@ woocommerce.get("products/categories").parsed_response
24052667

24062668
## View List Of Product Orders ##
24072669

2670+
This API lets you retrieve all product orders.
2671+
24082672
<div class="api-endpoint">
24092673
<div class="endpoint-data">
24102674
<i class="label label-get">GET</i>
@@ -2743,3 +3007,71 @@ woocommerce.get("products/546/orders").parsed_response
27433007
<aside class="notice">
27443008
View the <a href="#orders-properties">Order Properties</a> for more details on this response.
27453009
</aside>
3010+
3011+
## View List Of Product Reviews ##
3012+
3013+
This API lets you retrieve all reviews of a product.
3014+
3015+
<div class="api-endpoint">
3016+
<div class="endpoint-data">
3017+
<i class="label label-get">GET</i>
3018+
<h6>/wc-api/v3/products/&lt;id&gt;/reviews</h6>
3019+
</div>
3020+
</div>
3021+
3022+
```shell
3023+
curl https://example.com/wc-api/v3/products/546/reviews \
3024+
-u consumer_key:consumer_secret
3025+
```
3026+
3027+
```javascript
3028+
WooCommerce.get('products/546/reviews', function(err, data, res) {
3029+
console.log(res);
3030+
});
3031+
```
3032+
3033+
```python
3034+
print(wcapi.get("products/546/reviews").json())
3035+
```
3036+
3037+
```ruby
3038+
woocommerce.get("products/546/reviews").parsed_response
3039+
```
3040+
3041+
> JSON response example:
3042+
3043+
```json
3044+
{
3045+
"product_reviews": [
3046+
{
3047+
"id": 4,
3048+
"created_at": "2013-06-07T11:57:45Z",
3049+
"review": "This t-shirt is awesome! Would recommend to everyone!\n\nI'm ordering mine next week",
3050+
"rating": "5",
3051+
"reviewer_name": "Andrew",
3052+
"reviewer_email": "andrew@example.com",
3053+
"verified": false
3054+
},
3055+
{
3056+
"id": 3,
3057+
"created_at": "2013-06-07T11:53:49Z",
3058+
"review": "Wonderful quality, and an awesome design. WooThemes ftw!",
3059+
"rating": "4",
3060+
"reviewer_name": "Cobus Bester",
3061+
"reviewer_email": "cobus@example.com",
3062+
"verified": false
3063+
}
3064+
]
3065+
}
3066+
```
3067+
3068+
### Product Reviews Properties ###
3069+
3070+
| Attribute | Type | Description |
3071+
| ---------------- | ------- | ----------------------------------------------------------------------------------------- |
3072+
| `id` | integer | Review ID (comment ID) <i class="label label-info">read-only</i> |
3073+
| `created_at` | string | UTC DateTime when the review was created <i class="label label-info">read-only</i> |
3074+
| `rating` | string | Review rating (0 to 5) <i class="label label-info">read-only</i> |
3075+
| `reviewer_name` | string | Reviewer name <i class="label label-info">read-only</i> |
3076+
| `reviewer_email` | string | Reviewer email <i class="label label-info">read-only</i> |
3077+
| `verified` | boolean | Shows if the reviewer bought the product or not <i class="label label-info">read-only</i> |

0 commit comments

Comments
 (0)
Please sign in to comment.