diff --git a/source/images/logo.png b/source/images/logo.png index 12546ebc..2415244b 100644 Binary files a/source/images/logo.png and b/source/images/logo.png differ diff --git a/source/images/woocommerce-api-key-generated.png b/source/images/woocommerce-api-key-generated.png new file mode 100644 index 00000000..cd2b1e57 Binary files /dev/null and b/source/images/woocommerce-api-key-generated.png differ diff --git a/source/images/woocommerce-api-keys-settings.png b/source/images/woocommerce-api-keys-settings.png new file mode 100644 index 00000000..504c0b44 Binary files /dev/null and b/source/images/woocommerce-api-keys-settings.png differ diff --git a/source/images/woocommerce-creating-api-keys.png b/source/images/woocommerce-creating-api-keys.png new file mode 100644 index 00000000..b64fc139 Binary files /dev/null and b/source/images/woocommerce-creating-api-keys.png differ diff --git a/source/includes/wp-api-v1/_authentication.md b/source/includes/wp-api-v1/_authentication.md new file mode 100644 index 00000000..b983b903 --- /dev/null +++ b/source/includes/wp-api-v1/_authentication.md @@ -0,0 +1,336 @@ +# Authentication # + +WooCommerce includes two ways to authenticate with the WP REST API. In addition, it is possible to use any [WP REST API authentication](http://v2.wp-api.org/guide/authentication/) plugin or method too. + +## REST API keys ## + +To be unable to authenticate to any endpoint of our REST API you must generate a REST API keys, currently you can generate new REST API keys by the WordPress admin interface or by an endpoint to auto generate. + +### Generating API keys in the WordPress admin interface ### + +To create or manage keys for a specific WordPress user, go to WooCommerce > Settings > API > Keys/Apps. + +![WooCommerce REST API keys settings](images/woocommerce-api-keys-settings.png) + +Click in the "Add Key" button and in the next screen select the User you would like to generate a key for in the User field and add a Description. Choose the level of access for this REST API key, which can be Read access, Write access or Read/Write access. Then select the Generate API Key button and WooCommerce will generate REST API keys for that user. + +![Creating a new REST API key](images/woocommerce-creating-api-keys.png) + +Now that keys have been generated, you should see two new keys, a QRCode, and a Revoke API Key button. These two keys are your Consumer Key and Consumer Secret. + +![Generated REST API key](images/woocommerce-api-key-generated.png) + +### Auto generating API keys using our Application Authentication Endpoint ### + +This endpoint can be used by any APP to *allow users to generate API keys* for your APP. This makes integration with WooCommerce API easier because the user only needs to grant access to your APP via a URL. After being redirected back to your APP, the API keys will be sent back in a separate POST request. + +The following image illustrates how this works: + +![Authentication Endpoint flow](images/woocommerce-auth-endpoint-flow.png) + + + +#### URL parameters #### + +| Parameter | Type | Description | +|----------------|--------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `app_name` | string | Your APP name mandatory | +| `scope` | string | Level of access. Available: `read`, `write` and `read_write` mandatory | +| `user_id` | string | User ID in your APP. For your internal reference, used when the user is redirected back to your APP. NOT THE USER ID IN WOOCOMMERCE mandatory | +| `return_url` | string | URL the user will be redirected to after authentication mandatory | +| `callback_url` | string | URL that will receive the generated API key. Note: this URL should be over **HTTPS** mandatory | + +#### Creating an authentication endpoint URL #### + +You must use the `/wc-auth/v1/authorize` endpoint and pass the above parameters as a query string. + +> Example of how to build an authentication URL: + +```shell +# Bash example +STORE_URL='http://example.com' +ENDPOINT='/wc-auth/v1/authorize' +PARAMS="app_name=My App Name&scope=read_write&user_id=123&return_url=http://app.com/return-page&callback_url=https://app.com/callback-endpoint" +QUERY_STRING="$(perl -MURI::Escape -e 'print uri_escape($ARGV[0]);' "$PARAMS")" +QUERY_STRING=$(echo $QUERY_STRING | sed -e "s/%20/\+/g" -e "s/%3D/\=/g" -e "s/%26/\&/g") + +echo "$STORE_URL$ENDPOINT?$QUERY_STRING" +``` + +```javascript +var querystring = require('querystring'); + +var store_url = 'http://example.com'; +var endpoint = '/wc-auth/v1/authorize'; +var params = { + app_name: 'My App Name', + scope: 'read_write', + user_id: 123, + return_url: 'http://app.com/return-page', + callback_url: 'https://app.com/callback-endpoint' +}; +var query_string = querystring.stringify(params).replace(/%20/g, '+'); + +console.log(store_url + endpoint + '?' + query_string); +``` + +```php + 'My App Name', + 'scope' => 'write', + 'user_id' => 123, + 'return_url' => 'http://app.com', + 'callback_url' => 'https://app.com' +]; +$query_string = http_build_query( $params ); + +echo $store_url . $endpoint . '?' . $query_string; +?> +``` + +```python +from urllib.parse import urlencode + +store_url = 'http://example.com' +endpoint = '/wc-auth/v1/authorize' +params = { + "app_name": "My App Name", + "scope": "read_write", + "user_id": 123, + "return_url": "http://app.com/return-page", + "callback_url": "https://app.com/callback-endpoint" +} +query_string = urlencode(params) + +print("%s%s?%s" % (store_url, endpoint, query_string)) +``` + +```ruby +require "uri" + +store_url = 'http://example.com' +endpoint = '/wc-auth/v1/authorize' +params = { + app_name: "My App Name", + scope: "read_write", + user_id: 123, + return_url: "http://app.com/return-page", + callback_url: "https://app.com/callback-endpoint" +} +query_string = URI.encode_www_form(params) + +puts "#{store_url}#{endpoint}?#{query_string}" +``` + +> Example of JSON posted with the API Keys + +``` +{ + "key_id": 1, + "user_id": 123, + "consumer_key": "ck_xxxxxxxxxxxxxxxx", + "consumer_secret": "cs_xxxxxxxxxxxxxxxx", + "key_permissions": "read_write" +} +``` + +Example of the screen that the user will see: + +![Authentication Endpoint example](images/woocommerce-auth-endpoint-example.png) + +#### Notes #### + +- While redirecting the user using `return_url`, you are also sent `success` and `user_id` parameters as query strings. +- `success` sends `0` if the user denied, or `1` if authenticated successfully. +- Use `user_id` to identify the user when redirected back to the (`return_url`) and also remember to save the API Keys when your `callback_url` is posted to after auth. +- The auth endpoint will send the API Keys in JSON format to the `callback_url`, so it's important to remember that some languages such as PHP will not display it inside the `$_POST` global variable, in PHP you can access it using `$HTTP_RAW_POST_DATA` (for old PHP versions) or `file_get_contents('php://input');`. + +## Authentication over HTTPS ## + +You may use [HTTP Basic Auth](http://en.wikipedia.org/wiki/Basic_access_authentication) by providing the REST API Consumer Key as the username and the REST API Consumer Secret as the password. + +> HTTP Basic Auth example + +```shell +curl https://www.example.com/wp-json/wc/v1/orders \ + -u consumer_key:consumer_secret +``` + +```javascript +var WooCommerceAPI = require('woocommerce-api'); + +var WooCommerce = new WooCommerceAPI({ + url: 'https://example.com', + consumerKey: 'consumer_key', + consumerSecret: 'consumer_secret', + wp_api: true, + version: 'wc/v1' +}); +``` + +```php + true, + 'version' => 'wc/v1' + ] +); +?> +``` + +```python +from woocommerce import API + +wcapi = API( + url="https://example.com", + consumer_key="consumer_key", + consumer_secret="consumer_secret", + wp_api=True, + version="wc/v1" +) +``` + +```ruby +require "woocommerce_api" + +woocommerce = WooCommerce::API.new( + "https://example.com", + "consumer_key", + "consumer_secret", + { + wp_json: true, + version: "v3" + } +) +``` + +Occasionally some servers may not parse the Authorization header correctly (if you see a "Consumer key is missing" error when authenticating over SSL, you have a server issue). In this case, you may provide the consumer key/secret as query string parameters instead. + +> Example for servers that not properly parse the Authorization header: + +```shell +curl https://www.example.com/wp-json/wc/v1/orders?consumer_key=123&consumer_secret=abc +``` + +```javascript +var WooCommerceAPI = require('woocommerce-api'); + +var WooCommerce = new WooCommerceAPI({ + url: 'https://example.com', + consumerKey: 'consumer_key', + consumerSecret: 'consumer_secret', + wp_api: true, + version: 'wc/v1', + queryStringAuth: true // When true and using under HTTPS force Basic Authentication as query string +}); +``` + +```php + true, + 'version' => 'wc/v1', + 'query_string_auth' => true // When true and using under HTTPS force Basic Authentication as query string + ] +); +?> +``` + +## Authentication over HTTP ## + +You must use [OAuth 1.0a "one-legged" authentication](http://tools.ietf.org/html/rfc5849) to ensure REST API credentials cannot be intercepted by an attacker. Typically you will use any standard OAuth 1.0a library in the language of your choice to handle the authentication, or generate the necessary parameters by following the following instructions. + +### Creating a signature ### + +#### Collect the request method and URL #### + +First you need to determine the HTTP method you will be using for the request, and the URL of the request. + +The **HTTP method** will be `GET` in our case. + +The **Request URL** will be the endpoint you are posting to, e.g. `http://www.example.com/wp-json/wc/v1/orders`. + +#### Collect parameters #### + +Collect and normalize your query string parameters. This includes all `oauth_*` parameters except for the `oauth_signature` itself. + +These values need to be encoded into a single string which will be used later on. The process to build the string is very specific: + +1. [Percent encode](https://dev.twitter.com/oauth/overview/percent-encoding-parameters) every key and value that will be signed. +2. Sort the list of parameters alphabetically by encoded key. +3. For each key/value pair: + - Append the encoded key to the output string. + - Append the `=` character to the output string. + - Append the encoded value to the output string. + - If there are more key/value pairs remaining, append a `&` character to the output string. + +When percent encoding in PHP for example, you would use `rawurlencode()`. + +When sorting parameters in PHP for example, you would use `uksort( $params, 'strcmp' )`. + +> Parameters example: + +``` +oauth_consumer_key=abc123&oauth_signature_method=HMAC-SHA1 +``` + +#### Create the signature base string #### + +The above values collected so far must be joined to make a single string, from which the signature will be generated. This is called the signature base string in the OAuth specification. + +To encode the HTTP method, request URL, and parameter string into a single string: + +1. Set the output string equal to the uppercase **HTTP Method**. +2. Append the `&` character to the output string. +3. [Percent encode](https://dev.twitter.com/oauth/overview/percent-encoding-parameters) the URL and append it to the output string. +4. Append the `&` character to the output string. +5. [Percent encode](https://dev.twitter.com/oauth/overview/percent-encoding-parameters) the parameter string and append it to the output string. + +> Example signature base string: + +``` +GET&http%3A%2F%2Fwww.example.com%2Fwp-json%2Fwc%2Fv1%2Forders&oauth_consumer_key%3Dabc123%26oauth_signature_method%3DHMAC-SHA1 +``` + +#### Generate the signature #### + +Generate the signature using the *signature base string* and your consumer secret key with the HMAC-SHA1 hashing algorithm. + +In PHP you can use the [hash_hmac](http://php.net/manual/en/function.hash-hmac.php) function. + +HMAC-SHA1 or HMAC-SHA256 are the only accepted hash algorithms. + +If you are having trouble generating a correct signature, you'll want to review the string you are signing for encoding errors. The [authentication source](https://github.com/woothemes/woocommerce/blob/master/includes/api/class-wc-rest-authentication.php#L141) can also be helpful in understanding how to properly generate the signature. + +### OAuth tips ### + +* The OAuth parameters must be added as query string parameters and *not* included in the Authorization header. This is because there is no reliable cross-platform way to get the raw request headers in WordPress. +* The required parameters are: `oauth_consumer_key`, `oauth_timestamp`, `oauth_nonce`, `oauth_signature`, and `oauth_signature_method`. `oauth_version` is not required and should be omitted. +* The OAuth nonce can be any randomly generated 32 character (recommended) string that is unique to the consumer key. Read more suggestions on [generating nonces on the Twitter REST API forums](https://dev.twitter.com/discussions/12445). +* The OAuth timestamp should be the unix timestamp at the time of the request. The REST API will deny any requests that include a timestamp outside of a 15 minute window to prevent replay attacks. +* You must use the store URL provided by the index when forming the base string used for the signature, as this is what the server will use. (e.g. if the store URL includes a `www` sub-domain, you should use it for requests) +* You may test your generated signature using LinkedIn's [OAuth test console](http://developer.linkedinlabs.com/oauth-test/) -- leave the member token/secret blank. +* Twitter has great instructions on [generating signatures](https://dev.twitter.com/docs/auth/creating-signature) with OAuth 1.0a, but remember tokens are not used with this implementation. +* Note that the request body is *not* signed as per the OAuth spec, see [Google's OAuth 1.0 extension](https://oauth.googlecode.com/svn/spec/ext/body_hash/1.0/oauth-bodyhash.html) for details on why. +* If including parameters in your request, it saves a lot of trouble if you can order your query string items alphabetically. diff --git a/source/includes/wp-api-v1/_coupons.md b/source/includes/wp-api-v1/_coupons.md new file mode 100644 index 00000000..19fc1dde --- /dev/null +++ b/source/includes/wp-api-v1/_coupons.md @@ -0,0 +1,902 @@ +# Coupons # + +The coupons API allows you to create, view, update, and delete individual, or a batch, of coupon codes. + +## Coupon properties ## + +| Attribute | Type | Description | +|-------------------------------|-----------|-------------------------------------------------------------------------------------------------------------------------------------------------------| +| `id` | integer | Unique identifier for the object. read-only | +| `code` | string | Coupon code. mandatory | +| `date_created` | date-time | The date the coupon was created, in the site's timezone. read-only | +| `date_modified` | date-time | The date the coupon was last modified, in the site's timezone. read-only | +| `description` | string | Coupon description. | +| `discount_type` | string | Determines the type of discount that will be applied. Options: `fixed_cart`, `percent`, `fixed_product` and `percent_product`. Default: `fixed_cart`. | +| `amount` | float | The amount of discount. | +| `expiry_date` | string | UTC DateTime when the coupon expires. | +| `usage_count` | integer | Number of times the coupon has been used already. read-only | +| `individual_use` | boolean | Whether coupon can only be used individually. | +| `product_ids` | array | List of product ID's the coupon can be used on. | +| `exclude_product_ids` | array | List of product ID's the coupon cannot be used on. | +| `usage_limit` | integer | How many times the coupon can be used. | +| `usage_limit_per_user` | integer | How many times the coupon can be used per customer. | +| `limit_usage_to_x_items` | integer | Max number of items in the cart the coupon can be applied to. | +| `free_shipping` | boolean | Define if can be applied for free shipping. | +| `product_categories` | array | List of category ID's the coupon applies to. | +| `excluded_product_categories` | array | List of category ID's the coupon does not apply to. | +| `exclude_sale_items` | boolean | Define if should not apply when have sale items. | +| `minimum_amount` | float | Minimum order amount that needs to be in the cart before coupon applies. | +| `maximum_amount` | float | Maximum order amount allowed when using the coupon. | +| `email_restrictions` | array | List of email addresses that can use this coupon. | +| `used_by` | array | List of user IDs who have used the coupon. read-only | + +## Create a coupon ## + +This API helps you to create a new coupon. + +### HTTP request ### + +
+
+ POST +
/wp-json/wc/v1/coupons
+
+
+ +```shell +curl -X POST https://example.com/wp-json/wc/v1/coupons \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "code": "10off", + "discount_type": "percent", + "amount": 10, + "individual_use": true, + "exclude_sale_items": true, + "minimum_amount": "100.00" +}' +``` + +```javascript +var data = { + code: '10off', + discount_type: 'percent', + amount: 10, + individual_use: true, + exclude_sale_items: true, + minimum_amount: '100.00' +}; + +WooCommerce.post('coupons', data, function(err, data, res) { + console.log(res); +}); +``` + +```php + '10off', + 'discount_type' => 'percent', + 'amount' => 10, + 'individual_use' => true, + 'exclude_sale_items' => true, + 'minimum_amount' => '100.00' +]; + +print_r($woocommerce->post('coupons', $data)); +?> +``` + +```python +data = { + "code": "10off", + "discount_type": "percent", + "amount": 10, + "individual_use": True, + "exclude_sale_items": True, + "minimum_amount": "100.00" +} + +print(wcapi.post("coupons", data).json()) +``` + +```ruby +data = { + code: "10off", + discount_type: "percent", + amount: 10, + individual_use: true, + exclude_sale_items: true, + minimum_amount: "100.00" +} + +woocommerce.post("coupons", data).parsed_response +``` + +> JSON response example: + +```json +{ + "id": 113, + "code": "10off", + "date_created": "2016-04-28T21:55:54", + "date_modified": "2016-04-28T21:55:54", + "discount_type": "percent", + "description": "", + "amount": "10.00", + "expiry_date": null, + "usage_count": 0, + "individual_use": true, + "product_ids": [], + "exclude_product_ids": [], + "usage_limit": null, + "usage_limit_per_user": null, + "limit_usage_to_x_items": 0, + "free_shipping": false, + "product_categories": [], + "excluded_product_categories": [], + "exclude_sale_items": true, + "minimum_amount": "100.00", + "maximum_amount": "0.00", + "email_restrictions": [], + "used_by": [], + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/coupons/113" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/coupons" + } + ] + } +} +``` + +## Retrieve a coupon ## + +This API lets you retrieve and view a specific coupon by ID or code. + +### HTTP request ### + +
+
+ GET +
/wp-json/wc/v1/coupons/<id>
+
+
+ +```shell +curl https://example.com/wp-json/wc/v1/coupons/113 \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('coupons/113', function(err, data, res) { + console.log(res); +}); +``` + +```php +get('coupons/113')); ?> +``` + +```python +print(wcapi.get("coupons/113").json()) +``` + +```ruby +woocommerce.get("coupons/113").parsed_response +``` + +> JSON response example: + +```json +{ + "id": 113, + "code": "10off", + "date_created": "2016-04-28T21:55:54", + "date_modified": "2016-04-28T21:55:54", + "discount_type": "percent", + "description": "", + "amount": "10.00", + "expiry_date": null, + "usage_count": 0, + "individual_use": true, + "product_ids": [], + "exclude_product_ids": [], + "usage_limit": null, + "usage_limit_per_user": null, + "limit_usage_to_x_items": 0, + "free_shipping": false, + "product_categories": [], + "excluded_product_categories": [], + "exclude_sale_items": true, + "minimum_amount": "100.00", + "maximum_amount": "0.00", + "email_restrictions": [], + "used_by": [], + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/coupons/113" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/coupons" + } + ] + } +} +``` + +## List all coupons ## + +This API helps you to list all the coupons that have been created. + +### HTTP request ### + +
+
+ GET +
/wp-json/wc/v1/coupons
+
+
+ +```shell +curl https://example.com/wp-json/wc/v1/coupons \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('coupons', function(err, data, res) { + console.log(res); +}); +``` + +```php +get('coupons')); ?> +``` + +```python +print(wcapi.get("coupons").json()) +``` + +```ruby +woocommerce.get("coupons").parsed_response +``` + +> JSON response example: + +```json +[ + { + "id": 114, + "code": "free-shipping", + "date_created": "2016-04-28T21:58:25", + "date_modified": "2016-04-28T21:58:25", + "discount_type": "fixed_cart", + "description": "", + "amount": "0.00", + "expiry_date": null, + "usage_count": 0, + "individual_use": true, + "product_ids": [], + "exclude_product_ids": [], + "usage_limit": null, + "usage_limit_per_user": null, + "limit_usage_to_x_items": 0, + "free_shipping": false, + "product_categories": [], + "excluded_product_categories": [], + "exclude_sale_items": true, + "minimum_amount": "50.00", + "maximum_amount": "0.00", + "email_restrictions": [], + "used_by": [], + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/coupons/114" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/coupons" + } + ] + } + }, + { + "id": 113, + "code": "10off", + "date_created": "2016-04-28T21:55:54", + "date_modified": "2016-04-28T21:55:54", + "discount_type": "percent", + "description": "", + "amount": "10.00", + "expiry_date": null, + "usage_count": 0, + "individual_use": true, + "product_ids": [], + "exclude_product_ids": [], + "usage_limit": null, + "usage_limit_per_user": null, + "limit_usage_to_x_items": 0, + "free_shipping": false, + "product_categories": [], + "excluded_product_categories": [], + "exclude_sale_items": true, + "minimum_amount": "100.00", + "maximum_amount": "0.00", + "email_restrictions": [], + "used_by": [], + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/coupons/113" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/coupons" + } + ] + } + } +] +``` + +#### Available parameters #### + +| Parameter | Type | Description | +|------------|---------|---------------------------------------------------------------------------------------------------------------| +| `context` | string | Scope under which the request is made; determines fields present in response. Options: `view` and `edit`. | +| `page` | integer | Current page of the collection. | +| `per_page` | integer | Maximum number of items to be returned in result set. | +| `search` | string | Limit results to those matching a string. | +| `after` | string | Limit response to resources published after a given ISO8601 compliant date. | +| `before` | string | Limit response to resources published before a given ISO8601 compliant date. | +| `exclude` | string | Ensure result set excludes specific ids. | +| `include` | string | Limit result set to specific ids. | +| `offset` | integer | Offset the result set by a specific number of items. | +| `order` | string | Order sort attribute ascending or descending. Default is `asc`. Options: `asc` and `desc`. | +| `orderby` | string | Sort collection by object attribute. Default is `date`, Options: `date`, `id`, `include`, `title` and `slug`. | +| `filter` | string | Use WP Query arguments to modify the response; private query vars require appropriate authorization. | +| `code` | string | Limit result set to resources with a specific code. | + +## Update a coupon ## + +This API lets you make changes to a coupon. + +### HTTP request ### + +
+
+ PUT +
/wp-json/wc/v1/coupons/<id>
+
+
+ +```shell +curl -X PUT https://example.com/wp-json/wc/v1/coupons/113 \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "amount": 5 +}' +``` + +```javascript +var data = { + amount: 5 +}; + +WooCommerce.put('coupons/113', data, function(err, data, res) { + console.log(res); +}); +``` + +```php + 5 +]; + +print_r($woocommerce->put('coupons/113', $data)); +?> +``` + +```python +data = { + "amount": 5 +} + +print(wcapi.put("coupons/113", data).json()) +``` + +```ruby +data = { + amount: 5 +} + +woocommerce.put("coupons/113", data).parsed_response +``` + +> JSON response example: + +```json +{ + "id": 113, + "code": "10off", + "date_created": "2016-04-28T21:55:54", + "date_modified": "2016-04-28T22:00:49", + "discount_type": "percent", + "description": "", + "amount": "5.00", + "expiry_date": null, + "usage_count": 0, + "individual_use": true, + "product_ids": [], + "exclude_product_ids": [], + "usage_limit": null, + "usage_limit_per_user": null, + "limit_usage_to_x_items": 0, + "free_shipping": false, + "product_categories": [], + "excluded_product_categories": [], + "exclude_sale_items": true, + "minimum_amount": "100.00", + "maximum_amount": "0.00", + "email_restrictions": [], + "used_by": [], + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/coupons/113" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/coupons" + } + ] + } +} +``` + +## Delete a coupon ## + +This API helps you delete a coupon. + +### HTTP request ### + +
+
+ DELETE +
/wp-json/wc/v1/coupons/<id>
+
+
+ +```shell +curl -X DELETE https://example.com/wp-json/wc/v1/coupons/113?force=true \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.delete('coupons/113?force=true', function(err, data, res) { + console.log(res); +}); +``` + +```php +delete('coupons/113', ['force' => true])); ?> +``` + +```python +print(wcapi.delete("coupons/113?force=true").json()) +``` + +```ruby +woocommerce.delete("coupons/113", force: true).parsed_response +``` + +> JSON response example: + +```json +{ + "id": 113, + "code": "10off", + "date_created": "2016-04-28T21:55:54", + "date_modified": "2016-04-28T22:00:49", + "discount_type": "percent", + "description": "", + "amount": "5.00", + "expiry_date": null, + "usage_count": 0, + "individual_use": true, + "product_ids": [], + "exclude_product_ids": [], + "usage_limit": null, + "usage_limit_per_user": null, + "limit_usage_to_x_items": 0, + "free_shipping": false, + "product_categories": [], + "excluded_product_categories": [], + "exclude_sale_items": true, + "minimum_amount": "100.00", + "maximum_amount": "0.00", + "email_restrictions": [], + "used_by": [], + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/coupons/113" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/coupons" + } + ] + } +} +``` + +#### Available parameters #### + +| Parameter | Type | Description | +|-----------|--------|--------------------------------------------------------------------------| +| `force` | string | Use `true` whether to permanently delete the coupon, Default is `false`. | + +## Batch update coupons ## + +This API helps you to batch create, update and delete multiple coupons. + +### HTTP request ### + +
+
+ POST +
/wp-json/wc/v1/coupons/batch
+
+
+ +```shell +curl -X POST https://example.com//wp-json/wc/v1/coupons/batch \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "create": [ + { + "code": "20off", + "discount_type": "percent", + "amount": 20, + "individual_use": true, + "exclude_sale_items": true, + "minimum_amount": "100.00" + }, + { + "code": "30off", + "discount_type": "percent", + "amount": 30, + "individual_use": true, + "exclude_sale_items": true, + "minimum_amount": "100.00" + } + ], + "update": [ + { + "id": 113, + "minimum_amount": "50.00" + } + ], + "delete": [ + 137 + ] +}' +``` + +```javascript +var data = { + create: [ + { + code: '20off', + discount_type: 'percent', + amount: 20, + individual_use: true, + exclude_sale_items: true, + minimum_amount: '100.00' + }, + { + code: '30off', + discount_type: 'percent', + amount: 30, + individual_use: true, + exclude_sale_items: true, + minimum_amount: '100.00' + } + ], + update: [ + { + id: 113, + minimum_amount: '50.00' + } + ], + delete: [ + 137 + ] +}; + +WooCommerce.post('customers/batch', data, function(err, data, res) { + console.log(res); +}); +``` + +```php + [ + [ + 'code' => '20off', + 'discount_type' => 'percent', + 'amount' => 20, + 'individual_use' => true, + 'exclude_sale_items' => true, + 'minimum_amount' => '100.00' + ], + [ + 'code' => '30off', + 'discount_type' => 'percent', + 'amount' => 30, + 'individual_use' => true, + 'exclude_sale_items' => true, + 'minimum_amount' => '100.00' + ] + ], + 'update' => [ + [ + 'id' => 113, + 'minimum_amount' => '50.00' + ] + ], + 'delete' => [ + 137 + ] +]; + +print_r($woocommerce->post('customers/batch', $data)); +?> +``` + +```python +data = { + "create": [ + { + "code": "20off", + "discount_type": "percent", + "amount": 20, + "individual_use": True, + "exclude_sale_items": True, + "minimum_amount": "100.00" + }, + { + "code": "30off", + "discount_type": "percent", + "amount": 30, + "individual_use": True, + "exclude_sale_items": True, + "minimum_amount": "100.00" + } + ], + "update": [ + { + "id": 113, + "minimum_amount": "50.00" + } + ], + "delete": [ + 137 + ] +} + +print(wcapi.post("customers/batch", data).json()) +``` + +```ruby +data = { + create: [ + { + code: "20off", + discount_type: "percent", + amount: 20, + individual_use: true, + exclude_sale_items: true, + minimum_amount: "100.00" + }, + { + code: "30off", + discount_type: "percent", + amount: 30, + individual_use: true, + exclude_sale_items: true, + minimum_amount: "100.00" + } + ], + update: [ + { + id: 113, + minimum_amount: "50.00" + } + ], + delete: [ + 137 + ] +} + +woocommerce.post("customers/batch", data).parsed_response +``` + +> JSON response example: + +```json +{ + "create": [ + { + "id": 138, + "code": "20off", + "date_created": "2016-05-17T20:52:21", + "date_modified": "2016-05-17T20:52:21", + "discount_type": "percent", + "description": "", + "amount": "20.00", + "expiry_date": null, + "usage_count": 0, + "individual_use": true, + "product_ids": [], + "exclude_product_ids": [], + "usage_limit": null, + "usage_limit_per_user": null, + "limit_usage_to_x_items": 0, + "free_shipping": false, + "product_categories": [], + "excluded_product_categories": [], + "exclude_sale_items": true, + "minimum_amount": "100.00", + "maximum_amount": "0.00", + "email_restrictions": [], + "used_by": [], + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/coupons/138" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/coupons" + } + ] + } + }, + { + "id": 139, + "code": "30off", + "date_created": "2016-05-17T20:52:22", + "date_modified": "2016-05-17T20:52:22", + "discount_type": "percent", + "description": "", + "amount": "30.00", + "expiry_date": null, + "usage_count": 0, + "individual_use": true, + "product_ids": [], + "exclude_product_ids": [], + "usage_limit": null, + "usage_limit_per_user": null, + "limit_usage_to_x_items": 0, + "free_shipping": false, + "product_categories": [], + "excluded_product_categories": [], + "exclude_sale_items": true, + "minimum_amount": "100.00", + "maximum_amount": "0.00", + "email_restrictions": [], + "used_by": [], + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/coupons/139" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/coupons" + } + ] + } + } + ], + "update": [ + { + "id": 113, + "code": "10off", + "date_created": "2016-04-28T21:55:54", + "date_modified": "2016-05-17T20:52:23", + "discount_type": "percent", + "description": "", + "amount": "5.00", + "expiry_date": null, + "usage_count": 0, + "individual_use": true, + "product_ids": [], + "exclude_product_ids": [], + "usage_limit": null, + "usage_limit_per_user": null, + "limit_usage_to_x_items": 0, + "free_shipping": false, + "product_categories": [], + "excluded_product_categories": [], + "exclude_sale_items": true, + "minimum_amount": "50.00", + "maximum_amount": "0.00", + "email_restrictions": [], + "used_by": [], + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/coupons/113" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/coupons" + } + ] + } + } + ], + "delete": [ + { + "id": 137, + "code": "50off", + "date_created": "2016-05-17T20:49:12", + "date_modified": "2016-05-17T20:50:30", + "discount_type": "fixed_cart", + "description": "", + "amount": "50.00", + "expiry_date": null, + "usage_count": 0, + "individual_use": false, + "product_ids": [], + "exclude_product_ids": [], + "usage_limit": null, + "usage_limit_per_user": null, + "limit_usage_to_x_items": 0, + "free_shipping": false, + "product_categories": [], + "excluded_product_categories": [], + "exclude_sale_items": false, + "minimum_amount": "0.00", + "maximum_amount": "0.00", + "email_restrictions": [], + "used_by": [], + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/coupons/137" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/coupons" + } + ] + } + } + ] +} +``` diff --git a/source/includes/wp-api-v1/_customers.md b/source/includes/wp-api-v1/_customers.md new file mode 100644 index 00000000..491be069 --- /dev/null +++ b/source/includes/wp-api-v1/_customers.md @@ -0,0 +1,1525 @@ +# Customers # + +The customer API allows you to create, view, update, and delete individual, or a batch, of customers. + +## Customer properties ## + +| Attribute | Type | Description | +|--------------------|-----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `id` | integer | Unique identifier for the resource. read-only | +| `date_created` | date-time | The date the customer was created, in the site's timezone. read-only | +| `date_modified` | date-time | The date the customer was last modified, in the site's timezone. read-only | +| `email` | string | The email address for the customer. mandatory | +| `first_name` | string | Customer first name. | +| `last_name` | string | Customer last name. | +| `username` | string | Customer login name. Can be generated automatically from the customer's email addrees if the option `woocommerce_registration_generate_username` is equal to `yes` cannot be changed maybe mandatory | +| `password` | string | Customer password. Can be generated automatically with [`wp_generate_password()`](http://codex.wordpress.org/Function_Reference/wp_generate_password) if the "Automatically generate customer password" option is enabled, check the index meta for `generate_password` write-only maybe mandatory | +| `last_order` | array | Last order data. See [Customer Last Order Properties](#customer-last-order-properties). read-only | +| `orders_count` | integer | Quantity of orders made by the customer. read-only | +| `total_spent` | float | Total amount spent. read-only | +| `avatar_url` | string | Avatar URL. | +| `billing_address` | array | List of billing address data. See [Billing Address Properties](#billing-address-properties). | +| `shipping_address` | array | List of shipping address data. See [Shipping Address Properties](#shipping-address-properties). | + +### Customer last order properties ### + +| Attribute | Type | Description | +|-----------|-----------|------------------------------------------------------------------------------------| +| `id` | integer | Last order ID. read-only | +| `date` | date-time | UTC DateTime of the customer last order. read-only | + +### Billing address properties ### + +| Attribute | Type | Description | +|--------------|--------|------------------------------------------------------| +| `first_name` | string | First name. | +| `last_name` | string | Last name. | +| `company` | string | Company name. | +| `address_1` | string | Address line 1. | +| `address_2` | string | Address line 2. | +| `city` | string | City name. | +| `state` | string | ISO code or name of the state, province or district. | +| `postcode` | string | Postal code. | +| `country` | string | ISO code of the country. | +| `email` | string | Email address. | +| `phone` | string | Phone number. | + +### Shipping address properties ### + +| Attribute | Type | Description | +|--------------|--------|------------------------------------------------------| +| `first_name` | string | First name. | +| `last_name` | string | Last name. | +| `company` | string | Company name. | +| `address_1` | string | Address line 1. | +| `address_2` | string | Address line 2. | +| `city` | string | City name. | +| `state` | string | ISO code or name of the state, province or district. | +| `postcode` | string | Postal code. | +| `country` | string | ISO code of the country. | + +## Create a customer ## + +This API helps you to create a new customer. + +### HTTP request ### + +
+
+ POST +
/wp-json/wc/v1/customers
+
+
+ +```shell +curl -X POST https://example.com/wp-json/wc/v1/customers \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "email": "john.doe@example.com", + "first_name": "John", + "last_name": "Doe", + "username": "john.doe", + "billing_address": { + "first_name": "John", + "last_name": "Doe", + "company": "", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US", + "email": "john.doe@example.com", + "phone": "(555) 555-5555" + }, + "shipping_address": { + "first_name": "John", + "last_name": "Doe", + "company": "", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US" + } +}' +``` + +```javascript +var data = { + email: 'john.doe@example.com', + first_name: 'John', + last_name: 'Doe', + username: 'john.doe', + billing_address: { + first_name: 'John', + last_name: 'Doe', + company: '', + address_1: '969 Market', + address_2: '', + city: 'San Francisco', + state: 'CA', + postcode: '94103', + country: 'US', + email: 'john.doe@example.com', + phone: '(555) 555-5555' + }, + shipping_address: { + first_name: 'John', + last_name: 'Doe', + company: '', + address_1: '969 Market', + address_2: '', + city: 'San Francisco', + state: 'CA', + postcode: '94103', + country: 'US' + } +}; + +WooCommerce.post('customers', data, function(err, data, res) { + console.log(res); +}); +``` + +```php + 'john.doe@example.com', + 'first_name' => 'John', + 'last_name' => 'Doe', + 'username' => 'john.doe', + 'billing_address' => [ + 'first_name' => 'John', + 'last_name' => 'Doe', + 'company' => '', + 'address_1' => '969 Market', + 'address_2' => '', + 'city' => 'San Francisco', + 'state' => 'CA', + 'postcode' => '94103', + 'country' => 'US', + 'email' => 'john.doe@example.com', + 'phone' => '(555) 555-5555' + ], + 'shipping_address' => [ + 'first_name' => 'John', + 'last_name' => 'Doe', + 'company' => '', + 'address_1' => '969 Market', + 'address_2' => '', + 'city' => 'San Francisco', + 'state' => 'CA', + 'postcode' => '94103', + 'country' => 'US' + ] +]; + +print_r($woocommerce->post('customers', $data)); +?> +``` + +```python +data = { + "email": "john.doe@example.com", + "first_name": "John", + "last_name": "Doe", + "username": "john.doe", + "billing_address": { + "first_name": "John", + "last_name": "Doe", + "company": "", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US", + "email": "john.doe@example.com", + "phone": "(555) 555-5555" + }, + "shipping_address": { + "first_name": "John", + "last_name": "Doe", + "company": "", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US" + } +} + +print(wcapi.post("customers", data).json()) +``` + +```ruby +data = { + email: "john.doe@example.com", + first_name: "John", + last_name: "Doe", + username: "john.doe", + billing_address: { + first_name: "John", + last_name: "Doe", + company: "", + address_1: "969 Market", + address_2: "", + city: "San Francisco", + state: "CA", + postcode: "94103", + country: "US", + email: "john.doe@example.com", + phone: "(555) 555-5555" + }, + shipping_address: { + first_name: "John", + last_name: "Doe", + company: "", + address_1: "969 Market", + address_2: "", + city: "San Francisco", + state: "CA", + postcode: "94103", + country: "US" + } +} + +woocommerce.post("customers", data).parsed_response +``` + +> JSON response example: + +```json +{ + "id": 2, + "date_created": "2016-05-03T17:58:35", + "date_modified": "2016-05-11T21:34:43", + "email": "john.doe@example.com", + "first_name": "John", + "last_name": "Doe", + "username": "john.doe", + "last_order": { + "id": 118, + "date": "2016-05-03T18:10:43" + }, + "orders_count": 3, + "total_spent": "28.00", + "avatar_url": "https://secure.gravatar.com/avatar/?s=96", + "billing_address": { + "first_name": "John", + "last_name": "Doe", + "company": "", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US", + "email": "john.doe@example.com", + "phone": "(555) 555-5555" + }, + "shipping_address": { + "first_name": "John", + "last_name": "Doe", + "company": "", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US" + }, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/customers/2" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/customers" + } + ] + } +} +``` + +## Retrieve a customer ## + +This API lets you retrieve and view a specific customer by ID or email. + +### HTTP request ### + +
+
+ GET +
/wp-json/wc/v1/customers/<id>
+
+
+ +```shell +curl https://example.com/wp-json/wc/v1/customers/2 \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('customers/2', function(err, data, res) { + console.log(res); +}); +``` + +```php +get('customers/2')); ?> +``` + +```python +print(wcapi.get("customers/2").json()) +``` + +```ruby +woocommerce.get("customers/2").parsed_response +``` + +> JSON response example: + +```json +{ + "id": 2, + "date_created": "2016-05-03T17:58:35", + "date_modified": "2016-05-11T21:34:43", + "email": "john.doe@example.com", + "first_name": "John", + "last_name": "Doe", + "username": "john.doe", + "last_order": { + "id": 118, + "date": "2016-05-03T18:10:43" + }, + "orders_count": 3, + "total_spent": "28.00", + "avatar_url": "https://secure.gravatar.com/avatar/?s=96", + "billing_address": { + "first_name": "John", + "last_name": "Doe", + "company": "", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US", + "email": "john.doe@example.com", + "phone": "(555) 555-5555" + }, + "shipping_address": { + "first_name": "John", + "last_name": "Doe", + "company": "", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US" + }, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/customers/2" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/customers" + } + ] + } +} +``` + +## List all customers ## + +This API helps you to view all the customers. + +### HTTP request ### + +
+
+ GET +
/wp-json/wc/v1/customers
+
+
+ +```shell +curl https://example.com/wp-json/wc/v1/customers \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('customers', function(err, data, res) { + console.log(res); +}); +``` + +```php +get('customers')); ?> +``` + +```python +print(wcapi.get("customers").json()) +``` + +```ruby +woocommerce.get("customers").parsed_response +``` + +> JSON response example: + +```json +[ + { + "id": 5, + "date_created": "2016-05-11T21:39:01", + "date_modified": "2016-05-11T21:40:02", + "email": "joao.silva@example.com", + "first_name": "João", + "last_name": "Silva", + "username": "joao.silva", + "last_order": { + "id": null, + "date": null + }, + "orders_count": 0, + "total_spent": "0.00", + "avatar_url": "https://secure.gravatar.com/avatar/?s=96", + "billing_address": { + "first_name": "João", + "last_name": "Silva", + "company": "", + "address_1": "Av. Brasil, 432", + "address_2": "", + "city": "Rio de Janeiro", + "state": "RJ", + "postcode": "12345-000", + "country": "BR", + "email": "joao.silva@example.com", + "phone": "(55) 5555-5555" + }, + "shipping_address": { + "first_name": "João", + "last_name": "Silva", + "company": "", + "address_1": "Av. Brasil, 432", + "address_2": "", + "city": "Rio de Janeiro", + "state": "RJ", + "postcode": "12345-000", + "country": "BR" + }, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/customers/5" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/customers" + } + ] + } + }, + { + "id": 2, + "date_created": "2016-05-03T17:58:35", + "date_modified": "2016-05-11T21:34:43", + "email": "john.doe@example.com", + "first_name": "John", + "last_name": "Doe", + "username": "john.doe", + "last_order": { + "id": 118, + "date": "2016-05-03T18:10:43" + }, + "orders_count": 3, + "total_spent": "28.00", + "avatar_url": "https://secure.gravatar.com/avatar/?s=96", + "billing_address": { + "first_name": "John", + "last_name": "Doe", + "company": "", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US", + "email": "john.doe@example.com", + "phone": "(555) 555-5555" + }, + "shipping_address": { + "first_name": "John", + "last_name": "Doe", + "company": "", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US" + }, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/customers/2" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/customers" + } + ] + } + } +] +``` + +#### Available parameters #### + +| Parameter | Type | Description | +|------------|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `context` | string | Scope under which the request is made; determines fields present in response. Options: `view` and `edit`. | +| `page` | integer | Current page of the collection. | +| `per_page` | integer | Maximum number of items to be returned in result set. | +| `search` | string | Limit results to those matching a string. | +| `exclude` | string | Ensure result set excludes specific ids. | +| `include` | string | Limit result set to specific ids. | +| `offset` | integer | Offset the result set by a specific number of items. | +| `order` | string | Order sort attribute ascending or descending. Default is `asc`, Options: `asc` and `desc`. | +| `orderby` | string | Sort collection by object attribute. Default is `name`. Options: `id`, `include`, `name` and `registered_date`. | +| `email` | string | Limit result set to resources with a specific email. | +| `role` | string | Limit result set to resources with a specific role. Default: `customer`. Options (some plugins can add more user roles): `all`, `administrator`, `editor`, `author`, `contributor`, `subscriber`, `customer` and `shop_manager` | + +## Update a customer ## + +This API lets you make changes to a customer. + +### HTTP request ### + +
+
+ PUT +
/wp-json/wc/v1/customers/<id>
+
+
+ +```shell +curl -X PUT https://example.com/wp-json/wc/v1/customers/2 \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "first_name": "James", + "billing_address": { + "first_name": "James" + }, + "shipping_address": { + "first_name": "James" + } +}' +``` + +```javascript +var data = { + first_name: 'James', + billing_address: { + first_name: 'James' + }, + shipping_address: { + first_name: 'James' + } +}; + +WooCommerce.put('customers/2', data, function(err, data, res) { + console.log(res); +}); +``` + +```php + 'James', + 'billing_address' => [ + 'first_name' => 'James' + ], + 'shipping_address' => [ + 'first_name' => 'James' + ] +]; + +print_r($woocommerce->put('customers/2', $data)); +?> +``` + +```python +data = { + "first_name": "James", + "billing_address": { + "first_name": "James" + }, + "shipping_address": { + "first_name": "James" + } +} + +print(wcapi.put("customers/2", data).json()) +``` + +```ruby +data = { + first_name: "James", + billing_address: { + first_name: "James" + }, + shipping_address: { + first_name: "James" + } +} + +woocommerce.put("customers/2", data).parsed_response +``` + +> JSON response example: + +```json +{ + "id": 2, + "date_created": "2016-05-03T17:58:35", + "date_modified": "2016-05-11T21:43:45", + "email": "john.doe@example.com", + "first_name": "James", + "last_name": "Doe", + "username": "john.doe", + "last_order": { + "id": 118, + "date": "2016-05-03T18:10:43" + }, + "orders_count": 3, + "total_spent": "28.00", + "avatar_url": "https://secure.gravatar.com/avatar/?s=96", + "billing_address": { + "first_name": "James", + "last_name": "Doe", + "company": "", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US", + "email": "john.doe@example.com", + "phone": "(555) 555-5555" + }, + "shipping_address": { + "first_name": "James", + "last_name": "Doe", + "company": "", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US" + }, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/customers/2" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/customers" + } + ] + } +} +``` + +## Delete a customer ## + +This API helps you delete a customer. + +### HTTP request ### + +
+
+ DELETE +
/wp-json/wc/v1/customers/<id>
+
+
+ +```shell +curl -X DELETE https://example.com/wp-json/wc/v1/customers/2?force=true \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.delete('customers/2?force=true', function(err, data, res) { + console.log(res); +}); +``` + +```php +delete('customers/2', ['force' => true])); ?> +``` + +```python +print(wcapi.delete("customers/2?force=true").json()) +``` + +```ruby +woocommerce.delete("customers/2", force: true).parsed_response +``` + +> JSON response example: + +```json +{ + "id": 2, + "date_created": "2016-05-03T17:58:35", + "date_modified": "2016-05-11T21:43:45", + "email": "john.doe@example.com", + "first_name": "James", + "last_name": "Doe", + "username": "john.doe", + "last_order": { + "id": 118, + "date": "2016-05-03T18:10:43" + }, + "orders_count": 3, + "total_spent": "28.00", + "avatar_url": "https://secure.gravatar.com/avatar/?s=96", + "billing_address": { + "first_name": "James", + "last_name": "Doe", + "company": "", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US", + "email": "john.doe@example.com", + "phone": "(555) 555-5555" + }, + "shipping_address": { + "first_name": "James", + "last_name": "Doe", + "company": "", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US" + }, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/customers/2" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/customers" + } + ] + } +} +``` + +#### Available parameters #### + +| Parameter | Type | Description | +|-----------|--------|---------------------------------------------------------------| +| `force` | string | Required to be `true`, as resource does not support trashing. | + +## Batch update customers ## + +This API helps you to batch create, update and delete multiple customers. + +### HTTP request ### + +
+
+ POST +
/wp-json/wc/v1/customers/batch
+
+
+ +```shell +curl -X POST https://example.com/wp-json/wc/v1/customers/batch \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "create": [ + { + "email": "john.doe2@example.com", + "first_name": "John", + "last_name": "Doe", + "username": "john.doe2", + "billing_address": { + "first_name": "John", + "last_name": "Doe", + "company": "", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US", + "email": "john.doe@example.com", + "phone": "(555) 555-5555" + }, + "shipping_address": { + "first_name": "John", + "last_name": "Doe", + "company": "", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US" + } + }, + { + "email": "joao.silva2@example.com", + "first_name": "João", + "last_name": "Silva", + "username": "joao.silva2", + "billing_address": { + "first_name": "João", + "last_name": "Silva", + "company": "", + "address_1": "Av. Brasil, 432", + "address_2": "", + "city": "Rio de Janeiro", + "state": "RJ", + "postcode": "12345-000", + "country": "BR", + "email": "joao.silva@example.com", + "phone": "(55) 5555-5555" + }, + "shipping_address": { + "first_name": "João", + "last_name": "Silva", + "company": "", + "address_1": "Av. Brasil, 432", + "address_2": "", + "city": "Rio de Janeiro", + "state": "RJ", + "postcode": "12345-000", + "country": "BR" + } + } + ], + "update": [ + { + "id": 5, + "billing_address": { + "phone": "(11) 1111-1111" + } + } + ], + "delete": [ + 2 + ] +}' +``` + +```javascript +var data = { + create: [ + { + email: 'john.doe2@example.com', + first_name: 'John', + last_name: 'Doe', + username: 'john.doe2', + billing_address: { + first_name: 'John', + last_name: 'Doe', + company: '', + address_1: '969 Market', + address_2: '', + city: 'San Francisco', + state: 'CA', + postcode: '94103', + country: 'US', + email: 'john.doe@example.com', + phone: '(555) 555-5555' + }, + shipping_address: { + first_name: 'John', + last_name: 'Doe', + company: '', + address_1: '969 Market', + address_2: '', + city: 'San Francisco', + state: 'CA', + postcode: '94103', + country: 'US' + } + }, + { + email: 'joao.silva2@example.com', + first_name: 'João', + last_name: 'Silva', + username: 'joao.silva2', + billing_address: { + first_name: 'João', + last_name: 'Silva', + company: '', + address_1: 'Av. Brasil, 432', + address_2: '', + city: 'Rio de Janeiro', + state: 'RJ', + postcode: '12345-000', + country: 'BR', + email: 'joao.silva@example.com', + phone: '(55) 5555-5555' + }, + shipping_address: { + first_name: 'João', + last_name: 'Silva', + company: '', + address_1: 'Av. Brasil, 432', + address_2: '', + city: 'Rio de Janeiro', + state: 'RJ', + postcode: '12345-000', + country: 'BR' + } + } + ], + update: [ + { + id: 5, + billing_address: { + phone: '(11) 1111-1111' + } + } + ], + delete: [ + 2 + ] +}; + +WooCommerce.post('customers/batch', data, function(err, data, res) { + console.log(res); +}); +``` + +```php +post('customers/batch', $data)); +?> +``` + +```python +data = { + "create": [ + { + "email": "john.doe2@example.com", + "first_name": "John", + "last_name": "Doe", + "username": "john.doe2", + "billing_address": { + "first_name": "John", + "last_name": "Doe", + "company": "", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US", + "email": "john.doe@example.com", + "phone": "(555) 555-5555" + }, + "shipping_address": { + "first_name": "John", + "last_name": "Doe", + "company": "", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US" + } + }, + { + "email": "joao.silva2@example.com", + "first_name": "João", + "last_name": "Silva", + "username": "joao.silva2", + "billing_address": { + "first_name": "João", + "last_name": "Silva", + "company": "", + "address_1": "Av. Brasil, 432", + "address_2": "", + "city": "Rio de Janeiro", + "state": "RJ", + "postcode": "12345-000", + "country": "BR", + "email": "joao.silva@example.com", + "phone": "(55) 5555-5555" + }, + "shipping_address": { + "first_name": "João", + "last_name": "Silva", + "company": "", + "address_1": "Av. Brasil, 432", + "address_2": "", + "city": "Rio de Janeiro", + "state": "RJ", + "postcode": "12345-000", + "country": "BR" + } + } + ], + "update": [ + { + "id": 5, + "billing_address": { + "phone": "(11) 1111-1111" + } + } + ], + "delete": [ + 2 + ] +} + +print(wcapi.post("customers/batch", data).json()) +``` + +```ruby +data = { + create: [ + { + email: "john.doe2@example.com", + first_name: "John", + last_name: "Doe", + username: "john.doe2", + billing_address: { + first_name: "John", + last_name: "Doe", + company: "", + address_1: "969 Market", + address_2: "", + city: "San Francisco", + state: "CA", + postcode: "94103", + country: "US", + email: "john.doe@example.com", + phone: "(555) 555-5555" + }, + shipping_address: { + first_name: "John", + last_name: "Doe", + company: "", + address_1: "969 Market", + address_2: "", + city: "San Francisco", + state: "CA", + postcode: "94103", + country: "US" + } + }, + { + email: "joao.silva2@example.com", + first_name: "João", + last_name: "Silva", + username: "joao.silva2", + billing_address: { + first_name: "João", + last_name: "Silva", + company: "", + address_1: "Av. Brasil, 432", + address_2: "", + city: "Rio de Janeiro", + state: "RJ", + postcode: "12345-000", + country: "BR", + email: "joao.silva@example.com", + phone: "(55) 5555-5555" + }, + shipping_address: { + first_name: "João", + last_name: "Silva", + company: "", + address_1: "Av. Brasil, 432", + address_2: "", + city: "Rio de Janeiro", + state: "RJ", + postcode: "12345-000", + country: "BR" + } + } + ], + update: [ + { + id: 5, + billing_address: { + phone: "(11) 1111-1111" + } + } + ], + delete: [ + 2 + ] +} + +woocommerce.post("customers/batch", data).parsed_response +``` + +> JSON response example: + +```json +{ + "create": [ + { + "id": 6, + "date_created": "2016-05-11T22:06:32", + "date_modified": "2016-05-11T22:07:31", + "email": "john.doe2@example.com", + "first_name": "John", + "last_name": "Doe", + "username": "john.doe2", + "last_order": { + "id": null, + "date": null + }, + "orders_count": 0, + "total_spent": "0.00", + "avatar_url": "https://secure.gravatar.com/avatar/?s=96", + "billing_address": { + "first_name": "John", + "last_name": "Doe", + "company": "", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US", + "email": "john.doe@example.com", + "phone": "(555) 555-5555" + }, + "shipping_address": { + "first_name": "John", + "last_name": "Doe", + "company": "", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US" + }, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/customers/6" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/customers" + } + ] + } + }, + { + "id": 7, + "date_created": "2016-05-11T22:07:33", + "date_modified": "2016-05-11T22:07:37", + "email": "joao.silva2@example.com", + "first_name": "João", + "last_name": "Silva", + "username": "joao.silva2", + "last_order": { + "id": null, + "date": null + }, + "orders_count": 0, + "total_spent": "0.00", + "avatar_url": "https://secure.gravatar.com/avatar/?s=96", + "billing_address": { + "first_name": "João", + "last_name": "Silva", + "company": "", + "address_1": "Av. Brasil, 432", + "address_2": "", + "city": "Rio de Janeiro", + "state": "RJ", + "postcode": "12345-000", + "country": "BR", + "email": "joao.silva@example.com", + "phone": "(55) 5555-5555" + }, + "shipping_address": { + "first_name": "João", + "last_name": "Silva", + "company": "", + "address_1": "Av. Brasil, 432", + "address_2": "", + "city": "Rio de Janeiro", + "state": "RJ", + "postcode": "12345-000", + "country": "BR" + }, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/customers/7" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/customers" + } + ] + } + } + ], + "update": [ + { + "id": 5, + "date_created": "2016-05-11T21:39:01", + "date_modified": "2016-05-11T22:04:36", + "email": "joao.silva@example.com", + "first_name": "João", + "last_name": "Silva", + "username": "joao.silva", + "last_order": { + "id": null, + "date": null + }, + "orders_count": 0, + "total_spent": "0.00", + "avatar_url": "https://secure.gravatar.com/avatar/?s=96", + "billing_address": { + "first_name": "João", + "last_name": "Silva", + "company": "", + "address_1": "Av. Brasil, 432", + "address_2": "", + "city": "Rio de Janeiro", + "state": "RJ", + "postcode": "12345-000", + "country": "BR", + "email": "joao.silva@example.com", + "phone": "(11) 1111-1111" + }, + "shipping_address": { + "first_name": "João", + "last_name": "Silva", + "company": "", + "address_1": "Av. Brasil, 432", + "address_2": "", + "city": "Rio de Janeiro", + "state": "RJ", + "postcode": "12345-000", + "country": "BR" + }, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/customers/5" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/customers" + } + ] + } + } + ], + "delete": [ + { + "id": 2, + "date_created": "2016-05-03T17:58:35", + "date_modified": "2016-05-11T21:43:45", + "email": "john.doe@example.com", + "first_name": "James", + "last_name": "Doe", + "username": "john.doe", + "last_order": { + "id": 118, + "date": "2016-05-03T18:10:43" + }, + "orders_count": 3, + "total_spent": "28.00", + "avatar_url": "https://secure.gravatar.com/avatar/?s=96", + "billing_address": { + "first_name": "James", + "last_name": "Doe", + "company": "", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US", + "email": "john.doe@example.com", + "phone": "(555) 555-5555" + }, + "shipping_address": { + "first_name": "James", + "last_name": "Doe", + "company": "", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US" + }, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/customers/2" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/customers" + } + ] + } + } + ] +} +``` + +## Retrieve customer downloads ## + +This API lets you retrieve customer downloads permissions. + +### HTTP request ### + +
+
+ GET +
/wp-json/wc/v1/customers/<id>/downloads
+
+
+ +```shell +curl https://example.com/wp-json/wc/v1/customers/2/downloads \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('customers/2/downloads', function(err, data, res) { + console.log(res); +}); +``` + +```php +get('customers/2/downloads')); ?> +``` + +```python +print(wcapi.get("customers/2/downloads").json()) +``` + +```ruby +woocommerce.get("customers/2/downloads").parsed_response +``` + +> JSON response example: + +```json +[ + { + "download_url": "https://example.com/?download_file=96&order=wc_order_571a7260c0da5&email=john.dow@xanmple.com&key=1789931e0c14ad9909a50c826f10c169", + "download_id": "1789931e0c14ad9909a50c826f10c169", + "product_id": 96, + "download_name": "Woo Album #4 – Testing", + "order_id": 105, + "order_key": "wc_order_571a7260c0da5", + "downloads_remaining": "unlimited", + "access_expires": "never", + "file": { + "name": "Testing", + "file": "http://example.com/wp-content/uploads/2013/06/cd_5_angle.jpg" + }, + "_links": { + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/customers/1/downloads" + } + ], + "product": [ + { + "href": "https://example.com/wp-json/wc/v1/products/96" + } + ], + "order": [ + { + "href": "https://example.com/wp-json/wc/v1/orders/105" + } + ] + } + } +] +``` + +### Customer downloads properties ### + +| Attribute | Type | Description | +|-----------------------|---------|------------------------------------------------------------------------------------------------------------------| +| `download_url` | string | Download file URL. read-only | +| `download_id` | string | Download ID (MD5). read-only | +| `product_id` | integer | Downloadable product ID. read-only | +| `download_name` | string | Downloadable file name. read-only | +| `order_id` | integer | Order ID. read-only | +| `order_key` | string | Order key. read-only | +| `downloads_remaining` | string | Amount of downloads remaining. read-only | +| `access_expires` | string | The date when the download access expires, in the site's timezone. read-only | +| `file` | array | File details with `name` (file name) and `file` (file URL) attributes. read-only | diff --git a/source/includes/wp-api-v1/_index.md b/source/includes/wp-api-v1/_index.md new file mode 100644 index 00000000..5ff3dfa6 --- /dev/null +++ b/source/includes/wp-api-v1/_index.md @@ -0,0 +1,4618 @@ +# Index # + +By default, the API provides information about all available endpoints on the site. Authentication is not required to access the API index. + +### HTTP request ### + +
+
+ GET +
/wp-json/wc/v1
+
+
+ +```shell +curl https://example.com/wp-json/wc/v1 +``` + +```javascript +WooCommerce.get('', function(err, data, res) { + console.log(res); +}); +``` + +```php +get('')); ?> +``` + +```python +print(wcapi.get("").json()) +``` + +```ruby +woocommerce.get("").parsed_response +``` + +> JSON response example: + +```json +{ + "namespace": "wc/v1", + "routes": { + "/wc/v1": { + "namespace": "wc/v1", + "methods": [ + "GET" + ], + "endpoints": [ + { + "methods": [ + "GET" + ], + "args": { + "namespace": { + "required": false, + "default": "wc/v1" + }, + "context": { + "required": false, + "default": "view" + } + } + } + ], + "_links": { + "self": "https://example.com/wp-json/wc/v1" + } + }, + "/wc/v1/coupons": { + "namespace": "wc/v1", + "methods": [ + "GET", + "POST" + ], + "endpoints": [ + { + "methods": [ + "GET" + ], + "args": { + "context": { + "required": false, + "default": "view", + "enum": [ + "view", + "edit" + ], + "description": "Scope under which the request is made; determines fields present in response." + }, + "page": { + "required": false, + "default": 1, + "description": "Current page of the collection." + }, + "per_page": { + "required": false, + "default": 10, + "description": "Maximum number of items to be returned in result set." + }, + "search": { + "required": false, + "description": "Limit results to those matching a string." + }, + "after": { + "required": false, + "description": "Limit response to resources published after a given ISO8601 compliant date." + }, + "before": { + "required": false, + "description": "Limit response to resources published before a given ISO8601 compliant date." + }, + "exclude": { + "required": false, + "default": [], + "description": "Ensure result set excludes specific ids." + }, + "include": { + "required": false, + "default": [], + "description": "Limit result set to specific ids." + }, + "offset": { + "required": false, + "description": "Offset the result set by a specific number of items." + }, + "order": { + "required": false, + "default": "desc", + "enum": [ + "asc", + "desc" + ], + "description": "Order sort attribute ascending or descending." + }, + "orderby": { + "required": false, + "default": "date", + "enum": [ + "date", + "id", + "include", + "title", + "slug" + ], + "description": "Sort collection by object attribute." + }, + "slug": { + "required": false, + "description": "Limit result set to posts with a specific slug." + }, + "filter": { + "required": false, + "description": "Use WP Query arguments to modify the response; private query vars require appropriate authorization." + }, + "code": { + "required": false, + "description": "Limit result set to resources with a specific code." + } + } + }, + { + "methods": [ + "POST" + ], + "args": { + "code": { + "required": true + }, + "description": { + "required": false, + "description": "Coupon description." + }, + "discount_type": { + "required": false, + "default": "fixed_cart", + "enum": [ + "fixed_cart", + "percent", + "fixed_product", + "percent_product" + ], + "description": "Determines the type of discount that will be applied." + }, + "amount": { + "required": false, + "description": "The amount of discount." + }, + "expiry_date": { + "required": false, + "description": "UTC DateTime when the coupon expires." + }, + "individual_use": { + "required": false, + "default": false, + "description": "Whether coupon can only be used individually." + }, + "product_ids": { + "required": false, + "description": "List of product ID's the coupon can be used on." + }, + "exclude_product_ids": { + "required": false, + "description": "List of product ID's the coupon cannot be used on." + }, + "usage_limit": { + "required": false, + "description": "How many times the coupon can be used." + }, + "usage_limit_per_user": { + "required": false, + "description": "How many times the coupon can be used per customer." + }, + "limit_usage_to_x_items": { + "required": false, + "description": "Max number of items in the cart the coupon can be applied to." + }, + "free_shipping": { + "required": false, + "default": false, + "description": "Define if can be applied for free shipping." + }, + "product_categories": { + "required": false, + "description": "List of category ID's the coupon applies to." + }, + "excluded_product_categories": { + "required": false, + "description": "List of category ID's the coupon does not apply to." + }, + "exclude_sale_items": { + "required": false, + "default": false, + "description": "Define if should not apply when have sale items." + }, + "minimum_amount": { + "required": false, + "description": "Minimum order amount that needs to be in the cart before coupon applies." + }, + "maximum_amount": { + "required": false, + "description": "Maximum order amount allowed when using the coupon." + }, + "email_restrictions": { + "required": false, + "description": "List of email addresses that can use this coupon." + } + } + } + ], + "_links": { + "self": "https://example.com/wp-json/wc/v1/coupons" + } + }, + "/wc/v1/coupons/(?P[\\d]+)": { + "namespace": "wc/v1", + "methods": [ + "GET", + "POST", + "PUT", + "PATCH", + "DELETE" + ], + "endpoints": [ + { + "methods": [ + "GET" + ], + "args": { + "context": { + "required": false, + "default": "view", + "enum": [ + "view", + "edit" + ], + "description": "Scope under which the request is made; determines fields present in response." + } + } + }, + { + "methods": [ + "POST", + "PUT", + "PATCH" + ], + "args": { + "code": { + "required": false, + "description": "Coupon code." + }, + "description": { + "required": false, + "description": "Coupon description." + }, + "discount_type": { + "required": false, + "enum": [ + "fixed_cart", + "percent", + "fixed_product", + "percent_product" + ], + "description": "Determines the type of discount that will be applied." + }, + "amount": { + "required": false, + "description": "The amount of discount." + }, + "expiry_date": { + "required": false, + "description": "UTC DateTime when the coupon expires." + }, + "individual_use": { + "required": false, + "description": "Whether coupon can only be used individually." + }, + "product_ids": { + "required": false, + "description": "List of product ID's the coupon can be used on." + }, + "exclude_product_ids": { + "required": false, + "description": "List of product ID's the coupon cannot be used on." + }, + "usage_limit": { + "required": false, + "description": "How many times the coupon can be used." + }, + "usage_limit_per_user": { + "required": false, + "description": "How many times the coupon can be used per customer." + }, + "limit_usage_to_x_items": { + "required": false, + "description": "Max number of items in the cart the coupon can be applied to." + }, + "free_shipping": { + "required": false, + "description": "Define if can be applied for free shipping." + }, + "product_categories": { + "required": false, + "description": "List of category ID's the coupon applies to." + }, + "excluded_product_categories": { + "required": false, + "description": "List of category ID's the coupon does not apply to." + }, + "exclude_sale_items": { + "required": false, + "description": "Define if should not apply when have sale items." + }, + "minimum_amount": { + "required": false, + "description": "Minimum order amount that needs to be in the cart before coupon applies." + }, + "maximum_amount": { + "required": false, + "description": "Maximum order amount allowed when using the coupon." + }, + "email_restrictions": { + "required": false, + "description": "List of email addresses that can use this coupon." + } + } + }, + { + "methods": [ + "DELETE" + ], + "args": { + "force": { + "required": false, + "default": false, + "description": "Whether to bypass trash and force deletion." + } + } + } + ] + }, + "/wc/v1/coupons/batch": { + "namespace": "wc/v1", + "methods": [ + "POST", + "PUT", + "PATCH" + ], + "endpoints": [ + { + "methods": [ + "POST", + "PUT", + "PATCH" + ], + "args": { + "code": { + "required": false, + "description": "Coupon code." + }, + "description": { + "required": false, + "description": "Coupon description." + }, + "discount_type": { + "required": false, + "enum": [ + "fixed_cart", + "percent", + "fixed_product", + "percent_product" + ], + "description": "Determines the type of discount that will be applied." + }, + "amount": { + "required": false, + "description": "The amount of discount." + }, + "expiry_date": { + "required": false, + "description": "UTC DateTime when the coupon expires." + }, + "individual_use": { + "required": false, + "description": "Whether coupon can only be used individually." + }, + "product_ids": { + "required": false, + "description": "List of product ID's the coupon can be used on." + }, + "exclude_product_ids": { + "required": false, + "description": "List of product ID's the coupon cannot be used on." + }, + "usage_limit": { + "required": false, + "description": "How many times the coupon can be used." + }, + "usage_limit_per_user": { + "required": false, + "description": "How many times the coupon can be used per customer." + }, + "limit_usage_to_x_items": { + "required": false, + "description": "Max number of items in the cart the coupon can be applied to." + }, + "free_shipping": { + "required": false, + "description": "Define if can be applied for free shipping." + }, + "product_categories": { + "required": false, + "description": "List of category ID's the coupon applies to." + }, + "excluded_product_categories": { + "required": false, + "description": "List of category ID's the coupon does not apply to." + }, + "exclude_sale_items": { + "required": false, + "description": "Define if should not apply when have sale items." + }, + "minimum_amount": { + "required": false, + "description": "Minimum order amount that needs to be in the cart before coupon applies." + }, + "maximum_amount": { + "required": false, + "description": "Maximum order amount allowed when using the coupon." + }, + "email_restrictions": { + "required": false, + "description": "List of email addresses that can use this coupon." + } + } + } + ], + "_links": { + "self": "https://example.com/wp-json/wc/v1/coupons/batch" + } + }, + "/wc/v1/customers/(?P[\\d]+)/downloads": { + "namespace": "wc/v1", + "methods": [ + "GET" + ], + "endpoints": [ + { + "methods": [ + "GET" + ], + "args": { + "context": { + "required": false, + "default": "view", + "enum": [ + "view" + ], + "description": "Scope under which the request is made; determines fields present in response." + } + } + } + ] + }, + "/wc/v1/customers": { + "namespace": "wc/v1", + "methods": [ + "GET", + "POST" + ], + "endpoints": [ + { + "methods": [ + "GET" + ], + "args": { + "context": { + "required": false, + "default": "view", + "enum": [ + "view", + "edit" + ], + "description": "Scope under which the request is made; determines fields present in response." + }, + "page": { + "required": false, + "default": 1, + "description": "Current page of the collection." + }, + "per_page": { + "required": false, + "default": 10, + "description": "Maximum number of items to be returned in result set." + }, + "search": { + "required": false, + "description": "Limit results to those matching a string." + }, + "exclude": { + "required": false, + "default": [], + "description": "Ensure result set excludes specific ids." + }, + "include": { + "required": false, + "default": [], + "description": "Limit result set to specific ids." + }, + "offset": { + "required": false, + "description": "Offset the result set by a specific number of items." + }, + "order": { + "required": false, + "default": "asc", + "enum": [ + "asc", + "desc" + ], + "description": "Order sort attribute ascending or descending." + }, + "orderby": { + "required": false, + "default": "name", + "enum": [ + "id", + "include", + "name", + "registered_date" + ], + "description": "Sort collection by object attribute." + }, + "email": { + "required": false, + "description": "Limit result set to resources with a specific email." + }, + "role": { + "required": false, + "default": "customer", + "enum": [ + "all", + "administrator", + "editor", + "author", + "contributor", + "subscriber", + "customer", + "shop_manager" + ], + "description": "Limit result set to resources with a specific role." + } + } + }, + { + "methods": [ + "POST" + ], + "args": { + "email": { + "required": true + }, + "first_name": { + "required": false, + "description": "Customer first name." + }, + "last_name": { + "required": false, + "description": "Customer last name." + }, + "username": { + "required": false + }, + "password": { + "required": true + }, + "billing_address": { + "required": false, + "description": "List of billing address data." + }, + "shipping_address": { + "required": false, + "description": "List of shipping address data." + } + } + } + ], + "_links": { + "self": "https://example.com/wp-json/wc/v1/customers" + } + }, + "/wc/v1/customers/(?P[\\d]+)": { + "namespace": "wc/v1", + "methods": [ + "GET", + "POST", + "PUT", + "PATCH", + "DELETE" + ], + "endpoints": [ + { + "methods": [ + "GET" + ], + "args": { + "context": { + "required": false, + "default": "view", + "enum": [ + "view", + "edit" + ], + "description": "Scope under which the request is made; determines fields present in response." + } + } + }, + { + "methods": [ + "POST", + "PUT", + "PATCH" + ], + "args": { + "email": { + "required": false, + "description": "The email address for the customer." + }, + "first_name": { + "required": false, + "description": "Customer first name." + }, + "last_name": { + "required": false, + "description": "Customer last name." + }, + "username": { + "required": false, + "description": "Customer login name." + }, + "password": { + "required": false, + "description": "Customer password." + }, + "billing_address": { + "required": false, + "description": "List of billing address data." + }, + "shipping_address": { + "required": false, + "description": "List of shipping address data." + } + } + }, + { + "methods": [ + "DELETE" + ], + "args": { + "force": { + "required": false, + "default": false, + "description": "Required to be true, as resource does not support trashing." + }, + "reassign": { + "required": false + } + } + } + ] + }, + "/wc/v1/customers/batch": { + "namespace": "wc/v1", + "methods": [ + "POST", + "PUT", + "PATCH" + ], + "endpoints": [ + { + "methods": [ + "POST", + "PUT", + "PATCH" + ], + "args": { + "email": { + "required": false, + "description": "The email address for the customer." + }, + "first_name": { + "required": false, + "description": "Customer first name." + }, + "last_name": { + "required": false, + "description": "Customer last name." + }, + "username": { + "required": false, + "description": "Customer login name." + }, + "password": { + "required": false, + "description": "Customer password." + }, + "billing_address": { + "required": false, + "description": "List of billing address data." + }, + "shipping_address": { + "required": false, + "description": "List of shipping address data." + } + } + } + ], + "_links": { + "self": "https://example.com/wp-json/wc/v1/customers/batch" + } + }, + "/wc/v1/orders/(?P[\\d]+)/notes": { + "namespace": "wc/v1", + "methods": [ + "GET", + "POST" + ], + "endpoints": [ + { + "methods": [ + "GET" + ], + "args": { + "context": { + "required": false, + "default": "view", + "enum": [ + "view", + "edit" + ], + "description": "Scope under which the request is made; determines fields present in response." + } + } + }, + { + "methods": [ + "POST" + ], + "args": { + "note": { + "required": true + }, + "customer_note": { + "required": false, + "default": false, + "description": "Shows/define if the note is only for reference or for the customer (the user will be notified)." + } + } + } + ] + }, + "/wc/v1/orders/(?P[\\d]+)/notes/(?P[\\d]+)": { + "namespace": "wc/v1", + "methods": [ + "GET", + "DELETE" + ], + "endpoints": [ + { + "methods": [ + "GET" + ], + "args": { + "context": { + "required": false, + "default": "view", + "enum": [ + "view", + "edit" + ], + "description": "Scope under which the request is made; determines fields present in response." + } + } + }, + { + "methods": [ + "DELETE" + ], + "args": { + "force": { + "required": false, + "default": false, + "description": "Required to be true, as resource does not support trashing." + } + } + } + ] + }, + "/wc/v1/orders/(?P[\\d]+)/refunds": { + "namespace": "wc/v1", + "methods": [ + "GET", + "POST" + ], + "endpoints": [ + { + "methods": [ + "GET" + ], + "args": { + "context": { + "required": false, + "default": "view", + "enum": [ + "view", + "edit" + ], + "description": "Scope under which the request is made; determines fields present in response." + }, + "page": { + "required": false, + "default": 1, + "description": "Current page of the collection." + }, + "per_page": { + "required": false, + "default": 10, + "description": "Maximum number of items to be returned in result set." + }, + "search": { + "required": false, + "description": "Limit results to those matching a string." + }, + "after": { + "required": false, + "description": "Limit response to resources published after a given ISO8601 compliant date." + }, + "before": { + "required": false, + "description": "Limit response to resources published before a given ISO8601 compliant date." + }, + "exclude": { + "required": false, + "default": [], + "description": "Ensure result set excludes specific ids." + }, + "include": { + "required": false, + "default": [], + "description": "Limit result set to specific ids." + }, + "offset": { + "required": false, + "description": "Offset the result set by a specific number of items." + }, + "order": { + "required": false, + "default": "desc", + "enum": [ + "asc", + "desc" + ], + "description": "Order sort attribute ascending or descending." + }, + "orderby": { + "required": false, + "default": "date", + "enum": [ + "date", + "id", + "include", + "title", + "slug" + ], + "description": "Sort collection by object attribute." + }, + "slug": { + "required": false, + "description": "Limit result set to posts with a specific slug." + }, + "filter": { + "required": false, + "description": "Use WP Query arguments to modify the response; private query vars require appropriate authorization." + }, + "dp": { + "required": false, + "default": 2, + "description": "Number of decimal points to use in each resource." + } + } + }, + { + "methods": [ + "POST" + ], + "args": { + "amount": { + "required": false, + "description": "Refund amount." + }, + "reason": { + "required": false, + "description": "Reason for refund" + }, + "line_items": { + "required": false, + "description": "Line items data." + }, + "email": { + "required": true + } + } + } + ] + }, + "/wc/v1/orders/(?P[\\d]+)/refunds/(?P[\\d]+)": { + "namespace": "wc/v1", + "methods": [ + "GET", + "DELETE" + ], + "endpoints": [ + { + "methods": [ + "GET" + ], + "args": { + "context": { + "required": false, + "default": "view", + "enum": [ + "view", + "edit" + ], + "description": "Scope under which the request is made; determines fields present in response." + } + } + }, + { + "methods": [ + "DELETE" + ], + "args": { + "force": { + "required": false, + "default": false, + "description": "Required to be true, as resource does not support trashing." + }, + "reassign": { + "required": false + } + } + } + ] + }, + "/wc/v1/orders": { + "namespace": "wc/v1", + "methods": [ + "GET", + "POST" + ], + "endpoints": [ + { + "methods": [ + "GET" + ], + "args": { + "context": { + "required": false, + "default": "view", + "enum": [ + "view", + "edit" + ], + "description": "Scope under which the request is made; determines fields present in response." + }, + "page": { + "required": false, + "default": 1, + "description": "Current page of the collection." + }, + "per_page": { + "required": false, + "default": 10, + "description": "Maximum number of items to be returned in result set." + }, + "search": { + "required": false, + "description": "Limit results to those matching a string." + }, + "after": { + "required": false, + "description": "Limit response to resources published after a given ISO8601 compliant date." + }, + "before": { + "required": false, + "description": "Limit response to resources published before a given ISO8601 compliant date." + }, + "exclude": { + "required": false, + "default": [], + "description": "Ensure result set excludes specific ids." + }, + "include": { + "required": false, + "default": [], + "description": "Limit result set to specific ids." + }, + "offset": { + "required": false, + "description": "Offset the result set by a specific number of items." + }, + "order": { + "required": false, + "default": "desc", + "enum": [ + "asc", + "desc" + ], + "description": "Order sort attribute ascending or descending." + }, + "orderby": { + "required": false, + "default": "date", + "enum": [ + "date", + "id", + "include", + "title", + "slug" + ], + "description": "Sort collection by object attribute." + }, + "slug": { + "required": false, + "description": "Limit result set to posts with a specific slug." + }, + "filter": { + "required": false, + "description": "Use WP Query arguments to modify the response; private query vars require appropriate authorization." + }, + "status": { + "required": false, + "default": "any", + "enum": [ + "any", + "pending", + "processing", + "on-hold", + "completed", + "cancelled", + "refunded", + "failed" + ], + "description": "Limit result set to orders assigned a specific status." + }, + "customer": { + "required": false, + "description": "Limit result set to orders assigned a specific customer." + }, + "product": { + "required": false, + "description": "Limit result set to orders assigned a specific product." + }, + "dp": { + "required": false, + "default": 2, + "description": "Number of decimal points to use in each resource." + } + } + }, + { + "methods": [ + "POST" + ], + "args": { + "parent_id": { + "required": false, + "description": "Parent order ID." + }, + "status": { + "required": false, + "default": "pending", + "enum": [ + "pending", + "processing", + "on-hold", + "completed", + "cancelled", + "refunded", + "failed" + ], + "description": "Order status." + }, + "currency": { + "required": false, + "default": "BRL", + "enum": [ + "AED", + "AFN", + "ALL", + "AMD", + "ANG", + "AOA", + "ARS", + "AUD", + "AWG", + "AZN", + "BAM", + "BBD", + "BDT", + "BGN", + "BHD", + "BIF", + "BMD", + "BND", + "BOB", + "BRL", + "BSD", + "BTC", + "BTN", + "BWP", + "BYR", + "BZD", + "CAD", + "CDF", + "CHF", + "CLP", + "CNY", + "COP", + "CRC", + "CUC", + "CUP", + "CVE", + "CZK", + "DJF", + "DKK", + "DOP", + "DZD", + "EGP", + "ERN", + "ETB", + "EUR", + "FJD", + "FKP", + "GBP", + "GEL", + "GGP", + "GHS", + "GIP", + "GMD", + "GNF", + "GTQ", + "GYD", + "HKD", + "HNL", + "HRK", + "HTG", + "HUF", + "IDR", + "ILS", + "IMP", + "INR", + "IQD", + "IRR", + "ISK", + "JEP", + "JMD", + "JOD", + "JPY", + "KES", + "KGS", + "KHR", + "KMF", + "KPW", + "KRW", + "KWD", + "KYD", + "KZT", + "LAK", + "LBP", + "LKR", + "LRD", + "LSL", + "LYD", + "MAD", + "MDL", + "MGA", + "MKD", + "MMK", + "MNT", + "MOP", + "MRO", + "MUR", + "MVR", + "MWK", + "MXN", + "MYR", + "MZN", + "NAD", + "NGN", + "NIO", + "NOK", + "NPR", + "NZD", + "OMR", + "PAB", + "PEN", + "PGK", + "PHP", + "PKR", + "PLN", + "PRB", + "PYG", + "QAR", + "RON", + "RSD", + "RUB", + "RWF", + "SAR", + "SBD", + "SCR", + "SDG", + "SEK", + "SGD", + "SHP", + "SLL", + "SOS", + "SRD", + "SSP", + "STD", + "SYP", + "SZL", + "THB", + "TJS", + "TMT", + "TND", + "TOP", + "TRY", + "TTD", + "TWD", + "TZS", + "UAH", + "UGX", + "USD", + "UYU", + "UZS", + "VEF", + "VND", + "VUV", + "WST", + "XAF", + "XCD", + "XOF", + "XPF", + "YER", + "ZAR", + "ZMW" + ], + "description": "Currency the order was created with, in ISO format." + }, + "customer_id": { + "required": false, + "default": 0, + "description": "User ID who owns the order. 0 for guests." + }, + "billing": { + "required": false, + "description": "Billing address." + }, + "shipping": { + "required": false, + "description": "Shipping address." + }, + "payment_method": { + "required": false, + "description": "Payment method ID." + }, + "payment_method_title": { + "required": false, + "description": "Payment method title." + }, + "set_paid": { + "required": false, + "default": false, + "description": "Define if the order is paid. It will set the status to processing and reduce stock items." + }, + "transaction_id": { + "required": false, + "description": "Unique transaction ID." + }, + "customer_note": { + "required": false, + "description": "Note left by customer during checkout." + }, + "line_items": { + "required": false, + "description": "Line items data." + }, + "shipping_lines": { + "required": false, + "description": "Shipping lines data." + }, + "fee_lines": { + "required": false, + "description": "Fee lines data." + }, + "coupon_lines": { + "required": false, + "description": "Coupons line data." + } + } + } + ], + "_links": { + "self": "https://example.com/wp-json/wc/v1/orders" + } + }, + "/wc/v1/orders/(?P[\\d]+)": { + "namespace": "wc/v1", + "methods": [ + "GET", + "POST", + "PUT", + "PATCH", + "DELETE" + ], + "endpoints": [ + { + "methods": [ + "GET" + ], + "args": { + "context": { + "required": false, + "default": "view", + "enum": [ + "view", + "edit" + ], + "description": "Scope under which the request is made; determines fields present in response." + } + } + }, + { + "methods": [ + "POST", + "PUT", + "PATCH" + ], + "args": { + "parent_id": { + "required": false, + "description": "Parent order ID." + }, + "status": { + "required": false, + "enum": [ + "pending", + "processing", + "on-hold", + "completed", + "cancelled", + "refunded", + "failed" + ], + "description": "Order status." + }, + "currency": { + "required": false, + "enum": [ + "AED", + "AFN", + "ALL", + "AMD", + "ANG", + "AOA", + "ARS", + "AUD", + "AWG", + "AZN", + "BAM", + "BBD", + "BDT", + "BGN", + "BHD", + "BIF", + "BMD", + "BND", + "BOB", + "BRL", + "BSD", + "BTC", + "BTN", + "BWP", + "BYR", + "BZD", + "CAD", + "CDF", + "CHF", + "CLP", + "CNY", + "COP", + "CRC", + "CUC", + "CUP", + "CVE", + "CZK", + "DJF", + "DKK", + "DOP", + "DZD", + "EGP", + "ERN", + "ETB", + "EUR", + "FJD", + "FKP", + "GBP", + "GEL", + "GGP", + "GHS", + "GIP", + "GMD", + "GNF", + "GTQ", + "GYD", + "HKD", + "HNL", + "HRK", + "HTG", + "HUF", + "IDR", + "ILS", + "IMP", + "INR", + "IQD", + "IRR", + "ISK", + "JEP", + "JMD", + "JOD", + "JPY", + "KES", + "KGS", + "KHR", + "KMF", + "KPW", + "KRW", + "KWD", + "KYD", + "KZT", + "LAK", + "LBP", + "LKR", + "LRD", + "LSL", + "LYD", + "MAD", + "MDL", + "MGA", + "MKD", + "MMK", + "MNT", + "MOP", + "MRO", + "MUR", + "MVR", + "MWK", + "MXN", + "MYR", + "MZN", + "NAD", + "NGN", + "NIO", + "NOK", + "NPR", + "NZD", + "OMR", + "PAB", + "PEN", + "PGK", + "PHP", + "PKR", + "PLN", + "PRB", + "PYG", + "QAR", + "RON", + "RSD", + "RUB", + "RWF", + "SAR", + "SBD", + "SCR", + "SDG", + "SEK", + "SGD", + "SHP", + "SLL", + "SOS", + "SRD", + "SSP", + "STD", + "SYP", + "SZL", + "THB", + "TJS", + "TMT", + "TND", + "TOP", + "TRY", + "TTD", + "TWD", + "TZS", + "UAH", + "UGX", + "USD", + "UYU", + "UZS", + "VEF", + "VND", + "VUV", + "WST", + "XAF", + "XCD", + "XOF", + "XPF", + "YER", + "ZAR", + "ZMW" + ], + "description": "Currency the order was created with, in ISO format." + }, + "customer_id": { + "required": false, + "description": "User ID who owns the order. 0 for guests." + }, + "billing": { + "required": false, + "description": "Billing address." + }, + "shipping": { + "required": false, + "description": "Shipping address." + }, + "payment_method": { + "required": false, + "description": "Payment method ID." + }, + "payment_method_title": { + "required": false, + "description": "Payment method title." + }, + "set_paid": { + "required": false, + "description": "Define if the order is paid. It will set the status to processing and reduce stock items." + }, + "transaction_id": { + "required": false, + "description": "Unique transaction ID." + }, + "customer_note": { + "required": false, + "description": "Note left by customer during checkout." + }, + "line_items": { + "required": false, + "description": "Line items data." + }, + "shipping_lines": { + "required": false, + "description": "Shipping lines data." + }, + "fee_lines": { + "required": false, + "description": "Fee lines data." + }, + "coupon_lines": { + "required": false, + "description": "Coupons line data." + } + } + }, + { + "methods": [ + "DELETE" + ], + "args": { + "force": { + "required": false, + "default": false, + "description": "Whether to bypass trash and force deletion." + }, + "reassign": { + "required": false + } + } + } + ] + }, + "/wc/v1/orders/batch": { + "namespace": "wc/v1", + "methods": [ + "POST", + "PUT", + "PATCH" + ], + "endpoints": [ + { + "methods": [ + "POST", + "PUT", + "PATCH" + ], + "args": { + "parent_id": { + "required": false, + "description": "Parent order ID." + }, + "status": { + "required": false, + "enum": [ + "pending", + "processing", + "on-hold", + "completed", + "cancelled", + "refunded", + "failed" + ], + "description": "Order status." + }, + "currency": { + "required": false, + "enum": [ + "AED", + "AFN", + "ALL", + "AMD", + "ANG", + "AOA", + "ARS", + "AUD", + "AWG", + "AZN", + "BAM", + "BBD", + "BDT", + "BGN", + "BHD", + "BIF", + "BMD", + "BND", + "BOB", + "BRL", + "BSD", + "BTC", + "BTN", + "BWP", + "BYR", + "BZD", + "CAD", + "CDF", + "CHF", + "CLP", + "CNY", + "COP", + "CRC", + "CUC", + "CUP", + "CVE", + "CZK", + "DJF", + "DKK", + "DOP", + "DZD", + "EGP", + "ERN", + "ETB", + "EUR", + "FJD", + "FKP", + "GBP", + "GEL", + "GGP", + "GHS", + "GIP", + "GMD", + "GNF", + "GTQ", + "GYD", + "HKD", + "HNL", + "HRK", + "HTG", + "HUF", + "IDR", + "ILS", + "IMP", + "INR", + "IQD", + "IRR", + "ISK", + "JEP", + "JMD", + "JOD", + "JPY", + "KES", + "KGS", + "KHR", + "KMF", + "KPW", + "KRW", + "KWD", + "KYD", + "KZT", + "LAK", + "LBP", + "LKR", + "LRD", + "LSL", + "LYD", + "MAD", + "MDL", + "MGA", + "MKD", + "MMK", + "MNT", + "MOP", + "MRO", + "MUR", + "MVR", + "MWK", + "MXN", + "MYR", + "MZN", + "NAD", + "NGN", + "NIO", + "NOK", + "NPR", + "NZD", + "OMR", + "PAB", + "PEN", + "PGK", + "PHP", + "PKR", + "PLN", + "PRB", + "PYG", + "QAR", + "RON", + "RSD", + "RUB", + "RWF", + "SAR", + "SBD", + "SCR", + "SDG", + "SEK", + "SGD", + "SHP", + "SLL", + "SOS", + "SRD", + "SSP", + "STD", + "SYP", + "SZL", + "THB", + "TJS", + "TMT", + "TND", + "TOP", + "TRY", + "TTD", + "TWD", + "TZS", + "UAH", + "UGX", + "USD", + "UYU", + "UZS", + "VEF", + "VND", + "VUV", + "WST", + "XAF", + "XCD", + "XOF", + "XPF", + "YER", + "ZAR", + "ZMW" + ], + "description": "Currency the order was created with, in ISO format." + }, + "customer_id": { + "required": false, + "description": "User ID who owns the order. 0 for guests." + }, + "billing": { + "required": false, + "description": "Billing address." + }, + "shipping": { + "required": false, + "description": "Shipping address." + }, + "payment_method": { + "required": false, + "description": "Payment method ID." + }, + "payment_method_title": { + "required": false, + "description": "Payment method title." + }, + "set_paid": { + "required": false, + "description": "Define if the order is paid. It will set the status to processing and reduce stock items." + }, + "transaction_id": { + "required": false, + "description": "Unique transaction ID." + }, + "customer_note": { + "required": false, + "description": "Note left by customer during checkout." + }, + "line_items": { + "required": false, + "description": "Line items data." + }, + "shipping_lines": { + "required": false, + "description": "Shipping lines data." + }, + "fee_lines": { + "required": false, + "description": "Fee lines data." + }, + "coupon_lines": { + "required": false, + "description": "Coupons line data." + } + } + } + ], + "_links": { + "self": "https://example.com/wp-json/wc/v1/orders/batch" + } + }, + "/wc/v1/products/attributes/(?P[\\d]+)/terms": { + "namespace": "wc/v1", + "methods": [ + "GET", + "POST" + ], + "endpoints": [ + { + "methods": [ + "GET" + ], + "args": { + "context": { + "required": false, + "default": "view", + "enum": [ + "view", + "edit" + ], + "description": "Scope under which the request is made; determines fields present in response." + }, + "page": { + "required": false, + "default": 1, + "description": "Current page of the collection." + }, + "per_page": { + "required": false, + "default": 10, + "description": "Maximum number of items to be returned in result set." + }, + "search": { + "required": false, + "description": "Limit results to those matching a string." + }, + "exclude": { + "required": false, + "default": [], + "description": "Ensure result set excludes specific ids." + }, + "include": { + "required": false, + "default": [], + "description": "Limit result set to specific ids." + }, + "order": { + "required": false, + "default": "asc", + "enum": [ + "asc", + "desc" + ], + "description": "Order sort attribute ascending or descending." + }, + "orderby": { + "required": false, + "default": "name", + "enum": [ + "id", + "include", + "name", + "slug", + "term_group", + "description", + "count" + ], + "description": "Sort collection by resource attribute." + }, + "hide_empty": { + "required": false, + "default": false, + "description": "Whether to hide resources not assigned to any products." + }, + "parent": { + "required": false, + "description": "Limit result set to resources assigned to a specific parent." + }, + "product": { + "required": false, + "description": "Limit result set to resources assigned to a specific product." + }, + "slug": { + "required": false, + "description": "Limit result set to resources with a specific slug." + } + } + }, + { + "methods": [ + "POST" + ], + "args": { + "name": { + "required": true + }, + "slug": { + "required": false, + "description": "An alphanumeric identifier for the resource unique to its type." + }, + "menu_order": { + "required": false, + "description": "Menu order, used to custom sort the resource." + } + } + } + ] + }, + "/wc/v1/products/attributes/(?P[\\d]+)/terms/(?P[\\d]+)": { + "namespace": "wc/v1", + "methods": [ + "GET", + "POST", + "PUT", + "PATCH", + "DELETE" + ], + "endpoints": [ + { + "methods": [ + "GET" + ], + "args": { + "context": { + "required": false, + "default": "view", + "enum": [ + "view", + "edit" + ], + "description": "Scope under which the request is made; determines fields present in response." + } + } + }, + { + "methods": [ + "POST", + "PUT", + "PATCH" + ], + "args": { + "name": { + "required": false, + "description": "Term name." + }, + "slug": { + "required": false, + "description": "An alphanumeric identifier for the resource unique to its type." + }, + "menu_order": { + "required": false, + "description": "Menu order, used to custom sort the resource." + } + } + }, + { + "methods": [ + "DELETE" + ], + "args": { + "force": { + "required": false, + "default": false, + "description": "Required to be true, as resource does not support trashing." + } + } + } + ] + }, + "/wc/v1/products/attributes/(?P[\\d]+)/terms/batch": { + "namespace": "wc/v1", + "methods": [ + "POST", + "PUT", + "PATCH" + ], + "endpoints": [ + { + "methods": [ + "POST", + "PUT", + "PATCH" + ], + "args": { + "name": { + "required": false, + "description": "Term name." + }, + "slug": { + "required": false, + "description": "An alphanumeric identifier for the resource unique to its type." + }, + "menu_order": { + "required": false, + "description": "Menu order, used to custom sort the resource." + } + } + } + ] + }, + "/wc/v1/products/attributes": { + "namespace": "wc/v1", + "methods": [ + "GET", + "POST" + ], + "endpoints": [ + { + "methods": [ + "GET" + ], + "args": { + "context": { + "required": false, + "default": "view", + "enum": [ + "view", + "edit" + ], + "description": "Scope under which the request is made; determines fields present in response." + } + } + }, + { + "methods": [ + "POST" + ], + "args": { + "name": { + "required": true + }, + "slug": { + "required": false, + "description": "An alphanumeric identifier for the resource unique to its type." + }, + "type": { + "required": false, + "default": "select", + "enum": [ + "select", + "text" + ], + "description": "Type of attribute." + }, + "order_by": { + "required": false, + "default": "menu_order", + "enum": [ + "menu_order", + "name", + "name_num", + "id" + ], + "description": "Default sort order." + }, + "has_archives": { + "required": false, + "default": false, + "description": "Enable/Disable attribute archives." + } + } + } + ], + "_links": { + "self": "https://example.com/wp-json/wc/v1/products/attributes" + } + }, + "/wc/v1/products/attributes/(?P[\\d]+)": { + "namespace": "wc/v1", + "methods": [ + "GET", + "POST", + "PUT", + "PATCH", + "DELETE" + ], + "endpoints": [ + { + "methods": [ + "GET" + ], + "args": { + "context": { + "required": false, + "default": "view", + "enum": [ + "view", + "edit" + ], + "description": "Scope under which the request is made; determines fields present in response." + } + } + }, + { + "methods": [ + "POST", + "PUT", + "PATCH" + ], + "args": { + "name": { + "required": false, + "description": "Attribute name." + }, + "slug": { + "required": false, + "description": "An alphanumeric identifier for the resource unique to its type." + }, + "type": { + "required": false, + "enum": [ + "select", + "text" + ], + "description": "Type of attribute." + }, + "order_by": { + "required": false, + "enum": [ + "menu_order", + "name", + "name_num", + "id" + ], + "description": "Default sort order." + }, + "has_archives": { + "required": false, + "description": "Enable/Disable attribute archives." + } + } + }, + { + "methods": [ + "DELETE" + ], + "args": { + "force": { + "required": false, + "default": false, + "description": "Required to be true, as resource does not support trashing." + } + } + } + ] + }, + "/wc/v1/products/categories": { + "namespace": "wc/v1", + "methods": [ + "GET", + "POST" + ], + "endpoints": [ + { + "methods": [ + "GET" + ], + "args": { + "context": { + "required": false, + "default": "view", + "enum": [ + "view", + "edit" + ], + "description": "Scope under which the request is made; determines fields present in response." + }, + "page": { + "required": false, + "default": 1, + "description": "Current page of the collection." + }, + "per_page": { + "required": false, + "default": 10, + "description": "Maximum number of items to be returned in result set." + }, + "search": { + "required": false, + "description": "Limit results to those matching a string." + }, + "exclude": { + "required": false, + "default": [], + "description": "Ensure result set excludes specific ids." + }, + "include": { + "required": false, + "default": [], + "description": "Limit result set to specific ids." + }, + "order": { + "required": false, + "default": "asc", + "enum": [ + "asc", + "desc" + ], + "description": "Order sort attribute ascending or descending." + }, + "orderby": { + "required": false, + "default": "name", + "enum": [ + "id", + "include", + "name", + "slug", + "term_group", + "description", + "count" + ], + "description": "Sort collection by resource attribute." + }, + "hide_empty": { + "required": false, + "default": false, + "description": "Whether to hide resources not assigned to any products." + }, + "parent": { + "required": false, + "description": "Limit result set to resources assigned to a specific parent." + }, + "product": { + "required": false, + "description": "Limit result set to resources assigned to a specific product." + }, + "slug": { + "required": false, + "description": "Limit result set to resources with a specific slug." + } + } + }, + { + "methods": [ + "POST" + ], + "args": { + "name": { + "required": true + }, + "slug": { + "required": false, + "description": "An alphanumeric identifier for the resource unique to its type." + }, + "parent": { + "required": false, + "description": "The id for the parent of the resource." + }, + "description": { + "required": false, + "description": "HTML description of the resource." + }, + "display": { + "required": false, + "default": "default", + "enum": [ + "default", + "products", + "subcategories", + "both" + ], + "description": "Category archive display type." + }, + "image": { + "required": false, + "description": "Image URL." + }, + "menu_order": { + "required": false, + "description": "Menu order, used to custom sort the resource." + } + } + } + ], + "_links": { + "self": "https://example.com/wp-json/wc/v1/products/categories" + } + }, + "/wc/v1/products/categories/(?P[\\d]+)": { + "namespace": "wc/v1", + "methods": [ + "GET", + "POST", + "PUT", + "PATCH", + "DELETE" + ], + "endpoints": [ + { + "methods": [ + "GET" + ], + "args": { + "context": { + "required": false, + "default": "view", + "enum": [ + "view", + "edit" + ], + "description": "Scope under which the request is made; determines fields present in response." + } + } + }, + { + "methods": [ + "POST", + "PUT", + "PATCH" + ], + "args": { + "name": { + "required": false, + "description": "Category name." + }, + "slug": { + "required": false, + "description": "An alphanumeric identifier for the resource unique to its type." + }, + "parent": { + "required": false, + "description": "The id for the parent of the resource." + }, + "description": { + "required": false, + "description": "HTML description of the resource." + }, + "display": { + "required": false, + "enum": [ + "default", + "products", + "subcategories", + "both" + ], + "description": "Category archive display type." + }, + "image": { + "required": false, + "description": "Image URL." + }, + "menu_order": { + "required": false, + "description": "Menu order, used to custom sort the resource." + } + } + }, + { + "methods": [ + "DELETE" + ], + "args": { + "force": { + "required": false, + "default": false, + "description": "Required to be true, as resource does not support trashing." + } + } + } + ] + }, + "/wc/v1/products/categories/batch": { + "namespace": "wc/v1", + "methods": [ + "POST", + "PUT", + "PATCH" + ], + "endpoints": [ + { + "methods": [ + "POST", + "PUT", + "PATCH" + ], + "args": { + "name": { + "required": false, + "description": "Category name." + }, + "slug": { + "required": false, + "description": "An alphanumeric identifier for the resource unique to its type." + }, + "parent": { + "required": false, + "description": "The id for the parent of the resource." + }, + "description": { + "required": false, + "description": "HTML description of the resource." + }, + "display": { + "required": false, + "enum": [ + "default", + "products", + "subcategories", + "both" + ], + "description": "Category archive display type." + }, + "image": { + "required": false, + "description": "Image URL." + }, + "menu_order": { + "required": false, + "description": "Menu order, used to custom sort the resource." + } + } + } + ], + "_links": { + "self": "https://example.com/wp-json/wc/v1/products/categories/batch" + } + }, + "/wc/v1/products/(?P[\\d]+)/reviews": { + "namespace": "wc/v1", + "methods": [ + "GET" + ], + "endpoints": [ + { + "methods": [ + "GET" + ], + "args": { + "context": { + "required": false, + "default": "view", + "enum": [ + "view", + "edit" + ], + "description": "Scope under which the request is made; determines fields present in response." + } + } + } + ] + }, + "/wc/v1/products/(?P[\\d]+)/reviews/(?P[\\d]+)": { + "namespace": "wc/v1", + "methods": [ + "GET" + ], + "endpoints": [ + { + "methods": [ + "GET" + ], + "args": { + "context": { + "required": false, + "default": "view", + "enum": [ + "view", + "edit" + ], + "description": "Scope under which the request is made; determines fields present in response." + } + } + } + ] + }, + "/wc/v1/products/shipping_classes": { + "namespace": "wc/v1", + "methods": [ + "GET", + "POST" + ], + "endpoints": [ + { + "methods": [ + "GET" + ], + "args": { + "context": { + "required": false, + "default": "view", + "enum": [ + "view", + "edit" + ], + "description": "Scope under which the request is made; determines fields present in response." + }, + "page": { + "required": false, + "default": 1, + "description": "Current page of the collection." + }, + "per_page": { + "required": false, + "default": 10, + "description": "Maximum number of items to be returned in result set." + }, + "search": { + "required": false, + "description": "Limit results to those matching a string." + }, + "exclude": { + "required": false, + "default": [], + "description": "Ensure result set excludes specific ids." + }, + "include": { + "required": false, + "default": [], + "description": "Limit result set to specific ids." + }, + "offset": { + "required": false, + "description": "Offset the result set by a specific number of items." + }, + "order": { + "required": false, + "default": "asc", + "enum": [ + "asc", + "desc" + ], + "description": "Order sort attribute ascending or descending." + }, + "orderby": { + "required": false, + "default": "name", + "enum": [ + "id", + "include", + "name", + "slug", + "term_group", + "description", + "count" + ], + "description": "Sort collection by resource attribute." + }, + "hide_empty": { + "required": false, + "default": false, + "description": "Whether to hide resources not assigned to any products." + }, + "product": { + "required": false, + "description": "Limit result set to resources assigned to a specific product." + }, + "slug": { + "required": false, + "description": "Limit result set to resources with a specific slug." + } + } + }, + { + "methods": [ + "POST" + ], + "args": { + "name": { + "required": true + }, + "slug": { + "required": false, + "description": "An alphanumeric identifier for the resource unique to its type." + }, + "parent": { + "required": false, + "description": "The id for the parent of the resource." + }, + "description": { + "required": false, + "description": "HTML description of the resource." + } + } + } + ], + "_links": { + "self": "https://example.com/wp-json/wc/v1/products/shipping_classes" + } + }, + "/wc/v1/products/shipping_classes/(?P[\\d]+)": { + "namespace": "wc/v1", + "methods": [ + "GET", + "POST", + "PUT", + "PATCH", + "DELETE" + ], + "endpoints": [ + { + "methods": [ + "GET" + ], + "args": { + "context": { + "required": false, + "default": "view", + "enum": [ + "view", + "edit" + ], + "description": "Scope under which the request is made; determines fields present in response." + } + } + }, + { + "methods": [ + "POST", + "PUT", + "PATCH" + ], + "args": { + "name": { + "required": false, + "description": "Shipping class name." + }, + "slug": { + "required": false, + "description": "An alphanumeric identifier for the resource unique to its type." + }, + "parent": { + "required": false, + "description": "The id for the parent of the resource." + }, + "description": { + "required": false, + "description": "HTML description of the resource." + } + } + }, + { + "methods": [ + "DELETE" + ], + "args": { + "force": { + "required": false, + "default": false, + "description": "Required to be true, as resource does not support trashing." + } + } + } + ] + }, + "/wc/v1/products/shipping_classes/batch": { + "namespace": "wc/v1", + "methods": [ + "POST", + "PUT", + "PATCH" + ], + "endpoints": [ + { + "methods": [ + "POST", + "PUT", + "PATCH" + ], + "args": { + "name": { + "required": false, + "description": "Shipping class name." + }, + "slug": { + "required": false, + "description": "An alphanumeric identifier for the resource unique to its type." + }, + "parent": { + "required": false, + "description": "The id for the parent of the resource." + }, + "description": { + "required": false, + "description": "HTML description of the resource." + } + } + } + ], + "_links": { + "self": "https://example.com/wp-json/wc/v1/products/shipping_classes/batch" + } + }, + "/wc/v1/products/tags": { + "namespace": "wc/v1", + "methods": [ + "GET", + "POST" + ], + "endpoints": [ + { + "methods": [ + "GET" + ], + "args": { + "context": { + "required": false, + "default": "view", + "enum": [ + "view", + "edit" + ], + "description": "Scope under which the request is made; determines fields present in response." + }, + "page": { + "required": false, + "default": 1, + "description": "Current page of the collection." + }, + "per_page": { + "required": false, + "default": 10, + "description": "Maximum number of items to be returned in result set." + }, + "search": { + "required": false, + "description": "Limit results to those matching a string." + }, + "exclude": { + "required": false, + "default": [], + "description": "Ensure result set excludes specific ids." + }, + "include": { + "required": false, + "default": [], + "description": "Limit result set to specific ids." + }, + "offset": { + "required": false, + "description": "Offset the result set by a specific number of items." + }, + "order": { + "required": false, + "default": "asc", + "enum": [ + "asc", + "desc" + ], + "description": "Order sort attribute ascending or descending." + }, + "orderby": { + "required": false, + "default": "name", + "enum": [ + "id", + "include", + "name", + "slug", + "term_group", + "description", + "count" + ], + "description": "Sort collection by resource attribute." + }, + "hide_empty": { + "required": false, + "default": false, + "description": "Whether to hide resources not assigned to any products." + }, + "product": { + "required": false, + "description": "Limit result set to resources assigned to a specific product." + }, + "slug": { + "required": false, + "description": "Limit result set to resources with a specific slug." + } + } + }, + { + "methods": [ + "POST" + ], + "args": { + "name": { + "required": true + }, + "slug": { + "required": false, + "description": "An alphanumeric identifier for the resource unique to its type." + }, + "description": { + "required": false, + "description": "HTML description of the resource." + } + } + } + ], + "_links": { + "self": "https://example.com/wp-json/wc/v1/products/tags" + } + }, + "/wc/v1/products/tags/(?P[\\d]+)": { + "namespace": "wc/v1", + "methods": [ + "GET", + "POST", + "PUT", + "PATCH", + "DELETE" + ], + "endpoints": [ + { + "methods": [ + "GET" + ], + "args": { + "context": { + "required": false, + "default": "view", + "enum": [ + "view", + "edit" + ], + "description": "Scope under which the request is made; determines fields present in response." + } + } + }, + { + "methods": [ + "POST", + "PUT", + "PATCH" + ], + "args": { + "name": { + "required": false, + "description": "Tag name." + }, + "slug": { + "required": false, + "description": "An alphanumeric identifier for the resource unique to its type." + }, + "description": { + "required": false, + "description": "HTML description of the resource." + } + } + }, + { + "methods": [ + "DELETE" + ], + "args": { + "force": { + "required": false, + "default": false, + "description": "Required to be true, as resource does not support trashing." + } + } + } + ] + }, + "/wc/v1/products/tags/batch": { + "namespace": "wc/v1", + "methods": [ + "POST", + "PUT", + "PATCH" + ], + "endpoints": [ + { + "methods": [ + "POST", + "PUT", + "PATCH" + ], + "args": { + "name": { + "required": false, + "description": "Tag name." + }, + "slug": { + "required": false, + "description": "An alphanumeric identifier for the resource unique to its type." + }, + "description": { + "required": false, + "description": "HTML description of the resource." + } + } + } + ], + "_links": { + "self": "https://example.com/wp-json/wc/v1/products/tags/batch" + } + }, + "/wc/v1/products": { + "namespace": "wc/v1", + "methods": [ + "GET", + "POST" + ], + "endpoints": [ + { + "methods": [ + "GET" + ], + "args": { + "context": { + "required": false, + "default": "view", + "enum": [ + "view", + "edit" + ], + "description": "Scope under which the request is made; determines fields present in response." + }, + "page": { + "required": false, + "default": 1, + "description": "Current page of the collection." + }, + "per_page": { + "required": false, + "default": 10, + "description": "Maximum number of items to be returned in result set." + }, + "search": { + "required": false, + "description": "Limit results to those matching a string." + }, + "after": { + "required": false, + "description": "Limit response to resources published after a given ISO8601 compliant date." + }, + "before": { + "required": false, + "description": "Limit response to resources published before a given ISO8601 compliant date." + }, + "exclude": { + "required": false, + "default": [], + "description": "Ensure result set excludes specific ids." + }, + "include": { + "required": false, + "default": [], + "description": "Limit result set to specific ids." + }, + "offset": { + "required": false, + "description": "Offset the result set by a specific number of items." + }, + "order": { + "required": false, + "default": "desc", + "enum": [ + "asc", + "desc" + ], + "description": "Order sort attribute ascending or descending." + }, + "orderby": { + "required": false, + "default": "date", + "enum": [ + "date", + "id", + "include", + "title", + "slug" + ], + "description": "Sort collection by object attribute." + }, + "slug": { + "required": false, + "description": "Limit result set to posts with a specific slug." + }, + "filter": { + "required": false, + "description": "Use WP Query arguments to modify the response; private query vars require appropriate authorization." + }, + "status": { + "required": false, + "default": "any", + "enum": [ + "any", + "draft", + "pending", + "private", + "publish" + ], + "description": "Limit result set to products assigned a specific status." + }, + "type": { + "required": false, + "enum": [ + "simple", + "grouped", + "external", + "variable" + ], + "description": "Limit result set to products assigned a specific type." + }, + "category": { + "required": false, + "description": "Limit result set to products assigned a specific category." + }, + "tag": { + "required": false, + "description": "Limit result set to products assigned a specific tag." + }, + "shipping_class": { + "required": false, + "description": "Limit result set to products assigned a specific shipping class." + }, + "attribute": { + "required": false, + "description": "Limit result set to products with a specific attribute." + }, + "attribute_term": { + "required": false, + "description": "Limit result set to products with a specific attribute term (required an assigned attribute)." + }, + "sku": { + "required": false, + "description": "Limit result set to products with a specific SKU." + } + } + }, + { + "methods": [ + "POST" + ], + "args": { + "name": { + "required": false, + "description": "Product name." + }, + "slug": { + "required": false, + "description": "Product slug." + }, + "type": { + "required": false, + "default": "simple", + "enum": [ + "simple", + "grouped", + "external", + "variable" + ], + "description": "Product type." + }, + "status": { + "required": false, + "default": "publish", + "enum": [ + "draft", + "pending", + "private", + "publish" + ], + "description": "Product status (post status)." + }, + "featured": { + "required": false, + "default": false, + "description": "Featured product." + }, + "catalog_visibility": { + "required": false, + "default": "visible", + "enum": [ + "visible", + "catalog", + "search", + "hidden" + ], + "description": "Catalog visibility." + }, + "description": { + "required": false, + "description": "Product description." + }, + "short_description": { + "required": false, + "description": "Product short description." + }, + "sku": { + "required": false, + "description": "Unique identifier." + }, + "regular_price": { + "required": false, + "description": "Product regular price." + }, + "sale_price": { + "required": false, + "description": "Product sale price." + }, + "date_on_sale_from": { + "required": false, + "description": "Start date of sale price." + }, + "date_on_sale_to": { + "required": false, + "description": "End data of sale price." + }, + "virtual": { + "required": false, + "default": false, + "description": "If the product is virtual." + }, + "downloadable": { + "required": false, + "default": false, + "description": "If the product is downloadable." + }, + "downloads": { + "required": false, + "description": "List of downloadable files." + }, + "download_limit": { + "required": false, + "description": "Amount of times the product can be downloaded." + }, + "download_expiry": { + "required": false, + "description": "Number of days that the customer has up to be able to download the product." + }, + "download_type": { + "required": false, + "default": "standard", + "enum": [ + "standard", + "application", + "music" + ], + "description": "Download type, this controls the schema on the front-end." + }, + "external_url": { + "required": false, + "description": "Product external URL. Only for external products." + }, + "button_text": { + "required": false, + "description": "Product external button text. Only for external products." + }, + "tax_status": { + "required": false, + "default": "taxable", + "enum": [ + "taxable", + "shipping", + "none" + ], + "description": "Tax status." + }, + "tax_class": { + "required": false, + "description": "Tax class." + }, + "manage_stock": { + "required": false, + "default": false, + "description": "Stock management at product level." + }, + "stock_quantity": { + "required": false, + "description": "Stock quantity." + }, + "in_stock": { + "required": false, + "default": true, + "description": "Controls whether or not the product is listed as \"in stock\" or \"out of stock\" on the frontend." + }, + "backorders": { + "required": false, + "default": "no", + "enum": [ + "no", + "notify", + "yes" + ], + "description": "If managing stock, this controls if backorders are allowed." + }, + "sold_individually": { + "required": false, + "default": false, + "description": "Allow one item to be bought in a single order." + }, + "weight": { + "required": false, + "description": "Product weight (kg)." + }, + "dimensions": { + "required": false, + "description": "Product dimensions." + }, + "shipping_class": { + "required": false, + "description": "Shipping class slug." + }, + "reviews_allowed": { + "required": false, + "default": true, + "description": "Allow reviews." + }, + "upsell_ids": { + "required": false, + "description": "List of up-sell products IDs." + }, + "cross_sell_ids": { + "required": false, + "description": "List of cross-sell products IDs." + }, + "parent_id": { + "required": false, + "description": "Product parent ID." + }, + "purchase_note": { + "required": false, + "description": "Optional note to send the customer after purchase." + }, + "categories": { + "required": false, + "description": "List of categories." + }, + "tags": { + "required": false, + "description": "List of tags." + }, + "images": { + "required": false, + "description": "List of images." + }, + "attributes": { + "required": false, + "description": "List of attributes." + }, + "default_attributes": { + "required": false, + "description": "Defaults variation attributes." + }, + "variations": { + "required": false, + "description": "List of variations." + }, + "menu_order": { + "required": false, + "description": "Menu order, used to custom sort products." + } + } + } + ], + "_links": { + "self": "https://example.com/wp-json/wc/v1/products" + } + }, + "/wc/v1/products/(?P[\\d]+)": { + "namespace": "wc/v1", + "methods": [ + "GET", + "POST", + "PUT", + "PATCH", + "DELETE" + ], + "endpoints": [ + { + "methods": [ + "GET" + ], + "args": { + "context": { + "required": false, + "default": "view", + "enum": [ + "view", + "edit" + ], + "description": "Scope under which the request is made; determines fields present in response." + } + } + }, + { + "methods": [ + "POST", + "PUT", + "PATCH" + ], + "args": { + "name": { + "required": false, + "description": "Product name." + }, + "slug": { + "required": false, + "description": "Product slug." + }, + "type": { + "required": false, + "enum": [ + "simple", + "grouped", + "external", + "variable" + ], + "description": "Product type." + }, + "status": { + "required": false, + "enum": [ + "draft", + "pending", + "private", + "publish" + ], + "description": "Product status (post status)." + }, + "featured": { + "required": false, + "description": "Featured product." + }, + "catalog_visibility": { + "required": false, + "enum": [ + "visible", + "catalog", + "search", + "hidden" + ], + "description": "Catalog visibility." + }, + "description": { + "required": false, + "description": "Product description." + }, + "short_description": { + "required": false, + "description": "Product short description." + }, + "sku": { + "required": false, + "description": "Unique identifier." + }, + "regular_price": { + "required": false, + "description": "Product regular price." + }, + "sale_price": { + "required": false, + "description": "Product sale price." + }, + "date_on_sale_from": { + "required": false, + "description": "Start date of sale price." + }, + "date_on_sale_to": { + "required": false, + "description": "End data of sale price." + }, + "virtual": { + "required": false, + "description": "If the product is virtual." + }, + "downloadable": { + "required": false, + "description": "If the product is downloadable." + }, + "downloads": { + "required": false, + "description": "List of downloadable files." + }, + "download_limit": { + "required": false, + "description": "Amount of times the product can be downloaded." + }, + "download_expiry": { + "required": false, + "description": "Number of days that the customer has up to be able to download the product." + }, + "download_type": { + "required": false, + "enum": [ + "standard", + "application", + "music" + ], + "description": "Download type, this controls the schema on the front-end." + }, + "external_url": { + "required": false, + "description": "Product external URL. Only for external products." + }, + "button_text": { + "required": false, + "description": "Product external button text. Only for external products." + }, + "tax_status": { + "required": false, + "enum": [ + "taxable", + "shipping", + "none" + ], + "description": "Tax status." + }, + "tax_class": { + "required": false, + "description": "Tax class." + }, + "manage_stock": { + "required": false, + "description": "Stock management at product level." + }, + "stock_quantity": { + "required": false, + "description": "Stock quantity." + }, + "in_stock": { + "required": false, + "description": "Controls whether or not the product is listed as \"in stock\" or \"out of stock\" on the frontend." + }, + "backorders": { + "required": false, + "enum": [ + "no", + "notify", + "yes" + ], + "description": "If managing stock, this controls if backorders are allowed." + }, + "sold_individually": { + "required": false, + "description": "Allow one item to be bought in a single order." + }, + "weight": { + "required": false, + "description": "Product weight (kg)." + }, + "dimensions": { + "required": false, + "description": "Product dimensions." + }, + "shipping_class": { + "required": false, + "description": "Shipping class slug." + }, + "reviews_allowed": { + "required": false, + "description": "Allow reviews." + }, + "upsell_ids": { + "required": false, + "description": "List of up-sell products IDs." + }, + "cross_sell_ids": { + "required": false, + "description": "List of cross-sell products IDs." + }, + "parent_id": { + "required": false, + "description": "Product parent ID." + }, + "purchase_note": { + "required": false, + "description": "Optional note to send the customer after purchase." + }, + "categories": { + "required": false, + "description": "List of categories." + }, + "tags": { + "required": false, + "description": "List of tags." + }, + "images": { + "required": false, + "description": "List of images." + }, + "attributes": { + "required": false, + "description": "List of attributes." + }, + "default_attributes": { + "required": false, + "description": "Defaults variation attributes." + }, + "variations": { + "required": false, + "description": "List of variations." + }, + "menu_order": { + "required": false, + "description": "Menu order, used to custom sort products." + } + } + }, + { + "methods": [ + "DELETE" + ], + "args": { + "force": { + "required": false, + "default": false, + "description": "Whether to bypass trash and force deletion." + }, + "reassign": { + "required": false + } + } + } + ] + }, + "/wc/v1/products/batch": { + "namespace": "wc/v1", + "methods": [ + "POST", + "PUT", + "PATCH" + ], + "endpoints": [ + { + "methods": [ + "POST", + "PUT", + "PATCH" + ], + "args": { + "name": { + "required": false, + "description": "Product name." + }, + "slug": { + "required": false, + "description": "Product slug." + }, + "type": { + "required": false, + "enum": [ + "simple", + "grouped", + "external", + "variable" + ], + "description": "Product type." + }, + "status": { + "required": false, + "enum": [ + "draft", + "pending", + "private", + "publish" + ], + "description": "Product status (post status)." + }, + "featured": { + "required": false, + "description": "Featured product." + }, + "catalog_visibility": { + "required": false, + "enum": [ + "visible", + "catalog", + "search", + "hidden" + ], + "description": "Catalog visibility." + }, + "description": { + "required": false, + "description": "Product description." + }, + "short_description": { + "required": false, + "description": "Product short description." + }, + "sku": { + "required": false, + "description": "Unique identifier." + }, + "regular_price": { + "required": false, + "description": "Product regular price." + }, + "sale_price": { + "required": false, + "description": "Product sale price." + }, + "date_on_sale_from": { + "required": false, + "description": "Start date of sale price." + }, + "date_on_sale_to": { + "required": false, + "description": "End data of sale price." + }, + "virtual": { + "required": false, + "description": "If the product is virtual." + }, + "downloadable": { + "required": false, + "description": "If the product is downloadable." + }, + "downloads": { + "required": false, + "description": "List of downloadable files." + }, + "download_limit": { + "required": false, + "description": "Amount of times the product can be downloaded." + }, + "download_expiry": { + "required": false, + "description": "Number of days that the customer has up to be able to download the product." + }, + "download_type": { + "required": false, + "enum": [ + "standard", + "application", + "music" + ], + "description": "Download type, this controls the schema on the front-end." + }, + "external_url": { + "required": false, + "description": "Product external URL. Only for external products." + }, + "button_text": { + "required": false, + "description": "Product external button text. Only for external products." + }, + "tax_status": { + "required": false, + "enum": [ + "taxable", + "shipping", + "none" + ], + "description": "Tax status." + }, + "tax_class": { + "required": false, + "description": "Tax class." + }, + "manage_stock": { + "required": false, + "description": "Stock management at product level." + }, + "stock_quantity": { + "required": false, + "description": "Stock quantity." + }, + "in_stock": { + "required": false, + "description": "Controls whether or not the product is listed as \"in stock\" or \"out of stock\" on the frontend." + }, + "backorders": { + "required": false, + "enum": [ + "no", + "notify", + "yes" + ], + "description": "If managing stock, this controls if backorders are allowed." + }, + "sold_individually": { + "required": false, + "description": "Allow one item to be bought in a single order." + }, + "weight": { + "required": false, + "description": "Product weight (kg)." + }, + "dimensions": { + "required": false, + "description": "Product dimensions." + }, + "shipping_class": { + "required": false, + "description": "Shipping class slug." + }, + "reviews_allowed": { + "required": false, + "description": "Allow reviews." + }, + "upsell_ids": { + "required": false, + "description": "List of up-sell products IDs." + }, + "cross_sell_ids": { + "required": false, + "description": "List of cross-sell products IDs." + }, + "parent_id": { + "required": false, + "description": "Product parent ID." + }, + "purchase_note": { + "required": false, + "description": "Optional note to send the customer after purchase." + }, + "categories": { + "required": false, + "description": "List of categories." + }, + "tags": { + "required": false, + "description": "List of tags." + }, + "images": { + "required": false, + "description": "List of images." + }, + "attributes": { + "required": false, + "description": "List of attributes." + }, + "default_attributes": { + "required": false, + "description": "Defaults variation attributes." + }, + "variations": { + "required": false, + "description": "List of variations." + }, + "menu_order": { + "required": false, + "description": "Menu order, used to custom sort products." + } + } + } + ], + "_links": { + "self": "https://example.com/wp-json/wc/v1/products/batch" + } + }, + "/wc/v1/reports/sales": { + "namespace": "wc/v1", + "methods": [ + "GET" + ], + "endpoints": [ + { + "methods": [ + "GET" + ], + "args": { + "context": { + "required": false, + "default": "view", + "enum": [ + "view" + ], + "description": "Scope under which the request is made; determines fields present in response." + }, + "period": { + "required": false, + "enum": [ + "week", + "month", + "last_month", + "year" + ], + "description": "Report period." + }, + "date_min": { + "required": false, + "description": "Return sales for a specific start date, the date need to be in the YYYY-MM-AA format." + }, + "date_max": { + "required": false, + "description": "Return sales for a specific end date, the date need to be in the YYYY-MM-AA format." + } + } + } + ], + "_links": { + "self": "https://example.com/wp-json/wc/v1/reports/sales" + } + }, + "/wc/v1/reports/top_sellers": { + "namespace": "wc/v1", + "methods": [ + "GET" + ], + "endpoints": [ + { + "methods": [ + "GET" + ], + "args": { + "context": { + "required": false, + "default": "view", + "enum": [ + "view" + ], + "description": "Scope under which the request is made; determines fields present in response." + }, + "period": { + "required": false, + "enum": [ + "week", + "month", + "last_month", + "year" + ], + "description": "Report period." + }, + "date_min": { + "required": false, + "description": "Return sales for a specific start date, the date need to be in the YYYY-MM-AA format." + }, + "date_max": { + "required": false, + "description": "Return sales for a specific end date, the date need to be in the YYYY-MM-AA format." + } + } + } + ], + "_links": { + "self": "https://example.com/wp-json/wc/v1/reports/top_sellers" + } + }, + "/wc/v1/reports": { + "namespace": "wc/v1", + "methods": [ + "GET" + ], + "endpoints": [ + { + "methods": [ + "GET" + ], + "args": { + "context": { + "required": false, + "default": "view", + "enum": [ + "view" + ], + "description": "Scope under which the request is made; determines fields present in response." + } + } + } + ], + "_links": { + "self": "https://example.com/wp-json/wc/v1/reports" + } + }, + "/wc/v1/taxes/classes": { + "namespace": "wc/v1", + "methods": [ + "GET", + "POST" + ], + "endpoints": [ + { + "methods": [ + "GET" + ], + "args": { + "context": { + "required": false, + "default": "view", + "enum": [ + "view", + "edit" + ], + "description": "Scope under which the request is made; determines fields present in response." + } + } + }, + { + "methods": [ + "POST" + ], + "args": { + "name": { + "required": true, + "description": "Tax class name." + } + } + } + ], + "_links": { + "self": "https://example.com/wp-json/wc/v1/taxes/classes" + } + }, + "/wc/v1/taxes/classes/(?P\\w[\\w\\s\\-]*)": { + "namespace": "wc/v1", + "methods": [ + "DELETE" + ], + "endpoints": [ + { + "methods": [ + "DELETE" + ], + "args": { + "force": { + "required": false, + "default": false, + "description": "Required to be true, as resource does not support trashing." + } + } + } + ] + }, + "/wc/v1/taxes": { + "namespace": "wc/v1", + "methods": [ + "GET", + "POST" + ], + "endpoints": [ + { + "methods": [ + "GET" + ], + "args": { + "context": { + "required": false, + "default": "view", + "enum": [ + "view", + "edit" + ], + "description": "Scope under which the request is made; determines fields present in response." + }, + "page": { + "required": false, + "default": 1, + "description": "Current page of the collection." + }, + "per_page": { + "required": false, + "default": 10, + "description": "Maximum number of items to be returned in result set." + }, + "search": { + "required": false, + "description": "Limit results to those matching a string." + }, + "exclude": { + "required": false, + "default": [], + "description": "Ensure result set excludes specific ids." + }, + "include": { + "required": false, + "default": [], + "description": "Limit result set to specific ids." + }, + "offset": { + "required": false, + "description": "Offset the result set by a specific number of items." + }, + "order": { + "required": false, + "default": "asc", + "enum": [ + "asc", + "desc" + ], + "description": "Order sort attribute ascending or descending." + }, + "orderby": { + "required": false, + "default": "order", + "enum": [ + "id", + "order" + ], + "description": "Sort collection by object attribute." + }, + "class": { + "required": false, + "enum": [ + "standard", + "reduced-rate", + "zero-rate" + ], + "description": "Sort by tax class." + } + } + }, + { + "methods": [ + "POST" + ], + "args": { + "country": { + "required": false, + "description": "Country ISO 3166 code." + }, + "state": { + "required": false, + "description": "State code." + }, + "postcode": { + "required": false, + "description": "Postcode/ZIP." + }, + "city": { + "required": false, + "description": "City name." + }, + "rate": { + "required": false, + "description": "Tax rate." + }, + "name": { + "required": false, + "description": "Tax rate name." + }, + "priority": { + "required": false, + "default": 1, + "description": "Tax priority." + }, + "compound": { + "required": false, + "default": false, + "description": "Whether or not this is a compound rate." + }, + "shipping": { + "required": false, + "default": true, + "description": "Whether or not this tax rate also gets applied to shipping." + }, + "order": { + "required": false, + "description": "Indicates the order that will appear in queries." + }, + "class": { + "required": false, + "default": "standard", + "enum": [ + "standard", + "reduced-rate", + "zero-rate" + ], + "description": "Tax class." + } + } + } + ], + "_links": { + "self": "https://example.com/wp-json/wc/v1/taxes" + } + }, + "/wc/v1/taxes/(?P[\\d]+)": { + "namespace": "wc/v1", + "methods": [ + "GET", + "POST", + "PUT", + "PATCH", + "DELETE" + ], + "endpoints": [ + { + "methods": [ + "GET" + ], + "args": { + "context": { + "required": false, + "default": "view", + "enum": [ + "view", + "edit" + ], + "description": "Scope under which the request is made; determines fields present in response." + } + } + }, + { + "methods": [ + "POST", + "PUT", + "PATCH" + ], + "args": { + "country": { + "required": false, + "description": "Country ISO 3166 code." + }, + "state": { + "required": false, + "description": "State code." + }, + "postcode": { + "required": false, + "description": "Postcode/ZIP." + }, + "city": { + "required": false, + "description": "City name." + }, + "rate": { + "required": false, + "description": "Tax rate." + }, + "name": { + "required": false, + "description": "Tax rate name." + }, + "priority": { + "required": false, + "description": "Tax priority." + }, + "compound": { + "required": false, + "description": "Whether or not this is a compound rate." + }, + "shipping": { + "required": false, + "description": "Whether or not this tax rate also gets applied to shipping." + }, + "order": { + "required": false, + "description": "Indicates the order that will appear in queries." + }, + "class": { + "required": false, + "enum": [ + "standard", + "reduced-rate", + "zero-rate" + ], + "description": "Tax class." + } + } + }, + { + "methods": [ + "DELETE" + ], + "args": { + "force": { + "required": false, + "default": false, + "description": "Required to be true, as resource does not support trashing." + } + } + } + ] + }, + "/wc/v1/taxes/batch": { + "namespace": "wc/v1", + "methods": [ + "POST", + "PUT", + "PATCH" + ], + "endpoints": [ + { + "methods": [ + "POST", + "PUT", + "PATCH" + ], + "args": { + "country": { + "required": false, + "description": "Country ISO 3166 code." + }, + "state": { + "required": false, + "description": "State code." + }, + "postcode": { + "required": false, + "description": "Postcode/ZIP." + }, + "city": { + "required": false, + "description": "City name." + }, + "rate": { + "required": false, + "description": "Tax rate." + }, + "name": { + "required": false, + "description": "Tax rate name." + }, + "priority": { + "required": false, + "description": "Tax priority." + }, + "compound": { + "required": false, + "description": "Whether or not this is a compound rate." + }, + "shipping": { + "required": false, + "description": "Whether or not this tax rate also gets applied to shipping." + }, + "order": { + "required": false, + "description": "Indicates the order that will appear in queries." + }, + "class": { + "required": false, + "enum": [ + "standard", + "reduced-rate", + "zero-rate" + ], + "description": "Tax class." + } + } + } + ], + "_links": { + "self": "https://example.com/wp-json/wc/v1/taxes/batch" + } + }, + "/wc/v1/webhooks/(?P[\\d]+)/deliveries": { + "namespace": "wc/v1", + "methods": [ + "GET" + ], + "endpoints": [ + { + "methods": [ + "GET" + ], + "args": { + "context": { + "required": false, + "default": "view", + "enum": [ + "view", + "edit" + ], + "description": "Scope under which the request is made; determines fields present in response." + } + } + } + ] + }, + "/wc/v1/webhooks/(?P[\\d]+)/deliveries/(?P[\\d]+)": { + "namespace": "wc/v1", + "methods": [ + "GET" + ], + "endpoints": [ + { + "methods": [ + "GET" + ], + "args": { + "context": { + "required": false, + "default": "view", + "enum": [ + "view", + "edit" + ], + "description": "Scope under which the request is made; determines fields present in response." + } + } + } + ] + }, + "/wc/v1/webhooks": { + "namespace": "wc/v1", + "methods": [ + "GET", + "POST" + ], + "endpoints": [ + { + "methods": [ + "GET" + ], + "args": { + "context": { + "required": false, + "default": "view", + "enum": [ + "view", + "edit" + ], + "description": "Scope under which the request is made; determines fields present in response." + }, + "page": { + "required": false, + "default": 1, + "description": "Current page of the collection." + }, + "per_page": { + "required": false, + "default": 10, + "description": "Maximum number of items to be returned in result set." + }, + "search": { + "required": false, + "description": "Limit results to those matching a string." + }, + "after": { + "required": false, + "description": "Limit response to resources published after a given ISO8601 compliant date." + }, + "before": { + "required": false, + "description": "Limit response to resources published before a given ISO8601 compliant date." + }, + "exclude": { + "required": false, + "default": [], + "description": "Ensure result set excludes specific ids." + }, + "include": { + "required": false, + "default": [], + "description": "Limit result set to specific ids." + }, + "offset": { + "required": false, + "description": "Offset the result set by a specific number of items." + }, + "order": { + "required": false, + "default": "desc", + "enum": [ + "asc", + "desc" + ], + "description": "Order sort attribute ascending or descending." + }, + "orderby": { + "required": false, + "default": "date", + "enum": [ + "date", + "id", + "include", + "title", + "slug" + ], + "description": "Sort collection by object attribute." + }, + "slug": { + "required": false, + "description": "Limit result set to posts with a specific slug." + }, + "filter": { + "required": false, + "description": "Use WP Query arguments to modify the response; private query vars require appropriate authorization." + }, + "status": { + "required": false, + "default": "all", + "enum": [ + "all", + "active", + "paused", + "disabled" + ], + "description": "Limit result set to webhooks assigned a specific status." + } + } + }, + { + "methods": [ + "POST" + ], + "args": { + "name": { + "required": false, + "description": "A friendly name for the webhook." + }, + "status": { + "required": false, + "default": "active", + "enum": [ + "active", + "paused", + "disabled" + ], + "description": "Webhook status." + }, + "topic": { + "required": true + }, + "secret": { + "required": false, + "description": "Secret key used to generate a hash of the delivered webhook and provided in the request headers. This will default is a MD5 hash from the current user's ID|username if not provided." + }, + "delivery_url": { + "required": true + } + } + } + ], + "_links": { + "self": "https://example.com/wp-json/wc/v1/webhooks" + } + }, + "/wc/v1/webhooks/(?P[\\d]+)": { + "namespace": "wc/v1", + "methods": [ + "GET", + "POST", + "PUT", + "PATCH", + "DELETE" + ], + "endpoints": [ + { + "methods": [ + "GET" + ], + "args": { + "context": { + "required": false, + "default": "view", + "enum": [ + "view", + "edit" + ], + "description": "Scope under which the request is made; determines fields present in response." + } + } + }, + { + "methods": [ + "POST", + "PUT", + "PATCH" + ], + "args": { + "name": { + "required": false, + "description": "A friendly name for the webhook." + }, + "status": { + "required": false, + "enum": [ + "active", + "paused", + "disabled" + ], + "description": "Webhook status." + }, + "topic": { + "required": false, + "description": "Webhook topic." + }, + "secret": { + "required": false, + "description": "Secret key used to generate a hash of the delivered webhook and provided in the request headers. This will default is a MD5 hash from the current user's ID|username if not provided." + } + } + }, + { + "methods": [ + "DELETE" + ], + "args": { + "force": { + "required": false, + "default": false, + "description": "Required to be true, as resource does not support trashing." + } + } + } + ] + }, + "/wc/v1/webhooks/batch": { + "namespace": "wc/v1", + "methods": [ + "POST", + "PUT", + "PATCH" + ], + "endpoints": [ + { + "methods": [ + "POST", + "PUT", + "PATCH" + ], + "args": { + "name": { + "required": false, + "description": "A friendly name for the webhook." + }, + "status": { + "required": false, + "enum": [ + "active", + "paused", + "disabled" + ], + "description": "Webhook status." + }, + "topic": { + "required": false, + "description": "Webhook topic." + }, + "secret": { + "required": false, + "description": "Secret key used to generate a hash of the delivered webhook and provided in the request headers. This will default is a MD5 hash from the current user's ID|username if not provided." + } + } + } + ], + "_links": { + "self": "https://example.com/wp-json/wc/v1/webhooks/batch" + } + } + }, + "_links": { + "up": [ + { + "href": "https://example.com/wp-json/" + } + ] + } +} +``` diff --git a/source/includes/wp-api-v1/_introduction.md b/source/includes/wp-api-v1/_introduction.md new file mode 100644 index 00000000..8b8e94e2 --- /dev/null +++ b/source/includes/wp-api-v1/_introduction.md @@ -0,0 +1,253 @@ +# Introduction # + +WooCommerce (WC) 2.6+ is fully integrated with the WordPress [REST](http://en.wikipedia.org/wiki/Representational_State_Transfer) API. This allows WC data to be created, read, updated, and deleted using requests in JSON format and using WordPress REST API Authentication methods and standard HTTP verbs which are understood by most HTTP clients. + +The current WP REST API integration version is `v1` which takes a first-order position in endpoints. + +The following table shows API versions present in each major version of WooCommerce: + +| API Version | WC Version | WP Version | +|-------------|------------|------------| +| `v1` | 2.6.x or later | 4.4 or later | + +Prior to 2.6, WooCommerce had it's own REST API separate from WordPress which is now known as the legacy API. You can find the documentation for the legacy API separately. + +| API Version | WC Version | WP Version | Documentation | +|-------------|------------|------------|---------------| +| `Legacy v3` | 2.4.x or later | 4.1 or later | [Legacy v3 docs](v3.html) | +| `Legacy v2` | 2.2.x or later | 4.1 or later | [Legacy v2 docs](v2.html) | +| `Legacy v1` | 2.1.x or later | 4.1 or later | [Legacy v1 docs](v1.html) | + +## Requirements ## + +To use the latest version of the REST API you must be using: + +* WooCommerce 2.6+. +* WordPress 4.4+. +* Pretty permalinks in `Settings > Permalinks` so that the custom endpoints are supported. __Default permalinks will not work.__ +* You may access the API over either HTTP or HTTPS, but *HTTPS is recommended where possible*. + +If you use ModSecurity and see `501 Method Not Implemented` errors, see [this issue](https://github.com/woothemes/woocommerce/issues/9838) for details. + + + +## Request/Response Format ## + +The default response format is JSON. Requests with a message-body use plain JSON to set or update resource attributes. Successful requests will return a `200 OK` HTTP status. + +Some general information about responses: + +* Dates are returned in [RFC3339](http://www.ietf.org/rfc/rfc3339.txt) format in UTC timezone: `YYYY-MM-DDTHH:MM:SSZ` +* Resource IDs are returned as integers. +* Any decimal monetary amount, such as prices or totals, will be returned as strings with two decimal places. +* Other amounts, such as item counts, are returned as integers. +* Blank fields are generally included as `null` instead of being returned as blank strings or omitted. + +### JSONP Support ### + +The WP REST API supports JSONP by default. JSONP responses use the `application/javascript` content-type. You can specify the callback using the `?_jsonp` parameter for `GET` requests to have the response wrapped in a JSON function: + +
+
+ GET +
/wp-json/wc/v1?_jsonp=callback
+
+
+ +```shell +curl https://example.com/wp-json/wc/v1/products/tags/34?_jsonp=tagDetails \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('products/tags/34?_jsonp=tagDetails', function(err, data, res) { + console.log(res); +}); +``` + +```php +get('products/tags/34', ['_jsonp' => 'tagDetails'])); ?> +``` + +```python +print(wcapi.get("products/tags/34?_jsonp=tagDetails").json()) +``` + +```ruby +woocommerce.get("products/tags/34", _jsonp: "tagDetails").parsed_response +``` + +> Response: + +``` +/**/tagDetails({"id":34,"name":"Leather Shoes","slug":"leather-shoes","description":"","count":0,"_links":{"self":[{"href":"https://example.com/wp-json/wc/v1/products/tags/34"}],"collection":[{"href":"https://example.com/wp-json/wc/v1/products/tags"}]}})% +``` + +## Errors ## + +Occasionally you might encounter errors when accessing the REST API. There are four possible types: + +| Error Code | Error Type | +|------------|------------| +| `400 Bad Request` | Invalid request, e.g. using an unsupported HTTP method | +| `401 Unauthorized` | Authentication or permission error, e.g. incorrect API keys | +| `404 Not Found` | Requests to resources that don't exist or are missing | +| `500 Internal Server Error` | Server error | + +> WP REST API error example: + +```json +{ + "code": "rest_no_route", + "message": "No route was found matching the URL and request method", + "data": { + "status": 404 + } +} +``` + +> WooCommerce REST API error example: + +```json +{ + "code": "woocommerce_rest_term_invalid", + "message": "Resource doesn't exist.", + "data": { + "status": 404 + } +} +``` + +Errors return both an appropriate HTTP status code and response object which contains a `code`, `message` and `data` attribute. + +## Parameters ## + +Almost all endpoints accept optional parameters which can be passed as a HTTP query string parameter, e.g. `GET /orders?status=completed`. All parameters are documented along each endpoint. + +## Pagination ## + +Requests that return multiple items will be paginated to 10 items by default. This default can be changed by the site administrator by changing the `posts_per_page` option. Alternatively the items per page can be specified with the `?per_page` parameter: + +`GET /orders?per_page=15` + +You can specify further pages with the `?page` parameter: + +`GET /orders?page=2` + +You may also specify the offset from the first resource using the `?offset` parameter: + +`GET /orders?offset=5` + +Page number is 1-based and omitting the `?page` parameter will return the first page. + +The total number of resources and pages are always included in the `X-WP-Total` and `X-WP-TotalPages` HTTP headers. + +### Link Header ### + +Pagination info is included in the [Link Header](http://tools.ietf.org/html/rfc5988). It's recommended that you follow these values instead of building your own URLs where possible. + +``` +Link: ; rel="next", +; rel="last"` +``` + +The possible `rel` values are: + +| Value | Description | +|---------|----------------------------------------------------------| +| `next` | Shows the URL of the immediate next page of results. | +| `last` | Shows the URL of the last page of results. | +| `first` | Shows the URL of the first page of results. | +| `prev` | Shows the URL of the immediate previous page of results. | + +## Libraries and Tools ## + +- [Node.js](https://www.npmjs.com/package/woocommerce-api) Library +- [PHP](https://packagist.org/packages/automattic/woocommerce) Library +- [Python](https://pypi.python.org/pypi/WooCommerce) Library +- [Ruby](https://rubygems.org/gems/woocommerce_api) Library + +```javascript +// Install: +// npm install --save woocommerce-api + +// Setup: +var WooCommerceAPI = require('woocommerce-api'); + +var WooCommerce = new WooCommerceAPI({ + url: 'http://example.com', // Your store URL + consumerKey: 'consumer_key', // Your consumer key + consumerSecret: 'consumer_secret', // Your consumer secret + wp_api: true, // Enable the WP REST API integration + version: 'wc/v1' // WooCommerce WP REST API version +}); +``` + +```php + true, // Enable the WP REST API integration + 'version' => 'wc/v1' // WooCommerce WP REST API version + ] +); +?> +``` + +```python +# Install: +# pip install woocommerce + +# Setup: +from woocommerce import API + +wcapi = API( + url="http://example.com", # Your store URL + consumer_key="consumer_key", # Your consumer key + consumer_secret="consumer_secret", # Your consumer secret + wp_api=True, # Enable the WP REST API integration + version="wc/v1" # WooCommerce WP REST API version +) +``` + +```ruby +# Install: +# gem install woocommerce_api + +# Setup: +require "woocommerce_api" + +woocommerce = WooCommerce::API.new( + "http://example.com", # Your store URL + "consumer_key", # Your consumer key + "consumer_secret", # Your consumer secret + { + wp_json: true, # Enable the WP REST API integration + version: "v3" # WooCommerce WP REST API version + } +) +``` + + + +Some useful tools you can use to access the API include: + +* [CocoaRestClient](http://mmattozzi.github.io/cocoa-rest-client/) - A free, easy to use Mac OS X GUI client for interacting with the API, most useful when your test store has SSL enabled. +* [Paw HTTP Client](https://itunes.apple.com/us/app/paw-http-client/id584653203?mt=12) - Another excellent HTTP client for Mac OS X. +* [RESTClient, a debugger for RESTful web services](https://addons.mozilla.org/en-US/firefox/addon/restclient/) - Free Firefox add-on. +* [Advanced REST client](https://chrome.google.com/webstore/detail/advanced-rest-client/hgmloofddffdnphfgcellkdfbfbjeloo) - Free Google Chrome extension. diff --git a/source/includes/wp-api-v1/_order-notes.md b/source/includes/wp-api-v1/_order-notes.md new file mode 100644 index 00000000..d061639c --- /dev/null +++ b/source/includes/wp-api-v1/_order-notes.md @@ -0,0 +1,321 @@ +# Order notes # + +The order notes API allows you to create, view, and delete individual order notes. +Order notes are added by administrators and programmatically to store data about an order, or order events. + +## Order note properties ## + +| Attribute | Type | Description | +|-----------------|-----------|---------------------------------------------------------------------------------------------------------------------| +| `id` | integer | Unique identifier for the resource. read-only | +| `date_created` | date-time | The date the order note was created, in the site's timezone. read-only | +| `note` | string | Order note. required | +| `customer_note` | boolean | Shows/define if the note is only for reference or for the customer (the user will be notified). Default is `false`. | + +## Create an order note ## + +This API helps you to create a new note for an order. + +### HTTP request ### + +
+
+ POST +
/wp-json/wc/v1/orders/<id>/notes
+
+
+ +```shell +curl -X POST https://example.com/wp-json/wc/v1/orders/645/notes \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "note": "Order ok!!!" +}' +``` + +```javascript +var data = { + note: 'Order ok!!!' +}; + +WooCommerce.post('orders/645/notes', data, function(err, data, res) { + console.log(res); +}); +``` + +```php + 'Order ok!!!' +]; + +print_r($woocommerce->post('orders/645/notes', $data)); +?> +``` + +```python +data = { + "note": "Order ok!!!" +} + +print(wcapi.post("orders/645/notes", data).json()) +``` + +```ruby +data = { + note: "Order ok!!!" +} + +woocommerce.post("orders/645/notes", data).parsed_response +``` + +> JSON response example: + +```json +{ + "id": 51, + "date_created": "2016-05-13T20:51:55", + "note": "Order ok!!!", + "customer_note": false, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/orders/118/notes/51" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/orders/118/notes" + } + ], + "up": [ + { + "href": "https://example.com/wp-json/wc/v1/orders/118" + } + ] + } +} +``` + +## Retrieve an order note ## + +This API lets you retrieve and view a specific note from an order. + +### HTTP request ### + +
+
+ GET +
/wp-json/wc/v1/orders/<id>/notes/<note_id>
+
+
+ +```shell +curl https://example.com/wp-json/wc/v1/orders/645/notes/51 \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('orders/645/notes/51', function(err, data, res) { + console.log(res); +}); +``` + +```php +get('orders/645/notes/51')); ?> +``` + +```python +print(wcapi.get("orders/645/notes/51").json()) +``` + +```ruby +woocommerce.get("orders/645/notes/51").parsed_response +``` + +> JSON response example: + +```json +{ + "id": 51, + "date_created": "2016-05-13T20:51:55", + "note": "Order ok!!!", + "customer_note": false, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/orders/118/notes/51" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/orders/118/notes" + } + ], + "up": [ + { + "href": "https://example.com/wp-json/wc/v1/orders/118" + } + ] + } +} +``` + +## List all order notes ## + +This API helps you to view all the notes from an order. + +### HTTP request ### + +
+
+ GET +
/wp-json/wc/v1/orders/<id>/notes
+
+
+ +```shell +curl https://example.com/wp-json/wc/v1/orders/645/notes \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('orders/645/notes', function(err, data, res) { + console.log(res); +}); +``` + +```php +get('orders/645/notes')); ?> +``` + +```python +print(wcapi.get("orders/645/notes").json()) +``` + +```ruby +woocommerce.get("orders/645/notes").parsed_response +``` + +> JSON response example: + +```json +[ + { + "id": 51, + "date_created": "2016-05-13T20:51:55", + "note": "Order ok!!!", + "customer_note": false, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/orders/118/notes/51" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/orders/118/notes" + } + ], + "up": [ + { + "href": "https://example.com/wp-json/wc/v1/orders/118" + } + ] + } + }, + { + "id": 46, + "date_created": "2016-05-03T18:10:43", + "note": "Order status changed from Pending Payment to Processing.", + "customer_note": false, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/orders/118/notes/46" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/orders/118/notes" + } + ], + "up": [ + { + "href": "https://example.com/wp-json/wc/v1/orders/118" + } + ] + } + } +] +``` + +## Delete an order note ## + +This API helps you delete an order note. + +### HTTP request ### + +
+
+ DELETE +
/wp-json/wc/v1/orders/<id>/notes/<note_id>
+
+
+ +```shell +curl -X DELETE https://example.com/wp-json/wc/v1/orders/645/notes/51?force=true \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.delete('orders/645/notes/51?force=true', function(err, data, res) { + console.log(res); +}); +``` + +```php +delete('orders/645/notes/51', ['force' => true])); ?> +``` + +```python +print(wcapi.delete("orders/645/notes/51?force=true").json()) +``` + +```ruby +woocommerce.delete("orders/645/notes/51", force: true).parsed_response +``` + +> JSON response example: + +```json +{ + "id": 51, + "date_created": "2016-05-13T20:51:55", + "note": "Order ok!!!", + "customer_note": false, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/orders/118/notes/51" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/orders/118/notes" + } + ], + "up": [ + { + "href": "https://example.com/wp-json/wc/v1/orders/118" + } + ] + } +} +``` +#### Available parameters #### + +| Parameter | Type | Description | +|-----------|--------|---------------------------------------------------------------| +| `force` | string | Required to be `true`, as resource does not support trashing. | diff --git a/source/includes/wp-api-v1/_order-refunds.md b/source/includes/wp-api-v1/_order-refunds.md new file mode 100644 index 00000000..172538a9 --- /dev/null +++ b/source/includes/wp-api-v1/_order-refunds.md @@ -0,0 +1,387 @@ +# Refunds # + +The refunds API allows you to create, view, and delete individual refunds. + +## Refund properties ## + +| Attribute | Type | Description | +|----------------|-----------|----------------------------------------------------------------------------------------------------------| +| `id` | integer | Unique identifier for the resource. read-only | +| `date_created` | date-time | The date the order refund was created, in the site's timezone. read-only | +| `amount` | string | Refund amount. required | +| `reason` | string | Reason for refund. | +| `line_items` | array | Line items data. See [Refunds Line Items Properties](#refund-line-item-properties). | + +### Refund line item properties ### + +| Attribute | Type | Description | +|----------------|---------|------------------------------------------------------------------------------------------------| +| `id` | integer | Item ID. read-only | +| `name` | string | Product name. read-only | +| `sku` | string | Product SKU. read-only | +| `product_id` | integer | Product ID. | +| `variation_id` | integer | Variation ID, if applicable. | +| `quantity` | integer | Quantity ordered. | +| `tax_class` | string | Tax class of product. read-only | +| `price` | string | Product price. read-only | +| `subtotal` | string | Line subtotal (before discounts). | +| `subtotal_tax` | string | Line subtotal tax (before discounts). | +| `total` | string | Line total (after discounts). | +| `total_tax` | string | Line total tax (after discounts). | +| `taxes` | array | Line total tax with `id`, `total` and `subtotal`. read-only | +| `meta` | array | Line item meta data with `key`, `label` and `value`. read-only | + +## Create a refund ## + +This API helps you to create a new refund for an order. + +### HTTP request ### + +
+
+ POST +
/wp-json/wc/v1/orders/<id>/refunds
+
+
+ +```shell +curl -X POST https://example.com/wp-json/wc/v1/orders/116/refunds \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "amount": "10" +}' +``` + +```javascript +var data = { + amount: '10' +}; + +WooCommerce.post('orders/116/refunds', data, function(err, data, res) { + console.log(res); +}); +``` + +```php + '10' +]; + +print_r($woocommerce->post('orders/116/refunds', $data)); +?> +``` + +```python +data = { + "amount": "10" +} + +print(wcapi.post("orders/116/refunds", data).json()) +``` + +```ruby +data = { + amount: "10" +} + +woocommerce.post("orders/116/refunds", data).parsed_response +``` + +> JSON response example: + +```json +{ + "id": 150, + "date_created": "2016-05-30T17:28:05", + "amount": "10.00", + "reason": "", + "line_items": [], + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/orders/116/refunds/150" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/orders/116/refunds" + } + ], + "up": [ + { + "href": "https://example.com/wp-json/wc/v1/orders/116" + } + ] + } +} +``` + +## Retrieve a refund ## + +This API lets you retrieve and view a specific refund from an order. + +### HTTP request ### + +
+
+ GET +
/wp-json/wc/v1/orders/<id>/refunds/<refund_id>
+
+
+ +```shell +curl https://example.com/wp-json/wc/v1/orders/116/refunds/150 \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('orders/116/refunds/150', function(err, data, res) { + console.log(res); +}); +``` + +```php +get('orders/116/refunds/150')); ?> +``` + +```python +print(wcapi.get("orders/116/refunds/150").json()) +``` + +```ruby +woocommerce.get("orders/116/refunds/150").parsed_response +``` + +> JSON response example: + +```json +{ + "id": 150, + "date_created": "2016-05-30T17:28:05", + "amount": "10.00", + "reason": "", + "line_items": [], + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/orders/116/refunds/150" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/orders/116/refunds" + } + ], + "up": [ + { + "href": "https://example.com/wp-json/wc/v1/orders/116" + } + ] + } +} +``` + +#### Available parameters #### + +| Parameter | Type | Description | +|-----------|--------|---------------------------------------------------| +| `dp` | string | Number of decimal points to use in each resource. | + +## List all refunds ## + +This API helps you to view all the refunds from an order. + +### HTTP request ### + +
+
+ GET +
/wp-json/wc/v1/orders/<id>/refunds
+
+
+ +```shell +curl https://example.com/wp-json/wc/v1/orders/116/refunds \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('orders/116/refunds', function(err, data, res) { + console.log(res); +}); +``` + +```php +get('orders/116/refunds')); ?> +``` + +```python +print(wcapi.get("orders/116/refunds").json()) +``` + +```ruby +woocommerce.get("orders/116/refunds").parsed_response +``` + +> JSON response example: + +```json +[ + { + "id": 151, + "date_created": "2016-05-30T17:31:48", + "amount": "2.00", + "reason": "", + "line_items": [ + { + "id": 11, + "name": "Woo Single #2", + "sku": "12345", + "product_id": 99, + "variation_id": 0, + "quantity": -1, + "tax_class": "", + "price": "-2.00", + "subtotal": "-2.00", + "subtotal_tax": "0.00", + "total": "-2.00", + "total_tax": "0.00", + "taxes": [], + "meta": [] + } + ], + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/orders/116/refunds/151" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/orders/116/refunds" + } + ], + "up": [ + { + "href": "https://example.com/wp-json/wc/v1/orders/116" + } + ] + } + }, + { + "id": 150, + "date_created": "2016-05-30T17:28:05", + "amount": "10.00", + "reason": "", + "line_items": [], + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/orders/116/refunds/150" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/orders/116/refunds" + } + ], + "up": [ + { + "href": "https://example.com/wp-json/wc/v1/orders/116" + } + ] + } + } +] +``` + +#### Available parameters #### + +| Parameter | Type | Description | +|------------|---------|---------------------------------------------------------------------------------------------------------------| +| `context` | string | Scope under which the request is made; determines fields present in response. Options: `view` and `edit`. | +| `page` | integer | Current page of the collection. | +| `per_page` | integer | Maximum number of items to be returned in result set. | +| `search` | string | Limit results to those matching a string. | +| `after` | string | Limit response to resources published after a given ISO8601 compliant date. | +| `before` | string | Limit response to resources published before a given ISO8601 compliant date. | +| `exclude` | string | Ensure result set excludes specific ids. | +| `include` | string | Limit result set to specific ids. | +| `offset` | integer | Offset the result set by a specific number of items. | +| `order` | string | Order sort attribute ascending or descending. Default is `asc`. Options: `asc` and `desc`. | +| `orderby` | string | Sort collection by object attribute. Default is `date`, Options: `date`, `id`, `include`, `title` and `slug`. | +| `filter` | string | Use WP Query arguments to modify the response; private query vars require appropriate authorization. | +| `dp` | string | Number of decimal points to use in each resource. | + +## Delete a refund ## + +This API helps you delete an order refund. + +### HTTP request ### + +
+
+ DELETE +
/wp-json/wc/v1/orders/<id>/refunds/<refund_id>
+
+
+ +```shell +curl -X DELETE https://example.com/wp-json/wc/v1/orders/116/refunds/150?force=true \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.delete('orders/116/refunds/150?force=true', function(err, data, res) { + console.log(res); +}); +``` + +```php +delete('orders/116/refunds/150', ['force' => true])); ?> +``` + +```python +print(wcapi.delete("orders/116/refunds/150?force=true").json()) +``` + +```ruby +woocommerce.delete("orders/116/refunds/150", force: true).parsed_response +``` + +> JSON response example: + +```json +{ + "id": 150, + "date_created": "2016-05-30T17:28:05", + "amount": "10.00", + "reason": "", + "line_items": [], + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/orders/116/refunds/150" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/orders/116/refunds" + } + ], + "up": [ + { + "href": "https://example.com/wp-json/wc/v1/orders/116" + } + ] + } +} +``` + +#### Available parameters #### + +| Parameter | Type | Description | +|-----------|--------|---------------------------------------------------------------| +| `force` | string | Required to be `true`, as resource does not support trashing. | diff --git a/source/includes/wp-api-v1/_orders.md b/source/includes/wp-api-v1/_orders.md new file mode 100644 index 00000000..ca83eafc --- /dev/null +++ b/source/includes/wp-api-v1/_orders.md @@ -0,0 +1,2582 @@ +# Orders # + +The orders API allows you to create, view, update, and delete individual, or a batch, of orders. + +## Order properties ## + +| Attribute | Type | Description | +|------------------------|-----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `id` | integer | Unique identifier for the resource. read-only | +| `parent_id` | integer | Parent order ID. | +| `status` | string | Order status. Default is `pending`. Options (plugins may include new status): `pending`, `processing`, `on-hold`, `completed`, `cancelled`, `refunded` and `failed`. | +| `order_key` | string | Order key. read-only | +| `currency` | string | Currency the order was created with, in ISO format, e.g `USD`. Default is the current store currency. | +| `version` | string | Version of WooCommerce when the order was made. read-only | +| `prices_include_tax` | boolean | Shows if the prices included tax during checkout. read-only | +| `date_created` | date-time | The date the order was created, in the site's timezone. read-only | +| `date_modified` | date-time | The date the order was last modified, in the site's timezone. read-only | +| `customer_id` | integer | User ID who owns the order. Use `0` for guests. Default is `0`. | +| `discount_total` | string | Total discount amount for the order. read-only | +| `discount_tax` | string | Total discount tax amount for the order. read-only | +| `shipping_total` | string | Total shipping amount for the order. read-only | +| `shipping_tax` | string | Total shipping tax amount for the order. read-only | +| `cart_tax` | string | Sum of line item taxes only. read-only | +| `total` | string | Grand total. read-only | +| `total_tax` | string | Sum of all taxes. read-only | +| `billing` | array | Billing address. See [Customer Billing Address Properties](#billing-address-properties). | +| `shipping` | array | Shipping address. See [Customer Shipping Address Properties](#shipping-address-properties). | +| `payment_method` | string | Payment method ID. | +| `payment_method_title` | string | Payment method title. | +| `set_paid` | boolean | Define if the order is paid. It will set the status to processing and reduce stock items. Default is `false`. write-only | +| `transaction_id` | string | Unique transaction ID. In write-mode only is available if `set_paid` is `true`. | +| `customer_ip_address` | string | Customer's IP address. read-only | +| `customer_user_agent` | string | User agent of the customer. read-only | +| `created_via` | string | Shows where the order was created. read-only | +| `customer_note` | string | Note left by customer during checkout. | +| `date_completed` | date-time | The date the order was completed, in the site's timezone. read-only | +| `date_paid` | date-time | The date the order has been paid, in the site's timezone. read-only | +| `cart_hash` | string | MD5 hash of cart items to ensure orders are not modified. read-only | +| `line_items` | array | Line items data. See [Line Items Properties](#line-item-properties). | +| `tax_lines` | array | Tax lines data. See [Tax Lines Properties](#tax-line-properties). read-only | +| `shipping_lines` | array | Shipping lines data. See [Shipping Lines Properties](#shipping-line-properties). | +| `fee_lines` | array | Fee lines data. See [Fee Lines Properites](#fee-line-properties). | +| `coupon_lines` | array | Coupons line data. See [Coupon Lines Properties](#coupon-line-properties). | + +### Line item properties ### + +| Attribute | Type | Description | +|----------------|---------|------------------------------------------------------------------------------------------------| +| `id` | integer | Item ID. read-only | +| `name` | string | Product name. read-only | +| `sku` | string | Product SKU. read-only | +| `product_id` | integer | Product ID. | +| `variation_id` | integer | Variation ID, if applicable. | +| `quantity` | integer | Quantity ordered. | +| `tax_class` | string | Tax class of product. read-only | +| `price` | string | Product price. read-only | +| `subtotal` | string | Line subtotal (before discounts). | +| `subtotal_tax` | string | Line subtotal tax (before discounts). | +| `total` | string | Line total (after discounts). | +| `total_tax` | string | Line total tax (after discounts). | +| `taxes` | array | Line taxes with `id`, `total` and `subtotal`. read-only | +| `meta` | array | Line item meta data with `key`, `label` and `value`. read-only | + +### Tax line properties ### + +| Attribute | Type | Description | +|----------------------|---------|-------------------------------------------------------------------------------------------------------------------------------------| +| `id` | integer | Item ID. read-only | +| `rate_code` | string | Tax rate code. read-only | +| `rate_id` | string | Tax rate ID. read-only | +| `label` | string | Tax rate label. read-only | +| `compound` | boolean | Show if is a compound tax rate. Compound tax rates are applied on top of other tax rates. read-only | +| `tax_total` | string | Tax total (not including shipping taxes). read-only | +| `shipping_tax_total` | string | Shipping tax total. read-only | + +### Shipping line properties ### + +| Attribute | Type | Description | +|----------------|---------|-----------------------------------------------------------------------------| +| `id` | integer | Item ID. read-only | +| `method_title` | string | Shipping method name. | +| `method_id` | string | Shipping method ID. required | +| `total` | string | Line total (after discounts). | +| `total_tax` | string | Line total tax (after discounts). read-only | +| `taxes` | array | Line taxes with `id` and `total`. read-only | + +### Fee line properties ### + +| Attribute | Type | Description | +|--------------|---------|-----------------------------------------------------------------------------------------| +| `id` | integer | Item ID. read-only | +| `name` | string | Fee name. required | +| `tax_class` | string | Tax class. required if the fee is taxable | +| `tax_status` | string | Tax status of fee. Set to `taxable` if need apply taxes. | +| `total` | string | Line total (after discounts). | +| `total_tax` | string | Line total tax (after discounts). | +| `taxes` | array | Line taxes with `id`, `total` and `subtotal`. read-only | + +### Coupon line properties ### + +| Attribute | Type | Description | +|----------------|---------|---------------------------------------------------------------| +| `id` | integer | Item ID. read-only | +| `code` | string | Coupon code. required | +| `discount` | string | Discount total. required | +| `discount_tax` | string | Discount total tax. read-only | + +## Create an order ## + +This API helps you to create a new order. + +### HTTP request ### + +
+
+ POST +
/wp-json/wc/v1/orders
+
+
+ +> Example of create a paid order: + +```shell +curl -X POST https://example.com/wp-json/wc/v1/orders \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "payment_method": "bacs", + "payment_method_title": "Direct Bank Transfer", + "set_paid": true, + "billing": { + "first_name": "John", + "last_name": "Doe", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US", + "email": "john.doe@example.com", + "phone": "(555) 555-5555" + }, + "shipping": { + "first_name": "John", + "last_name": "Doe", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US" + }, + "line_items": [ + { + "product_id": 93, + "quantity": 2 + }, + { + "product_id": 22, + "variation_id": 23, + "quantity": 1 + } + ], + "shipping_lines": [ + { + "method_id": "flat_rate", + "method_title": "Flat Rate", + "total": 10 + } + ] +}' +``` + +```javascript +var data = { + payment_method: 'bacs', + payment_method_title: 'Direct Bank Transfer', + set_paid: true, + billing: { + first_name: 'John', + last_name: 'Doe', + address_1: '969 Market', + address_2: '', + city: 'San Francisco', + state: 'CA', + postcode: '94103', + country: 'US', + email: 'john.doe@example.com', + phone: '(555) 555-5555' + }, + shipping: { + first_name: 'John', + last_name: 'Doe', + address_1: '969 Market', + address_2: '', + city: 'San Francisco', + state: 'CA', + postcode: '94103', + country: 'US' + }, + line_items: [ + { + product_id: 93, + quantity: 2 + }, + { + product_id: 22, + variation_id: 23, + quantity: 1 + } + ], + shipping_lines: [ + { + method_id: 'flat_rate', + method_title: 'Flat Rate', + total: 10 + } + ] +}; + +WooCommerce.post('orders', data, function(err, data, res) { + console.log(res); +}); +``` + +```php + 'bacs', + 'payment_method_title' => 'Direct Bank Transfer', + 'set_paid' => true, + 'billing' => [ + 'first_name' => 'John', + 'last_name' => 'Doe', + 'address_1' => '969 Market', + 'address_2' => '', + 'city' => 'San Francisco', + 'state' => 'CA', + 'postcode' => '94103', + 'country' => 'US', + 'email' => 'john.doe@example.com', + 'phone' => '(555) 555-5555' + ], + 'shipping' => [ + 'first_name' => 'John', + 'last_name' => 'Doe', + 'address_1' => '969 Market', + 'address_2' => '', + 'city' => 'San Francisco', + 'state' => 'CA', + 'postcode' => '94103', + 'country' => 'US' + ], + 'line_items' => [ + [ + 'product_id' => 93, + 'quantity' => 2 + ], + [ + 'product_id' => 22, + 'variation_id' => 23, + 'quantity' => 1 + ] + ], + 'shipping_lines' => [ + [ + 'method_id' => 'flat_rate', + 'method_title' => 'Flat Rate', + 'total' => 10 + ] + ] +]; + +print_r($woocommerce->post('orders', $data)); +?> +``` + +```python +data = { + "payment_method": "bacs", + "payment_method_title": "Direct Bank Transfer", + "set_paid": True, + "billing": { + "first_name": "John", + "last_name": "Doe", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US", + "email": "john.doe@example.com", + "phone": "(555) 555-5555" + }, + "shipping": { + "first_name": "John", + "last_name": "Doe", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US" + }, + "line_items": [ + { + "product_id": 93, + "quantity": 2 + }, + { + "product_id": 22, + "variation_id": 23, + "quantity": 1 + } + ], + "shipping_lines": [ + { + "method_id": "flat_rate", + "method_title": "Flat Rate", + "total": 10 + } + ] +} + +print(wcapi.post("orders", data).json()) +``` + +```ruby +data = { + payment_method: "bacs", + payment_method_title: "Direct Bank Transfer", + set_paid: true, + billing: { + first_name: "John", + last_name: "Doe", + address_1: "969 Market", + address_2: "", + city: "San Francisco", + state: "CA", + postcode: "94103", + country: "US", + email: "john.doe@example.com", + phone: "(555) 555-5555" + }, + shipping: { + first_name: "John", + last_name: "Doe", + address_1: "969 Market", + address_2: "", + city: "San Francisco", + state: "CA", + postcode: "94103", + country: "US" + }, + line_items: [ + { + product_id: 93, + quantity: 2 + }, + { + product_id: 22, + variation_id: 23, + quantity: 1 + } + ], + shipping_lines: [ + { + method_id: "flat_rate", + method_title: "Flat Rate", + total: 10 + } + ] +} + +woocommerce.post("orders", data).parsed_response +``` + +> JSON response example: + +```json +{ + "id": 154, + "parent_id": 0, + "status": "processing", + "order_key": "wc_order_574cc02467274", + "currency": "USD", + "version": "2.6.0", + "prices_include_tax": false, + "date_created": "2016-05-30T22:35:16", + "date_modified": "2016-05-30T22:35:16", + "customer_id": 0, + "discount_total": "0.00", + "discount_tax": "0.00", + "shipping_total": "10.00", + "shipping_tax": "0.00", + "cart_tax": "1.95", + "total": "37.95", + "total_tax": "1.95", + "billing": { + "first_name": "John", + "last_name": "Doe", + "company": "", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US", + "email": "john.doe@example.com", + "phone": "(555) 555-5555" + }, + "shipping": { + "first_name": "John", + "last_name": "Doe", + "company": "", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US" + }, + "payment_method": "bacs", + "payment_method_title": "bacs", + "transaction_id": "", + "customer_ip_address": "127.0.0.1", + "customer_user_agent": "curl/7.47.0", + "created_via": "rest-api", + "customer_note": "", + "date_completed": "2016-05-30T19:35:16", + "date_paid": "2016-05-30 19:35:25", + "cart_hash": "", + "line_items": [ + { + "id": 18, + "name": "Woo Single #1", + "sku": "", + "product_id": 93, + "variation_id": 0, + "quantity": 2, + "tax_class": "", + "price": "3.00", + "subtotal": "6.00", + "subtotal_tax": "0.45", + "total": "6.00", + "total_tax": "0.45", + "taxes": [ + { + "id": 75, + "total": 0.45, + "subtotal": 0.45 + } + ], + "meta": [] + }, + { + "id": 19, + "name": "Ship Your Idea", + "sku": "", + "product_id": 22, + "variation_id": 23, + "quantity": 1, + "tax_class": "", + "price": "20.00", + "subtotal": "20.00", + "subtotal_tax": "1.50", + "total": "20.00", + "total_tax": "1.50", + "taxes": [ + { + "id": 75, + "total": 1.5, + "subtotal": 1.5 + } + ], + "meta": [ + { + "key": "pa_color", + "label": "Color", + "value": "Black" + } + ] + } + ], + "tax_lines": [ + { + "id": 21, + "rate_code": "US-CA-STATE TAX", + "rate_id": "75", + "label": "State Tax", + "compound": false, + "tax_total": "1.95", + "shipping_tax_total": "0.00" + } + ], + "shipping_lines": [ + { + "id": 20, + "method_title": "Flat Rate", + "method_id": "flat_rate", + "total": "10.00", + "total_tax": "0.00", + "taxes": [] + } + ], + "fee_lines": [], + "coupon_lines": [], + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/orders/154" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/orders" + } + ] + } +} +``` + +## Retrieve an order ## + +This API lets you retrieve and view a specific order. + +### HTTP request ### + +
+
+ GET +
/wp-json/wc/v1/orders/<id>
+
+
+ +```shell +curl https://example.com/wp-json/wc/v1/orders/154 \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('orders/154', function(err, data, res) { + console.log(res); +}); +``` + +```php +get('orders/154')); ?> +``` + +```python +print(wcapi.get("orders/154").json()) +``` + +```ruby +woocommerce.get("orders/154").parsed_response +``` + +> JSON response example: + +```json +{ + "id": 154, + "parent_id": 0, + "status": "processing", + "order_key": "wc_order_574cc02467274", + "currency": "USD", + "version": "2.6.0", + "prices_include_tax": false, + "date_created": "2016-05-30T22:35:16", + "date_modified": "2016-05-30T22:35:16", + "customer_id": 0, + "discount_total": "0.00", + "discount_tax": "0.00", + "shipping_total": "10.00", + "shipping_tax": "0.00", + "cart_tax": "1.95", + "total": "37.95", + "total_tax": "1.95", + "billing": { + "first_name": "John", + "last_name": "Doe", + "company": "", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US", + "email": "john.doe@example.com", + "phone": "(555) 555-5555" + }, + "shipping": { + "first_name": "John", + "last_name": "Doe", + "company": "", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US" + }, + "payment_method": "bacs", + "payment_method_title": "bacs", + "transaction_id": "", + "customer_ip_address": "127.0.0.1", + "customer_user_agent": "curl/7.47.0", + "created_via": "rest-api", + "customer_note": "", + "date_completed": "2016-05-30T19:35:16", + "date_paid": "2016-05-30 19:35:25", + "cart_hash": "", + "line_items": [ + { + "id": 18, + "name": "Woo Single #1", + "sku": "", + "product_id": 93, + "variation_id": 0, + "quantity": 2, + "tax_class": "", + "price": "3.00", + "subtotal": "6.00", + "subtotal_tax": "0.45", + "total": "6.00", + "total_tax": "0.45", + "taxes": [ + { + "id": 75, + "total": 0.45, + "subtotal": 0.45 + } + ], + "meta": [] + }, + { + "id": 19, + "name": "Ship Your Idea", + "sku": "", + "product_id": 22, + "variation_id": 23, + "quantity": 1, + "tax_class": "", + "price": "20.00", + "subtotal": "20.00", + "subtotal_tax": "1.50", + "total": "20.00", + "total_tax": "1.50", + "taxes": [ + { + "id": 75, + "total": 1.5, + "subtotal": 1.5 + } + ], + "meta": [ + { + "key": "pa_color", + "label": "Color", + "value": "Black" + } + ] + } + ], + "tax_lines": [ + { + "id": 21, + "rate_code": "US-CA-STATE TAX", + "rate_id": "75", + "label": "State Tax", + "compound": false, + "tax_total": "1.95", + "shipping_tax_total": "0.00" + } + ], + "shipping_lines": [ + { + "id": 20, + "method_title": "Flat Rate", + "method_id": "flat_rate", + "total": "10.00", + "total_tax": "0.00", + "taxes": [] + } + ], + "fee_lines": [], + "coupon_lines": [], + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/orders/154" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/orders" + } + ] + } +} +``` + +#### Available parameters #### + +| Parameter | Type | Description | +|-----------|--------|---------------------------------------------------| +| `dp` | string | Number of decimal points to use in each resource. | + +## List all orders ## + +This API helps you to view all the orders. + +### HTTP request ### + +
+
+ GET +
/wp-json/wc/v1/orders
+
+
+ +```shell +curl https://example.com/wp-json/wc/v1/orders \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('orders', function(err, data, res) { + console.log(res); +}); +``` + +```php +get('orders')); ?> +``` + +```python +print(wcapi.get("orders").json()) +``` + +```ruby +woocommerce.get("orders").parsed_response +``` + +> JSON response example: + +```json +[ + { + "id": 154, + "parent_id": 0, + "status": "processing", + "order_key": "wc_order_574cc02467274", + "currency": "USD", + "version": "2.6.0", + "prices_include_tax": false, + "date_created": "2016-05-30T22:35:16", + "date_modified": "2016-05-30T22:35:16", + "customer_id": 0, + "discount_total": "0.00", + "discount_tax": "0.00", + "shipping_total": "10.00", + "shipping_tax": "0.00", + "cart_tax": "1.95", + "total": "37.95", + "total_tax": "1.95", + "billing": { + "first_name": "John", + "last_name": "Doe", + "company": "", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US", + "email": "john.doe@example.com", + "phone": "(555) 555-5555" + }, + "shipping": { + "first_name": "John", + "last_name": "Doe", + "company": "", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US" + }, + "payment_method": "bacs", + "payment_method_title": "bacs", + "transaction_id": "", + "customer_ip_address": "127.0.0.1", + "customer_user_agent": "curl/7.47.0", + "created_via": "rest-api", + "customer_note": "", + "date_completed": "2016-05-30T19:35:16", + "date_paid": "2016-05-30 19:35:25", + "cart_hash": "", + "line_items": [ + { + "id": 18, + "name": "Woo Single #1", + "sku": "", + "product_id": 93, + "variation_id": 0, + "quantity": 2, + "tax_class": "", + "price": "3.00", + "subtotal": "6.00", + "subtotal_tax": "0.45", + "total": "6.00", + "total_tax": "0.45", + "taxes": [ + { + "id": 75, + "total": 0.45, + "subtotal": 0.45 + } + ], + "meta": [] + }, + { + "id": 19, + "name": "Ship Your Idea", + "sku": "", + "product_id": 22, + "variation_id": 23, + "quantity": 1, + "tax_class": "", + "price": "20.00", + "subtotal": "20.00", + "subtotal_tax": "1.50", + "total": "20.00", + "total_tax": "1.50", + "taxes": [ + { + "id": 75, + "total": 1.5, + "subtotal": 1.5 + } + ], + "meta": [ + { + "key": "pa_color", + "label": "Color", + "value": "Black" + } + ] + } + ], + "tax_lines": [ + { + "id": 21, + "rate_code": "US-CA-STATE TAX", + "rate_id": "75", + "label": "State Tax", + "compound": false, + "tax_total": "1.95", + "shipping_tax_total": "0.00" + } + ], + "shipping_lines": [ + { + "id": 20, + "method_title": "Flat Rate", + "method_id": "flat_rate", + "total": "10.00", + "total_tax": "0.00", + "taxes": [] + } + ], + "fee_lines": [], + "coupon_lines": [], + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/orders/154" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/orders" + } + ] + } + }, + { + "id": 116, + "parent_id": 0, + "status": "processing", + "order_key": "wc_order_5728e6e53d2a4", + "currency": "USD", + "version": "2.6.0", + "prices_include_tax": false, + "date_created": "2016-05-03T17:59:00", + "date_modified": "2016-05-30T22:37:31", + "customer_id": 1, + "discount_total": "0.00", + "discount_tax": "0.00", + "shipping_total": "10.00", + "shipping_tax": "0.00", + "cart_tax": "0.00", + "total": "14.00", + "total_tax": "0.00", + "billing": { + "first_name": "John", + "last_name": "Doe", + "company": "", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US", + "email": "john.doe@claudiosmweb.com", + "phone": "(555) 555-5555" + }, + "shipping": { + "first_name": "John", + "last_name": "Doe", + "company": "", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US" + }, + "payment_method": "bacs", + "payment_method_title": "Direct Bank Transfer", + "transaction_id": "", + "customer_ip_address": "127.0.0.1", + "customer_user_agent": "curl/7.47.0", + "created_via": "", + "customer_note": "", + "date_completed": "2016-05-30T19:35:16", + "date_paid": "2016-05-03 14:59:12", + "cart_hash": "", + "line_items": [ + { + "id": 6, + "name": "Woo Single #2", + "sku": "12345", + "product_id": 99, + "variation_id": 0, + "quantity": 2, + "tax_class": "", + "price": "2.00", + "subtotal": "4.00", + "subtotal_tax": "0.00", + "total": "4.00", + "total_tax": "0.00", + "taxes": [], + "meta": [] + } + ], + "tax_lines": [], + "shipping_lines": [ + { + "id": 7, + "method_title": "Flat Rate", + "method_id": "flat_rate", + "total": "10.00", + "total_tax": "0.00", + "taxes": [] + } + ], + "fee_lines": [], + "coupon_lines": [], + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/orders/116" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/orders" + } + ], + "customer": [ + { + "href": "https://example.com/wp-json/wc/v1/customers/1" + } + ] + } + } +] +``` + +#### Available parameters #### + +| Parameter | Type | Description | +|------------|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `context` | string | Scope under which the request is made; determines fields present in response. Options: `view` and `edit`. | +| `page` | integer | Current page of the collection. | +| `per_page` | integer | Maximum number of items to be returned in result set. | +| `search` | string | Limit results to those matching a string. | +| `after` | string | Limit response to resources published after a given ISO8601 compliant date. | +| `before` | string | Limit response to resources published before a given ISO8601 compliant date. | +| `exclude` | string | Ensure result set excludes specific ids. | +| `include` | string | Limit result set to specific ids. | +| `offset` | integer | Offset the result set by a specific number of items. | +| `order` | string | Order sort attribute ascending or descending. Default is `asc`. Options: `asc` and `desc`. | +| `orderby` | string | Sort collection by object attribute. Default is `date`, Options: `date`, `id`, `include`, `title` and `slug`. | +| `filter` | string | Use WP Query arguments to modify the response; private query vars require appropriate authorization. | +| `status` | string | Limit result set to orders assigned a specific status. Default is `any`. Options (plugins may add new status): `any`, `pending`, `processing`, `on-hold`, `completed`, `cancelled`, `refunded` and `failed`. | +| `customer` | string | Limit result set to orders assigned a specific customer. | +| `product` | string | Limit result set to orders assigned a specific product. | +| `dp` | string | Number of decimal points to use in each resource. | + +## Update an Order ## + +This API lets you make changes to an order. + +### HTTP Request ### + +
+
+ PUT +
/wp-json/wc/v1/orders/<id>
+
+
+ +```shell +curl -X PUT https://example.com/wp-json/wc/v1/orders/154 \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "status": "completed" +}' +``` + +```javascript +var data = { + status: 'completed' +}; + +WooCommerce.put('orders/154', data, function(err, data, res) { + console.log(res); +}); +``` + +```php + 'completed' +]; + +print_r($woocommerce->put('orders/154', $data)); +?> +``` + +```python +data = { + "status": "completed" +} + +print(wcapi.put("orders/154", data).json()) +``` + +```ruby +data = { + status: "completed" +} + +woocommerce.put("orders/154", data).parsed_response +``` + +> JSON response example: + +```json +{ + "id": 154, + "parent_id": 0, + "status": "completed", + "order_key": "wc_order_574cc02467274", + "currency": "USD", + "version": "2.6.0", + "prices_include_tax": false, + "date_created": "2016-05-30T22:35:16", + "date_modified": "2016-05-30T22:46:16", + "customer_id": 0, + "discount_total": "0.00", + "discount_tax": "0.00", + "shipping_total": "10.00", + "shipping_tax": "0.00", + "cart_tax": "1.95", + "total": "37.95", + "total_tax": "1.95", + "billing": { + "first_name": "John", + "last_name": "Doe", + "company": "", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US", + "email": "john.doe@example.com", + "phone": "(555) 555-5555" + }, + "shipping": { + "first_name": "John", + "last_name": "Doe", + "company": "", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US" + }, + "payment_method": "bacs", + "payment_method_title": "bacs", + "transaction_id": "", + "customer_ip_address": "127.0.0.1", + "customer_user_agent": "curl/7.47.0", + "created_via": "rest-api", + "customer_note": "", + "date_completed": "2016-05-30T19:47:46", + "date_paid": "2016-05-30 19:35:25", + "cart_hash": "", + "line_items": [ + { + "id": 18, + "name": "Woo Single #1", + "sku": "", + "product_id": 93, + "variation_id": 0, + "quantity": 2, + "tax_class": "", + "price": "3.00", + "subtotal": "6.00", + "subtotal_tax": "0.45", + "total": "6.00", + "total_tax": "0.45", + "taxes": [ + { + "id": 75, + "total": 0.45, + "subtotal": 0.45 + } + ], + "meta": [] + }, + { + "id": 19, + "name": "Ship Your Idea", + "sku": "", + "product_id": 22, + "variation_id": 23, + "quantity": 1, + "tax_class": "", + "price": "20.00", + "subtotal": "20.00", + "subtotal_tax": "1.50", + "total": "20.00", + "total_tax": "1.50", + "taxes": [ + { + "id": 75, + "total": 1.5, + "subtotal": 1.5 + } + ], + "meta": [ + { + "key": "pa_color", + "label": "Color", + "value": "Black" + } + ] + } + ], + "tax_lines": [ + { + "id": 21, + "rate_code": "US-CA-STATE TAX", + "rate_id": "75", + "label": "State Tax", + "compound": false, + "tax_total": "1.95", + "shipping_tax_total": "0.00" + } + ], + "shipping_lines": [ + { + "id": 20, + "method_title": "Flat Rate", + "method_id": "flat_rate", + "total": "10.00", + "total_tax": "0.00", + "taxes": [] + } + ], + "fee_lines": [], + "coupon_lines": [], + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/orders/154" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/orders" + } + ] + } +} +``` + +## Delete an order ## + +This API helps you delete an order. + +### HTTP request ### + +
+
+ DELETE +
/wp-json/wc/v1/orders/<id>
+
+
+ +```shell +curl -X DELETE https://example.com/wp-json/wc/v1/orders/154?force=true \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.delete('orders/154?force=true', function(err, data, res) { + console.log(res); +}); +``` + +```php +delete('orders/154', ['force' => true])); ?> +``` + +```python +print(wcapi.delete("orders/154?force=true").json()) +``` + +```ruby +woocommerce.delete("orders/154", force: true).parsed_response +``` + +> JSON response example: + +```json +{ + "id": 154, + "parent_id": 0, + "status": "completed", + "order_key": "wc_order_574cc02467274", + "currency": "USD", + "version": "2.6.0", + "prices_include_tax": false, + "date_created": "2016-05-30T22:35:16", + "date_modified": "2016-05-30T22:46:16", + "customer_id": 0, + "discount_total": "0.00", + "discount_tax": "0.00", + "shipping_total": "10.00", + "shipping_tax": "0.00", + "cart_tax": "1.95", + "total": "37.95", + "total_tax": "1.95", + "billing": { + "first_name": "John", + "last_name": "Doe", + "company": "", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US", + "email": "john.doe@example.com", + "phone": "(555) 555-5555" + }, + "shipping": { + "first_name": "John", + "last_name": "Doe", + "company": "", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US" + }, + "payment_method": "bacs", + "payment_method_title": "bacs", + "transaction_id": "", + "customer_ip_address": "127.0.0.1", + "customer_user_agent": "curl/7.47.0", + "created_via": "rest-api", + "customer_note": "", + "date_completed": "2016-05-30T19:47:46", + "date_paid": "2016-05-30 19:35:25", + "cart_hash": "", + "line_items": [ + { + "id": 18, + "name": "Woo Single #1", + "sku": "", + "product_id": 93, + "variation_id": 0, + "quantity": 2, + "tax_class": "", + "price": "3.00", + "subtotal": "6.00", + "subtotal_tax": "0.45", + "total": "6.00", + "total_tax": "0.45", + "taxes": [ + { + "id": 75, + "total": 0.45, + "subtotal": 0.45 + } + ], + "meta": [] + }, + { + "id": 19, + "name": "Ship Your Idea", + "sku": "", + "product_id": 22, + "variation_id": 23, + "quantity": 1, + "tax_class": "", + "price": "20.00", + "subtotal": "20.00", + "subtotal_tax": "1.50", + "total": "20.00", + "total_tax": "1.50", + "taxes": [ + { + "id": 75, + "total": 1.5, + "subtotal": 1.5 + } + ], + "meta": [ + { + "key": "pa_color", + "label": "Color", + "value": "Black" + } + ] + } + ], + "tax_lines": [ + { + "id": 21, + "rate_code": "US-CA-STATE TAX", + "rate_id": "75", + "label": "State Tax", + "compound": false, + "tax_total": "1.95", + "shipping_tax_total": "0.00" + } + ], + "shipping_lines": [ + { + "id": 20, + "method_title": "Flat Rate", + "method_id": "flat_rate", + "total": "10.00", + "total_tax": "0.00", + "taxes": [] + } + ], + "fee_lines": [], + "coupon_lines": [], + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/orders/154" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/orders" + } + ] + } +} +``` + +#### Available parameters #### + +| Parameter | Type | Description | +|-----------|--------|-------------------------------------------------------------------------| +| `force` | string | Use `true` whether to permanently delete the order, Default is `false`. | + +## Batch update orders ## + +This API helps you to batch create, update and delete multiple orders. + +### HTTP request ### + +
+
+ POST +
/wp-json/wc/v1/orders/batch
+
+
+ +```shell +curl -X POST https://example.com/wp-json/wc/v1/orders/batch \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "create": [ + { + "payment_method": "bacs", + "payment_method_title": "Direct Bank Transfer", + "billing": { + "first_name": "John", + "last_name": "Doe", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US", + "email": "john.doe@example.com", + "phone": "(555) 555-5555" + }, + "shipping": { + "first_name": "John", + "last_name": "Doe", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US" + }, + "line_items": [ + { + "product_id": 79, + "quantity": 1 + }, + { + "product_id": 93, + "quantity": 1 + }, + { + "product_id": 22, + "variation_id": 23, + "quantity": 1 + } + ], + "shipping_lines": [ + { + "method_id": "flat_rate", + "method_title": "Flat Rate", + "total": 30 + } + ] + }, + { + "payment_method": "bacs", + "payment_method_title": "Direct Bank Transfer", + "set_paid": true, + "billing": { + "first_name": "John", + "last_name": "Doe", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US", + "email": "john.doe@example.com", + "phone": "(555) 555-5555" + }, + "shipping": { + "first_name": "John", + "last_name": "Doe", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US" + }, + "line_items": [ + { + "product_id": 22, + "variation_id": 23, + "quantity": 1 + }, + { + "product_id": 22, + "variation_id": 24, + "quantity": 1 + } + ], + "shipping_lines": [ + { + "method_id": "flat_rate", + "method_title": "Flat Rate", + "total": 20 + } + ] + } + ], + "update": [ + { + "id": 154, + "shipping_methods": "Local Delivery" + } + ], + "delete": [ + 154 + ] +}' +``` + +```javascript +var data = { + create: [ + { + payment_method: 'bacs', + payment_method_title: 'Direct Bank Transfer', + billing: { + first_name: 'John', + last_name: 'Doe', + address_1: '969 Market', + address_2: '', + city: 'San Francisco', + state: 'CA', + postcode: '94103', + country: 'US', + email: 'john.doe@example.com', + phone: '(555) 555-5555' + }, + shipping: { + first_name: 'John', + last_name: 'Doe', + address_1: '969 Market', + address_2: '', + city: 'San Francisco', + state: 'CA', + postcode: '94103', + country: 'US' + }, + line_items: [ + { + product_id: 79, + quantity: 1 + }, + { + product_id: 93, + quantity: 1 + }, + { + product_id: 22, + variation_id: 23, + quantity: 1 + } + ], + shipping_lines: [ + { + method_id: 'flat_rate', + method_title: 'Flat Rate', + total: 30 + } + ] + }, + { + payment_method: 'bacs', + payment_method_title: 'Direct Bank Transfer', + set_paid: true, + billing: { + first_name: 'John', + last_name: 'Doe', + address_1: '969 Market', + address_2: '', + city: 'San Francisco', + state: 'CA', + postcode: '94103', + country: 'US', + email: 'john.doe@example.com', + phone: '(555) 555-5555' + }, + shipping: { + first_name: 'John', + last_name: 'Doe', + address_1: '969 Market', + address_2: '', + city: 'San Francisco', + state: 'CA', + postcode: '94103', + country: 'US' + }, + line_items: [ + { + product_id: 22, + variation_id: 23, + quantity: 1 + }, + { + product_id: 22, + variation_id: 24, + quantity: 1 + } + ], + shipping_lines: [ + { + method_id: 'flat_rate', + method_title: 'Flat Rate', + total: 20 + } + ] + } + ], + update: [ + { + id: 154, + shipping_methods: 'Local Delivery' + } + ], + delete: [ + 154 + ] +}; + +WooCommerce.post('orders/batch', data, function(err, data, res) { + console.log(res); +}); +``` + +```php + [ + [ + 'payment_method' => 'bacs', + 'payment_method_title' => 'Direct Bank Transfer', + 'billing' => [ + 'first_name' => 'John', + 'last_name' => 'Doe', + 'address_1' => '969 Market', + 'address_2' => '', + 'city' => 'San Francisco', + 'state' => 'CA', + 'postcode' => '94103', + 'country' => 'US', + 'email' => 'john.doe@example.com', + 'phone' => '(555) 555-5555' + ], + 'shipping' => [ + 'first_name' => 'John', + 'last_name' => 'Doe', + 'address_1' => '969 Market', + 'address_2' => '', + 'city' => 'San Francisco', + 'state' => 'CA', + 'postcode' => '94103', + 'country' => 'US' + ], + 'line_items' => [ + [ + 'product_id' => 79, + 'quantity' => 1 + ], + [ + 'product_id' => 93, + 'quantity' => 1 + ], + [ + 'product_id' => 22, + 'variation_id' => 23, + 'quantity' => 1 + ] + ], + 'shipping_lines' => [ + [ + 'method_id' => 'flat_rate', + 'method_title' => 'Flat Rate', + 'total' => 30 + ] + ] + ], + [ + 'payment_method' => 'bacs', + 'payment_method_title' => 'Direct Bank Transfer', + 'set_paid' => true, + 'billing' => [ + 'first_name' => 'John', + 'last_name' => 'Doe', + 'address_1' => '969 Market', + 'address_2' => '', + 'city' => 'San Francisco', + 'state' => 'CA', + 'postcode' => '94103', + 'country' => 'US', + 'email' => 'john.doe@example.com', + 'phone' => '(555) 555-5555' + ], + 'shipping' => [ + 'first_name' => 'John', + 'last_name' => 'Doe', + 'address_1' => '969 Market', + 'address_2' => '', + 'city' => 'San Francisco', + 'state' => 'CA', + 'postcode' => '94103', + 'country' => 'US' + ], + 'line_items' => [ + [ + 'product_id' => 22, + 'variation_id' => 23, + 'quantity' => 1 + ], + [ + 'product_id' => 22, + 'variation_id' => 24, + 'quantity' => 1 + ] + ], + 'shipping_lines' => [ + [ + 'method_id' => 'flat_rate', + 'method_title' => 'Flat Rate', + 'total' => 20 + ] + ] + ] + ], + 'update' => [ + [ + 'id' => 154, + 'shipping_methods' => 'Local Delivery' + ] + ], + 'delete' => [ + 154 + ] +]; + +print_r($woocommerce->post('orders/batch', $data)); +?> +``` + +```python +data = { + "create": [ + { + "payment_method": "bacs", + "payment_method_title": "Direct Bank Transfer", + "billing": { + "first_name": "John", + "last_name": "Doe", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US", + "email": "john.doe@example.com", + "phone": "(555) 555-5555" + }, + "shipping": { + "first_name": "John", + "last_name": "Doe", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US" + }, + "line_items": [ + { + "product_id": 79, + "quantity": 1 + }, + { + "product_id": 93, + "quantity": 1 + }, + { + "product_id": 22, + "variation_id": 23, + "quantity": 1 + } + ], + "shipping_lines": [ + { + "method_id": "flat_rate", + "method_title": "Flat Rate", + "total": 30 + } + ] + }, + { + "payment_method": "bacs", + "payment_method_title": "Direct Bank Transfer", + "set_paid": True, + "billing": { + "first_name": "John", + "last_name": "Doe", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US", + "email": "john.doe@example.com", + "phone": "(555) 555-5555" + }, + "shipping": { + "first_name": "John", + "last_name": "Doe", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US" + }, + "line_items": [ + { + "product_id": 22, + "variation_id": 23, + "quantity": 1 + }, + { + "product_id": 22, + "variation_id": 24, + "quantity": 1 + } + ], + "shipping_lines": [ + { + "method_id": "flat_rate", + "method_title": "Flat Rate", + "total": 20 + } + ] + } + ], + "update": [ + { + "id": 154, + "shipping_methods": "Local Delivery" + } + ], + "delete": [ + 154 + ] +} + +print(wcapi.post("orders/batch", data).json()) +``` + +```ruby +data = { + create: [ + { + payment_method: "bacs", + payment_method_title: "Direct Bank Transfer", + billing: { + first_name: "John", + last_name: "Doe", + address_1: "969 Market", + address_2: "", + city: "San Francisco", + state: "CA", + postcode: "94103", + country: "US", + email: "john.doe@example.com", + phone: "(555) 555-5555" + }, + shipping: { + first_name: "John", + last_name: "Doe", + address_1: "969 Market", + address_2: "", + city: "San Francisco", + state: "CA", + postcode: "94103", + country: "US" + }, + line_items: [ + { + product_id: 79, + quantity: 1 + }, + { + product_id: 93, + quantity: 1 + }, + { + product_id: 22, + variation_id: 23, + quantity: 1 + } + ], + shipping_lines: [ + { + method_id: "flat_rate", + method_title: "Flat Rate", + total: 30 + } + ] + }, + { + payment_method: "bacs", + payment_method_title: "Direct Bank Transfer", + set_paid: true, + billing: { + first_name: "John", + last_name: "Doe", + address_1: "969 Market", + address_2: "", + city: "San Francisco", + state: "CA", + postcode: "94103", + country: "US", + email: "john.doe@example.com", + phone: "(555) 555-5555" + }, + shipping: { + first_name: "John", + last_name: "Doe", + address_1: "969 Market", + address_2: "", + city: "San Francisco", + state: "CA", + postcode: "94103", + country: "US" + }, + line_items: [ + { + product_id: 22, + variation_id: 23, + quantity: 1 + }, + { + product_id: 22, + variation_id: 24, + quantity: 1 + } + ], + shipping_lines: [ + { + method_id: "flat_rate", + method_title: "Flat Rate", + total: 20 + } + ] + } + ], + update: [ + { + id: 154, + shipping_methods: "Local Delivery" + } + ], + delete: [ + 154 + ] +} + +woocommerce.post("orders/batch", data).parsed_response +``` + +> JSON response example: + +```json +{ + "create": [ + { + "id": 155, + "parent_id": 0, + "status": "pending", + "order_key": "wc_order_574cc9541cea3", + "currency": "USD", + "version": "2.6.0", + "prices_include_tax": false, + "date_created": "2016-05-30T23:14:28", + "date_modified": "2016-05-30T23:14:28", + "customer_id": 0, + "discount_total": "0.00", + "discount_tax": "0.00", + "shipping_total": "30.00", + "shipping_tax": "0.00", + "cart_tax": "2.85", + "total": "70.85", + "total_tax": "2.85", + "billing": { + "first_name": "John", + "last_name": "Doe", + "company": "", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US", + "email": "john.doe@example.com", + "phone": "(555) 555-5555" + }, + "shipping": { + "first_name": "John", + "last_name": "Doe", + "company": "", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US" + }, + "payment_method": "bacs", + "payment_method_title": "bacs", + "transaction_id": "", + "customer_ip_address": "127.0.0.1", + "customer_user_agent": "curl/7.47.0", + "created_via": "rest-api", + "customer_note": "", + "date_completed": "2016-05-30T20:14:28", + "date_paid": "", + "cart_hash": "", + "line_items": [ + { + "id": 22, + "name": "Woo Logo", + "sku": "", + "product_id": 79, + "variation_id": 0, + "quantity": 1, + "tax_class": "", + "price": "15.00", + "subtotal": "15.00", + "subtotal_tax": "1.13", + "total": "15.00", + "total_tax": "1.13", + "taxes": [ + { + "id": 75, + "total": 1.125, + "subtotal": 1.125 + } + ], + "meta": [] + }, + { + "id": 23, + "name": "Woo Single #1", + "sku": "", + "product_id": 93, + "variation_id": 0, + "quantity": 1, + "tax_class": "", + "price": "3.00", + "subtotal": "3.00", + "subtotal_tax": "0.23", + "total": "3.00", + "total_tax": "0.23", + "taxes": [ + { + "id": 75, + "total": 0.225, + "subtotal": 0.225 + } + ], + "meta": [] + }, + { + "id": 24, + "name": "Ship Your Idea", + "sku": "", + "product_id": 22, + "variation_id": 23, + "quantity": 1, + "tax_class": "", + "price": "20.00", + "subtotal": "20.00", + "subtotal_tax": "1.50", + "total": "20.00", + "total_tax": "1.50", + "taxes": [ + { + "id": 75, + "total": 1.5, + "subtotal": 1.5 + } + ], + "meta": [ + { + "key": "pa_color", + "label": "Color", + "value": "Black" + } + ] + } + ], + "tax_lines": [ + { + "id": 26, + "rate_code": "US-CA-STATE TAX", + "rate_id": "75", + "label": "State Tax", + "compound": false, + "tax_total": "2.85", + "shipping_tax_total": "0.00" + } + ], + "shipping_lines": [ + { + "id": 25, + "method_title": "Flat Rate", + "method_id": "flat_rate", + "total": "30.00", + "total_tax": "0.00", + "taxes": [] + } + ], + "fee_lines": [], + "coupon_lines": [], + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/orders/155" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/orders" + } + ] + } + }, + { + "id": 156, + "parent_id": 0, + "status": "processing", + "order_key": "wc_order_574cc95465214", + "currency": "USD", + "version": "2.6.0", + "prices_include_tax": false, + "date_created": "2016-05-30T23:14:28", + "date_modified": "2016-05-30T23:14:28", + "customer_id": 0, + "discount_total": "0.00", + "discount_tax": "0.00", + "shipping_total": "20.00", + "shipping_tax": "0.00", + "cart_tax": "3.00", + "total": "63.00", + "total_tax": "3.00", + "billing": { + "first_name": "John", + "last_name": "Doe", + "company": "", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US", + "email": "john.doe@example.com", + "phone": "(555) 555-5555" + }, + "shipping": { + "first_name": "John", + "last_name": "Doe", + "company": "", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US" + }, + "payment_method": "bacs", + "payment_method_title": "bacs", + "transaction_id": "", + "customer_ip_address": "127.0.0.1", + "customer_user_agent": "curl/7.47.0", + "created_via": "rest-api", + "customer_note": "", + "date_completed": "2016-05-30T20:14:28", + "date_paid": "2016-05-30 20:14:37", + "cart_hash": "", + "line_items": [ + { + "id": 27, + "name": "Ship Your Idea", + "sku": "", + "product_id": 22, + "variation_id": 23, + "quantity": 1, + "tax_class": "", + "price": "20.00", + "subtotal": "20.00", + "subtotal_tax": "1.50", + "total": "20.00", + "total_tax": "1.50", + "taxes": [ + { + "id": 75, + "total": 1.5, + "subtotal": 1.5 + } + ], + "meta": [ + { + "key": "pa_color", + "label": "Color", + "value": "Black" + } + ] + }, + { + "id": 28, + "name": "Ship Your Idea", + "sku": "", + "product_id": 22, + "variation_id": 24, + "quantity": 1, + "tax_class": "", + "price": "20.00", + "subtotal": "20.00", + "subtotal_tax": "1.50", + "total": "20.00", + "total_tax": "1.50", + "taxes": [ + { + "id": 75, + "total": 1.5, + "subtotal": 1.5 + } + ], + "meta": [ + { + "key": "pa_color", + "label": "Color", + "value": "Green" + } + ] + } + ], + "tax_lines": [ + { + "id": 30, + "rate_code": "US-CA-STATE TAX", + "rate_id": "75", + "label": "State Tax", + "compound": false, + "tax_total": "3.00", + "shipping_tax_total": "0.00" + } + ], + "shipping_lines": [ + { + "id": 29, + "method_title": "Flat Rate", + "method_id": "flat_rate", + "total": "20.00", + "total_tax": "0.00", + "taxes": [] + } + ], + "fee_lines": [], + "coupon_lines": [], + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/orders/156" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/orders" + } + ] + } + } + ], + "update": [ + { + "id": 154, + "parent_id": 0, + "status": "completed", + "order_key": "wc_order_574cc02467274", + "currency": "USD", + "version": "2.6.0", + "prices_include_tax": false, + "date_created": "2016-05-30T22:35:16", + "date_modified": "2016-05-30T22:55:19", + "customer_id": 0, + "discount_total": "0.00", + "discount_tax": "0.00", + "shipping_total": "10.00", + "shipping_tax": "0.00", + "cart_tax": "1.95", + "total": "37.95", + "total_tax": "1.95", + "billing": { + "first_name": "John", + "last_name": "Doe", + "company": "", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US", + "email": "john.doe@example.com", + "phone": "(555) 555-5555" + }, + "shipping": { + "first_name": "John", + "last_name": "Doe", + "company": "", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US" + }, + "payment_method": "bacs", + "payment_method_title": "bacs", + "transaction_id": "", + "customer_ip_address": "127.0.0.1", + "customer_user_agent": "curl/7.47.0", + "created_via": "rest-api", + "customer_note": "", + "date_completed": "2016-05-30T19:47:46", + "date_paid": "2016-05-30 19:35:25", + "cart_hash": "", + "line_items": [ + { + "id": 18, + "name": "Woo Single #1", + "sku": "", + "product_id": 93, + "variation_id": 0, + "quantity": 2, + "tax_class": "", + "price": "3.00", + "subtotal": "6.00", + "subtotal_tax": "0.45", + "total": "6.00", + "total_tax": "0.45", + "taxes": [ + { + "id": 75, + "total": 0.45, + "subtotal": 0.45 + } + ], + "meta": [] + }, + { + "id": 19, + "name": "Ship Your Idea", + "sku": "", + "product_id": 22, + "variation_id": 23, + "quantity": 1, + "tax_class": "", + "price": "20.00", + "subtotal": "20.00", + "subtotal_tax": "1.50", + "total": "20.00", + "total_tax": "1.50", + "taxes": [ + { + "id": 75, + "total": 1.5, + "subtotal": 1.5 + } + ], + "meta": [ + { + "key": "pa_color", + "label": "Color", + "value": "Black" + } + ] + } + ], + "tax_lines": [ + { + "id": 21, + "rate_code": "US-CA-STATE TAX", + "rate_id": "75", + "label": "State Tax", + "compound": false, + "tax_total": "1.95", + "shipping_tax_total": "0.00" + } + ], + "shipping_lines": [ + { + "id": 20, + "method_title": "Flat Rate", + "method_id": "flat_rate", + "total": "10.00", + "total_tax": "0.00", + "taxes": [] + } + ], + "fee_lines": [], + "coupon_lines": [], + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/orders/154" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/orders" + } + ] + } + } + ], + "delete": [ + { + "id": 154, + "parent_id": 0, + "status": "completed", + "order_key": "wc_order_574cc02467274", + "currency": "USD", + "version": "2.6.0", + "prices_include_tax": false, + "date_created": "2016-05-30T22:35:16", + "date_modified": "2016-05-30T22:55:19", + "customer_id": 0, + "discount_total": "0.00", + "discount_tax": "0.00", + "shipping_total": "10.00", + "shipping_tax": "0.00", + "cart_tax": "1.95", + "total": "37.95", + "total_tax": "1.95", + "billing": { + "first_name": "John", + "last_name": "Doe", + "company": "", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US", + "email": "john.doe@example.com", + "phone": "(555) 555-5555" + }, + "shipping": { + "first_name": "John", + "last_name": "Doe", + "company": "", + "address_1": "969 Market", + "address_2": "", + "city": "San Francisco", + "state": "CA", + "postcode": "94103", + "country": "US" + }, + "payment_method": "bacs", + "payment_method_title": "bacs", + "transaction_id": "", + "customer_ip_address": "127.0.0.1", + "customer_user_agent": "curl/7.47.0", + "created_via": "rest-api", + "customer_note": "", + "date_completed": "2016-05-30T19:47:46", + "date_paid": "2016-05-30 19:35:25", + "cart_hash": "", + "line_items": [ + { + "id": 18, + "name": "Woo Single #1", + "sku": "", + "product_id": 93, + "variation_id": 0, + "quantity": 2, + "tax_class": "", + "price": "3.00", + "subtotal": "6.00", + "subtotal_tax": "0.45", + "total": "6.00", + "total_tax": "0.45", + "taxes": [ + { + "id": 75, + "total": 0.45, + "subtotal": 0.45 + } + ], + "meta": [] + }, + { + "id": 19, + "name": "Ship Your Idea", + "sku": "", + "product_id": 22, + "variation_id": 23, + "quantity": 1, + "tax_class": "", + "price": "20.00", + "subtotal": "20.00", + "subtotal_tax": "1.50", + "total": "20.00", + "total_tax": "1.50", + "taxes": [ + { + "id": 75, + "total": 1.5, + "subtotal": 1.5 + } + ], + "meta": [ + { + "key": "pa_color", + "label": "Color", + "value": "Black" + } + ] + } + ], + "tax_lines": [ + { + "id": 21, + "rate_code": "US-CA-STATE TAX", + "rate_id": "75", + "label": "State Tax", + "compound": false, + "tax_total": "1.95", + "shipping_tax_total": "0.00" + } + ], + "shipping_lines": [ + { + "id": 20, + "method_title": "Flat Rate", + "method_id": "flat_rate", + "total": "10.00", + "total_tax": "0.00", + "taxes": [] + } + ], + "fee_lines": [], + "coupon_lines": [], + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/orders/154" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/orders" + } + ] + } + } + ] +} +``` diff --git a/source/includes/wp-api-v1/_product-attribute-terms.md b/source/includes/wp-api-v1/_product-attribute-terms.md new file mode 100644 index 00000000..c520dd5d --- /dev/null +++ b/source/includes/wp-api-v1/_product-attribute-terms.md @@ -0,0 +1,743 @@ +# Product attribute terms # + +The product attribute terms API allows you to create, view, update, and delete individual, or a batch, of attribute terms. + +## Attribute term properties ## + +| Attribute | Type | Description | +|--------------|---------|------------------------------------------------------------------------------------------| +| `id` | integer | Unique identifier for the resource. read-only | +| `name` | string | Term name. required | +| `slug` | string | An alphanumeric identifier for the resource unique to its type. | +| `menu_order` | integer | Menu order, used to custom sort the resource. | +| `count` | integer | Number of published products for the resource. read-only | + +## Create an attribute term ## + +This API helps you to create a new product attribute term. + +### HTTP request ### + +
+
+ POST +
/wp-json/wc/v1/products/attributes/<attribute_id>/terms
+
+
+ +```shell +curl -X POST https://example.com/wp-json/wc/v1/products/attributes/2/terms \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "name": "XXS" +}' +``` + +```javascript +var data = { + name: 'XXS' +}; + +WooCommerce.post('products/attributes/2/terms', data, function(err, data, res) { + console.log(res); +}); +``` + +```php + 'XXS' +]; + +print_r($woocommerce->post('products/attributes/2/terms', $data)); +?> +``` + +```python +data = { + "name": "XXS" +} + +print(wcapi.post("products/attributes/2/terms", data).json()) +``` + +```ruby +data = { + name: "XXS" +} + +woocommerce.post("products/attributes/2/terms", data).parsed_response +``` + +> JSON response example: + +```json +{ + "id": 23, + "name": "XXS", + "slug": "xxs", + "menu_order": 1, + "count": 1, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms/23" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms" + } + ] + } +} +``` + +## Retrieve an attribute term ## + +This API lets you retrieve a product attribute term by ID. + +
+
+ GET +
/wp-json/wc/v1/products/attributes/<attribute_id>/terms/<id>
+
+
+ +```shell +curl https://example.com/wp-json/wc/v1/products/attributes/2/terms/23 \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('products/attributes/2/terms/23', function(err, data, res) { + console.log(res); +}); +``` + +```php +get('products/attributes/2/terms/23')); ?> +``` + +```python +print(wcapi.get("products/attributes/2/terms/23").json()) +``` + +```ruby +woocommerce.get("products/attributes/2/terms/23").parsed_response +``` + +> JSON response example: + +```json +{ + "id": 23, + "name": "XXS", + "slug": "xxs", + "menu_order": 1, + "count": 1, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms/23" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms" + } + ] + } +} +``` + +## List all attribute terms ## + +This API lets you retrieve all terms from a product attribute. + +
+
+ GET +
/wp-json/wc/v1/products/attributes/<attribute_id>/terms
+
+
+ +```shell +curl https://example.com/wp-json/wc/v1/products/attributes/2/terms \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('products/attributes/2/terms', function(err, data, res) { + console.log(res); +}); +``` + +```php +get('products/attributes/2/terms')); ?> +``` + +```python +print(wcapi.get("products/attributes/2/terms").json()) +``` + +```ruby +woocommerce.get("products/attributes/2/terms").parsed_response +``` + +> JSON response example: + +```json +[ + { + "id": 23, + "name": "XXS", + "slug": "xxs", + "menu_order": 1, + "count": 1, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms/23" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms" + } + ] + } + }, + { + "id": 22, + "name": "XS", + "slug": "xs", + "menu_order": 2, + "count": 1, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms/22" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms" + } + ] + } + }, + { + "id": 17, + "name": "S", + "slug": "s", + "menu_order": 3, + "count": 1, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms/17" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms" + } + ] + } + }, + { + "id": 18, + "name": "M", + "slug": "m", + "menu_order": 4, + "count": 1, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms/18" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms" + } + ] + } + }, + { + "id": 19, + "name": "L", + "slug": "l", + "menu_order": 5, + "count": 1, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms/19" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms" + } + ] + } + }, + { + "id": 20, + "name": "XL", + "slug": "xl", + "menu_order": 6, + "count": 1, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms/20" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms" + } + ] + } + }, + { + "id": 21, + "name": "XXL", + "slug": "xxl", + "menu_order": 7, + "count": 1, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms/21" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms" + } + ] + } + } +] +``` + +#### Available parameters #### + +| Parameter | Type | Description | +|--------------|---------|--------------------------------------------------------------------------------------------------------------------------------------------| +| `context` | string | Scope under which the request is made; determines fields present in response. Options: `view` and `edit`. | +| `page` | integer | Current page of the collection. | +| `per_page` | integer | Maximum number of items to be returned in result set. | +| `search` | string | Limit results to those matching a string. | +| `exclude` | string | Ensure result set excludes specific ids. | +| `include` | string | Limit result set to specific ids. | +| `order` | string | Order sort attribute ascending or descending. Default is `asc`. Options: `asc` and `desc`. | +| `orderby` | string | Sort collection by object attribute. Default is `name`. Options: `id`, `include`, `name`, `slug`, `term_group`, `description` and `count`. | +| `hide_empty` | bool | Whether to hide resources not assigned to any products. Default is `false`. | +| `parent` | integer | Limit result set to resources assigned to a specific parent. | +| `product` | integer | Limit result set to resources assigned to a specific product. | +| `slug` | string | Limit result set to resources with a specific slug. | + +## Update an attribute term ## + +This API lets you make changes to a product attribute term. + +### HTTP request ### + +
+
+ PUT +
/wp-json/wc/v1/products/attributes/<attribute_id>/terms/<id>
+
+
+ +```shell +curl -X PUT https://example.com/wp-json/wc/v1/products/attributes/2/terms/23 \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "name": "XXS" +}' +``` + +```javascript +var data = { + name: 'XXS' +}; + +WooCommerce.put('products/attributes/2/terms/23', data, function(err, data, res) { + console.log(res); +}); +``` + +```php + 'XXS' +]; + +print_r($woocommerce->put('products/attributes/2/terms/23', $data)); +?> +``` + +```python +data = { + "name": "XXS" +} + +print(wcapi.put("products/attributes/2/terms/23", data).json()) +``` + +```ruby +data = { + name: "XXS" +} + +woocommerce.put("products/attributes/2/terms/23", data).parsed_response +``` + +> JSON response example: + +```json +{ + "id": 23, + "name": "XXS", + "slug": "xxs", + "menu_order": 1, + "count": 1, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms/23" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms" + } + ] + } +} +``` + +## Delete an attribute term ## + +This API helps you delete a product attribute term. + +### HTTP request ### + +
+
+ DELETE +
/wp-json/wc/v1/products/attributes/<attribute_id>/terms/<id>
+
+
+ +```shell +curl -X DELETE https://example.com/wp-json/wc/v1/products/attributes/2/terms/23?force=true \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.delete('products/attributes/2/terms/23?force=true', function(err, data, res) { + console.log(res); +}); +``` + +```php +delete('products/attributes/2/terms/23', ['force' => true])); ?> +``` + +```python +print(wcapi.delete("products/attributes/2/terms/23?force=true").json()) +``` + +```ruby +woocommerce.delete("products/attributes/2/terms/23", force: true).parsed_response +``` + +> JSON response example: + +```json +{ + "id": 23, + "name": "XXS", + "slug": "xxs", + "menu_order": 1, + "count": 1, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms/23" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms" + } + ] + } +} +``` + +#### Available parameters #### + +| Parameter | Type | Description | +|-----------|--------|---------------------------------------------------------------| +| `force` | string | Required to be `true`, as resource does not support trashing. | + +## Batch update attribute terms ## + +This API helps you to batch create, update and delete multiple product attribute terms. + +### HTTP request ### + +
+
+ POST +
/wp-json/wc/v1/products/attributes/<attribute_id>/terms/batch
+
+
+ +```shell +curl -X POST https://example.com//wp-json/wc/v1/products/attributes/<attribute_id>/terms/batch \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "create": [ + { + "name" => "XXS" + }, + { + "name" => "S" + } + ], + "update": [ + { + "id": 19, + "menu_order": 6 + } + ], + "delete": [ + 21, + 20 + ] +}' +``` + +```javascript +var data = { + create: [ + { + name: 'XXS' + }, + { + name: 'S' + } + ], + update: [ + { + id: 19, + menu_order: 6 + } + ], + delete: [ + 21, + 20 + ] +}; + +WooCommerce.post('products/attributes/2/terms/batch', data, function(err, data, res) { + console.log(res); +}); +``` + +```php + [ + [ + 'name' => 'XXS' + ], + [ + 'name' => 'S' + ] + ], + 'update' => [ + [ + 'id' => 19, + 'menu_order' => 6 + ] + ], + 'delete' => [ + 21, + 20 + ] +]; + +print_r($woocommerce->post('products/attributes/2/terms/batch', $data)); +?> +``` + +```python +data = { + "create": [ + { + "name": "XXS" + }, + { + "name": "S" + } + ], + "update": [ + { + "id": 19, + "menu_order": 6 + } + ], + "delete": [ + 21, + 20 + ] +} + +print(wcapi.post("products/attributes/2/terms/batch", data).json()) +``` + +```ruby +data = { + create: [ + { + name: "XXS" + }, + { + name: "S" + } + ], + update: [ + { + id: 19, + menu_order: 6 + } + ], + delete: [ + 21, + 20 + ] +} + +woocommerce.post("products/attributes/2/terms/batch", data).parsed_response +``` + +> JSON response example: + +```json +{ + "create": [ + { + "id": 23, + "name": "XXS", + "slug": "xxs", + "menu_order": 1, + "count": 0, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms/23" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms" + } + ] + } + }, + { + "id": 17, + "name": "S", + "slug": "s", + "menu_order": 3, + "count": 0, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms/17" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms" + } + ] + } + } + ], + "update": [ + { + "id": 19, + "name": "L", + "slug": "l", + "menu_order": 5, + "count": 1, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms/19" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms" + } + ] + } + } + ], + "delete": [ + { + "id": 21, + "name": "XXL", + "slug": "xxl", + "menu_order": 7, + "count": 1, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms/21" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms" + } + ] + } + }, + { + "id": 20, + "name": "XL", + "slug": "xl", + "menu_order": 6, + "count": 1, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms/20" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes/2/terms" + } + ] + } + } + ] +} +``` diff --git a/source/includes/wp-api-v1/_product-attributes.md b/source/includes/wp-api-v1/_product-attributes.md new file mode 100644 index 00000000..3b529b4e --- /dev/null +++ b/source/includes/wp-api-v1/_product-attributes.md @@ -0,0 +1,644 @@ +# Product attributes # + +The product attributes API allows you to create, view, update, and delete individual, or a batch, of product attributes. + +## Product attribute properties ## + +| Attribute | Type | Description | +|----------------|---------|-----------------------------------------------------------------------------------------------------------| +| `id` | integer | Unique identifier for the resource. read-only | +| `name` | string | Attribute name. required | +| `slug` | string | An alphanumeric identifier for the resource unique to its type. | +| `type` | string | Type of attribute. Default is `select`. Options: `select` and `text` (some plugins can include new types) | +| `order_by` | string | Default sort order. Default is `menu_order`. Options: `menu_order`, `name`, `name_num` and `id`. | +| `has_archives` | boolean | Enable/Disable attribute archives. Default is `false`. | + +## Create a product attribute ## + +This API helps you to create a new product attribute. + +### HTTP request ### + +
+
+ POST +
/wp-json/wc/v1/products/attributes
+
+
+ +```shell +curl -X POST https://example.com/wp-json/wc/v1/products/attributes \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "name": "Color", + "slug": "pa_color", + "type": "select", + "order_by": "menu_order", + "has_archives": true +}' +``` + +```javascript +var data = { + name: 'Color', + slug: 'pa_color', + type: 'select', + order_by: 'menu_order', + has_archives: true +}; + +WooCommerce.post('products/attributes', data, function(err, data, res) { + console.log(res); +}); +``` + +```php + 'Color', + 'slug' => 'pa_color', + 'type' => 'select', + 'order_by' => 'menu_order', + 'has_archives' => true +]; + +print_r($woocommerce->post('products/attributes', $data)); +?> +``` + +```python +data = { + "name": "Color", + "slug": "pa_color", + "type": "select", + "order_by": "menu_order", + "has_archives": True +} + +print(wcapi.post("products/attributes", data).json()) +``` + +```ruby +data = { + name: "Color", + slug: "pa_color", + type: "select", + order_by: "menu_order", + has_archives: true +} + +woocommerce.post("products/attributes", data).parsed_response +``` + +> JSON response example: + +```json +{ + "id": 1, + "name": "Color", + "slug": "pa_color", + "type": "select", + "order_by": "menu_order", + "has_archives": true, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes/6" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes" + } + ] + } +} +``` + +## Retrieve a product attribute ## + +This API lets you retrieve and view a specific product attribute by ID. + +
+
+ GET +
/wp-json/wc/v1/products/attributes/<id>
+
+
+ +```shell +curl https://example.com/wp-json/wc/v1/products/attributes/1 \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('products/attributes/1', function(err, data, res) { + console.log(res); +}); +``` + +```php +get('products/attributes/1')); ?> +``` + +```python +print(wcapi.get("products/attributes/1").json()) +``` + +```ruby +woocommerce.get("products/attributes/1").parsed_response +``` + +> JSON response example: + +```json +{ + "id": 1, + "name": "Color", + "slug": "pa_color", + "type": "select", + "order_by": "menu_order", + "has_archives": true, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes/6" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes" + } + ] + } +} +``` + +## List all product attributes ## + +This API helps you to view all the product attributes. + +### HTTP request ### + +
+
+ GET +
/wp-json/wc/v1/products/attributes
+
+
+ +```shell +curl https://example.com/wp-json/wc/v1/products/attributes \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('products/attributes', function(err, data, res) { + console.log(res); +}); +``` + +```php +get('products/attributes')); ?> +``` + +```python +print(wcapi.get("products/attributes").json()) +``` + +```ruby +woocommerce.get("products/attributes").parsed_response +``` + +> JSON response example: + +```json +[ + { + "id": 1, + "name": "Color", + "slug": "pa_color", + "type": "select", + "order_by": "menu_order", + "has_archives": true, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes/6" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes" + } + ] + } + }, + { + "id": 2, + "name": "Size", + "slug": "pa_size", + "type": "select", + "order_by": "menu_order", + "has_archives": false, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes/2" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes" + } + ] + } + } +] +``` + +## Update a product attribute ## + +This API lets you make changes to a product attribute. + +### HTTP request ### + +
+
+ PUT +
/wp-json/wc/v1/products/attributes/<id>
+
+
+ +```shell +curl -X PUT https://example.com/wp-json/wc/v1/products/attributes/1 \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "order_by": "name" +}' +``` + +```javascript +var data = { + order_by: 'name' +}; + +WooCommerce.put('products/attributes/1', data, function(err, data, res) { + console.log(res); +}); +``` + +```php + 'name' +]; + +print_r($woocommerce->put('products/attributes/1', $data)); +?> +``` + +```python +data = { + "order_by": "name" +} + +print(wcapi.put("products/attributes/1", data).json()) +``` + +```ruby +data = { + order_by: "name" +} + +woocommerce.put("products/attributes/1", data).parsed_response +``` + +> JSON response example: + +```json +{ + "id": 1, + "name": "Color", + "slug": "pa_color", + "type": "select", + "order_by": "name", + "has_archives": true, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes/6" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes" + } + ] + } +} +``` + +## Delete a product attribute ## + +This API helps you delete a product attribute. + +### HTTP request ### + +
+
+ DELETE +
/wp-json/wc/v1/products/attributes/<id>
+
+
+ + + +```shell +curl -X DELETE https://example.com/wp-json/wc/v1/products/attributes/1?force=true \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.delete('products/attributes/1?force=true', function(err, data, res) { + console.log(res); +}); +``` + +```php +delete('products/attributes/1', ['force' => true])); ?> +``` + +```python +print(wcapi.delete("products/attributes/1?force=true").json()) +``` + +```ruby +woocommerce.delete("products/attributes/1", force: true).parsed_response +``` + +> JSON response example: + +```json +{ + "id": 1, + "name": "Color", + "slug": "pa_color", + "type": "select", + "order_by": "menu_order", + "has_archives": true, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes/6" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes" + } + ] + } +} +``` + +#### Available parameters #### + +| Parameter | Type | Description | +|-----------|--------|---------------------------------------------------------------| +| `force` | string | Required to be `true`, as resource does not support trashing. | + +## Batch update product attributes ## + +This API helps you to batch create, update and delete multiple product attributes. + +### HTTP request ### + +
+
+ POST +
/wp-json/wc/v1/products/attributes/batch
+
+
+ +```shell +curl -X POST https://example.com//wp-json/wc/v1/products/attributes/batch \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "create": [ + { + "name" => "Brand" + }, + { + "name" => "Publisher" + } + ], + "update": [ + { + "id": 2, + "order_by": "name" + } + ], + "delete": [ + 1 + ] +}' +``` + +```javascript +var data = { + create: [ + { + name: 'Brand' + }, + { + name: 'Publisher' + } + ], + update: [ + { + id: 2, + order_by: 'name' + } + ], + delete: [ + 1 + ] +}; + +WooCommerce.post('products/attributes/batch', data, function(err, data, res) { + console.log(res); +}); +``` + +```php + [ + [ + 'name' => 'Brand' + ], + [ + 'name' => 'Publisher' + ] + ], + 'update' => [ + [ + 'id' => 2, + 'order_by' => 'name' + ] + ], + 'delete' => [ + 1 + ] +]; + +print_r($woocommerce->post('products/attributes/batch', $data)); +?> +``` + +```python +data = { + "create": [ + { + "name": "Brand" + }, + { + "name": "Publisher" + } + ], + "update": [ + { + "id": 2, + "order_by": "name" + } + ], + "delete": [ + 1 + ] +} + +print(wcapi.post("products/attributes/batch", data).json()) +``` + +```ruby +data = { + create: [ + { + name: "Round toe" + }, + { + name: "Flat" + } + ], + update: [ + { + id: 2, + order_by: "name" + } + ], + delete: [ + 1 + ] +} + +woocommerce.post("products/attributes/batch", data).parsed_response +``` + +> JSON response example: + +```json +{ + "create": [ + { + "id": 7, + "name": "Brand", + "slug": "pa_brand", + "type": "select", + "order_by": "menu_order", + "has_archives": false, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes/7" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes" + } + ] + } + }, + { + "id": 8, + "name": "Publisher", + "slug": "pa_publisher", + "type": "select", + "order_by": "menu_order", + "has_archives": false, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes/8" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes" + } + ] + } + } + ], + "update": [ + { + "id": 2, + "name": "Size", + "slug": "pa_size", + "type": "select", + "order_by": "menu_order", + "has_archives": false, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes/2" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes" + } + ] + } + } + ], + "delete": [ + { + "id": 1, + "name": "Color", + "slug": "pa_color", + "type": "select", + "order_by": "menu_order", + "has_archives": true, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes/6" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/attributes" + } + ] + } + } + ] +} +``` diff --git a/source/includes/wp-api-v1/_product-categories.md b/source/includes/wp-api-v1/_product-categories.md new file mode 100644 index 00000000..253e1893 --- /dev/null +++ b/source/includes/wp-api-v1/_product-categories.md @@ -0,0 +1,914 @@ +# Product categories # + +The product categories API allows you to create, view, update, and delete individual, or a batch, of categories. + +## Product category properties ## + +| Attribute | Type | Description | +|---------------|---------|-----------------------------------------------------------------------------------------------------------------| +| `id` | integer | Unique identifier for the resource. read-only | +| `name` | string | Category name. required | +| `slug` | string | An alphanumeric identifier for the resource unique to its type. | +| `parent` | integer | The id for the parent of the resource. | +| `description` | string | HTML description of the resource. | +| `display` | string | Category archive display type. Default is `default`. Options: `default`, `products`, `subcategories` and `both` | +| `image` | array | Image data. See [Category Image properties](#category-image-properties) | +| `menu_order` | integer | Menu order, used to custom sort the resource. | +| `count` | integer | Number of published products for the resource. read-only | + +### Category Image properties ### + +| Attribute | Type | Description | +|-----------------|-----------|---------------------------------------------------------------------------------------------------------| +| `id` | integer | Image ID (attachment ID). In write-mode used to attach pre-existing images. | +| `date_created` | date-time | The date the image was created, in the site's timezone. read-only | +| `date_modified` | date-time | The date the image was last modified, in the site's timezone. read-only | +| `src` | string | Image URL. In write-mode used to upload new images. | +| `name` | string | Image name. | +| `alt` | string | Image alternative text. | + +## Create a product category ## + +This API helps you to create a new product category. + +### HTTP request ### + +
+
+ POST +
/wp-json/wc/v1/products/categories
+
+
+ +> Example of how to create a product category: + +```shell +curl -X POST https://example.com/wp-json/wc/v1/products/categories \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "name": "Clothing", + "image": { + "src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg" + } +}' +``` + +```javascript +var data = { + name: 'Clothing', + image: { + src: 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg' + } +}; + +WooCommerce.post('products/categories', data, function(err, data, res) { + console.log(res); +}); +``` + +```php + 'Clothing', + 'image' => [ + 'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg' + ] +]; + +print_r($woocommerce->post('products/categories', $data)); +?> +``` + +```python +data = { + "name": "Clothing", + "image": { + "src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg" + } +} + +print(wcapi.post("products/categories", data).json()) +``` + +```ruby +data = { + name: "Clothing", + image: { + src: "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg" + } +} + +woocommerce.post("products/categories", data).parsed_response +``` + +> JSON response example: + +```json +{ + "id": 9, + "name": "Clothing", + "slug": "clothing", + "parent": 0, + "description": "", + "display": "default", + "image": { + "id": 173, + "date_created": "2016-05-31T23:51:03", + "date_modified": "2016-05-31T23:51:03", + "src": "https://example/wp-content/uploads/2016/05/T_3_front-1.jpg", + "title": "", + "alt": "" + }, + "menu_order": 0, + "count": 18, + "_links": { + "self": [ + { + "href": "https://example/wp-json/wc/v1/products/categories/9" + } + ], + "collection": [ + { + "href": "https://example/wp-json/wc/v1/products/categories" + } + ] + } +} +``` + +## Retrieve a product category ## + +This API lets you retrieve a product category by ID. + +
+
+ GET +
/wp-json/wc/v1/products/categories/<id>
+
+
+ +```shell +curl https://example.com/wp-json/wc/v1/products/categories/9 \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('products/categories/9', function(err, data, res) { + console.log(res); +}); +``` + +```php +get('products/categories/9')); ?> +``` + +```python +print(wcapi.get("products/categories/9").json()) +``` + +```ruby +woocommerce.get("products/categories/9").parsed_response +``` + +> JSON response example: + +```json +{ + "id": 9, + "name": "Clothing", + "slug": "clothing", + "parent": 0, + "description": "", + "display": "default", + "image": { + "id": 173, + "date_created": "2016-05-31T23:51:03", + "date_modified": "2016-05-31T23:51:03", + "src": "https://example/wp-content/uploads/2016/05/T_3_front-1.jpg", + "title": "", + "alt": "" + }, + "menu_order": 0, + "count": 18, + "_links": { + "self": [ + { + "href": "https://example/wp-json/wc/v1/products/categories/9" + } + ], + "collection": [ + { + "href": "https://example/wp-json/wc/v1/products/categories" + } + ] + } +} +``` + +## List all product categories ## + +This API lets you retrieve all product categories. + +
+
+ GET +
/wp-json/wc/v1/products/categories
+
+
+ +```shell +curl https://example.com/wp-json/wc/v1/products/categories \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('products/categories', function(err, data, res) { + console.log(res); +}); +``` + +```php +get('products/categories')); ?> +``` + +```python +print(wcapi.get("products/categories").json()) +``` + +```ruby +woocommerce.get("products/categories").parsed_response +``` + +> JSON response example: + +```json +[ + { + "id": 15, + "name": "Albums", + "slug": "albums", + "parent": 11, + "description": "", + "display": "default", + "image": [], + "menu_order": 0, + "count": 4, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/categories/15" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/categories" + } + ], + "up": [ + { + "href": "https://example.com/wp-json/wc/v1/products/categories/11" + } + ] + } + }, + { + "id": 9, + "name": "Clothing", + "slug": "clothing", + "parent": 0, + "description": "", + "display": "default", + "image": { + "id": 173, + "date_created": "2016-05-31T23:51:03", + "date_modified": "2016-05-31T23:51:03", + "src": "https://example/wp-content/uploads/2016/05/T_3_front-1.jpg", + "title": "", + "alt": "" + }, + "menu_order": 0, + "count": 18, + "_links": { + "self": [ + { + "href": "https://example/wp-json/wc/v1/products/categories/9" + } + ], + "collection": [ + { + "href": "https://example/wp-json/wc/v1/products/categories" + } + ] + } + }, + { + "id": 10, + "name": "Hoodies", + "slug": "hoodies", + "parent": 9, + "description": "", + "display": "default", + "image": [], + "menu_order": 0, + "count": 6, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/categories/10" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/categories" + } + ], + "up": [ + { + "href": "https://example.com/wp-json/wc/v1/products/categories/9" + } + ] + } + }, + { + "id": 11, + "name": "Music", + "slug": "music", + "parent": 0, + "description": "", + "display": "default", + "image": [], + "menu_order": 0, + "count": 7, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/categories/11" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/categories" + } + ] + } + }, + { + "id": 12, + "name": "Posters", + "slug": "posters", + "parent": 0, + "description": "", + "display": "default", + "image": [], + "menu_order": 0, + "count": 5, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/categories/12" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/categories" + } + ] + } + }, + { + "id": 13, + "name": "Singles", + "slug": "singles", + "parent": 11, + "description": "", + "display": "default", + "image": [], + "menu_order": 0, + "count": 3, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/categories/13" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/categories" + } + ], + "up": [ + { + "href": "https://example.com/wp-json/wc/v1/products/categories/11" + } + ] + } + }, + { + "id": 14, + "name": "T-shirts", + "slug": "t-shirts", + "parent": 9, + "description": "", + "display": "default", + "image": [], + "menu_order": 0, + "count": 6, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/categories/14" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/categories" + } + ], + "up": [ + { + "href": "https://example.com/wp-json/wc/v1/products/categories/9" + } + ] + } + } +] +``` + +#### Available parameters #### + +| Parameter | Type | Description | +|--------------|---------|--------------------------------------------------------------------------------------------------------------------------------------------| +| `context` | string | Scope under which the request is made; determines fields present in response. Options: `view` and `edit`. | +| `page` | integer | Current page of the collection. | +| `per_page` | integer | Maximum number of items to be returned in result set. | +| `search` | string | Limit results to those matching a string. | +| `exclude` | string | Ensure result set excludes specific ids. | +| `include` | string | Limit result set to specific ids. | +| `order` | string | Order sort attribute ascending or descending. Default is `asc`. Options: `asc` and `desc`. | +| `orderby` | string | Sort collection by object attribute. Default is `name`. Options: `id`, `include`, `name`, `slug`, `term_group`, `description` and `count`. | +| `hide_empty` | bool | Whether to hide resources not assigned to any products. Default is `false`. | +| `parent` | integer | Limit result set to resources assigned to a specific parent. | +| `product` | integer | Limit result set to resources assigned to a specific product. | +| `slug` | string | Limit result set to resources with a specific slug. | + +## Update a product category ## + +This API lets you make changes to a product category. + +### HTTP request ### + +
+
+ PUT +
/wp-json/wc/v1/products/categories/<id>
+
+
+ +```shell +curl -X PUT https://example.com/wp-json/wc/v1/products/categories/9 \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "product_category": { + "description": "All kinds of clothes." + } +}' +``` + +```javascript +var data = { + product_category: { + description: 'All kinds of clothes.' + } +}; + +WooCommerce.put('products/categories/9', data, function(err, data, res) { + console.log(res); +}); +``` + +```php + [ + 'description' => 'All kinds of clothes.' + ] +]; + +print_r($woocommerce->put('products/categories/9', $data)); +?> +``` + +```python +data = { + "product_category": { + "description": "All kinds of clothes." + } +} + +print(wcapi.put("products/categories/9", data).json()) +``` + +```ruby +data = { + product_category: { + description: "All kinds of clothes." + } +} + +woocommerce.put("products/categories/9", data).parsed_response +``` + +> JSON response example: + +```json +{ + "id": 9, + "name": "Clothing", + "slug": "clothing", + "parent": 0, + "description": "All kinds of clothes.", + "display": "default", + "image": { + "id": 173, + "date_created": "2016-05-31T23:51:03", + "date_modified": "2016-05-31T23:51:03", + "src": "https://example/wp-content/uploads/2016/05/T_3_front-1.jpg", + "title": "", + "alt": "" + }, + "menu_order": 0, + "count": 18, + "_links": { + "self": [ + { + "href": "https://example/wp-json/wc/v1/products/categories/9" + } + ], + "collection": [ + { + "href": "https://example/wp-json/wc/v1/products/categories" + } + ] + } +} +``` + +## Delete a product category ## + +This API helps you delete a product category. + +### HTTP request ### + +
+
+ DELETE +
/wp-json/wc/v1/products/categories/<id>
+
+
+ +```shell +curl -X DELETE https://example.com/wp-json/wc/v1/products/categories/9?force=true \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.delete('products/categories/9?force=true', function(err, data, res) { + console.log(res); +}); +``` + +```php +delete('products/categories/9', ['force' => true])); ?> +``` + +```python +print(wcapi.delete("products/categories/9?force=true").json()) +``` + +```ruby +woocommerce.delete("products/categories/9", force: true).parsed_response +``` + +> JSON response example: + +```json +{ + "id": 9, + "name": "Clothing", + "slug": "clothing", + "parent": 0, + "description": "All kinds of clothes.", + "display": "default", + "image": { + "id": 173, + "date_created": "2016-05-31T23:51:03", + "date_modified": "2016-05-31T23:51:03", + "src": "https://example/wp-content/uploads/2016/05/T_3_front-1.jpg", + "title": "", + "alt": "" + }, + "menu_order": 0, + "count": 18, + "_links": { + "self": [ + { + "href": "https://example/wp-json/wc/v1/products/categories/9" + } + ], + "collection": [ + { + "href": "https://example/wp-json/wc/v1/products/categories" + } + ] + } +} +``` + +#### Available parameters #### + +| Parameter | Type | Description | +|-----------|--------|---------------------------------------------------------------| +| `force` | string | Required to be `true`, as resource does not support trashing. | + +## Batch update product categories ## + +This API helps you to batch create, update and delete multiple product categories. + +### HTTP request ### + +
+
+ POST +
/wp-json/wc/v1/products/categories/batch
+
+
+ +```shell +curl -X POST https://example.com//wp-json/wc/v1/products/categories/batch \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "create": [ + { + "name" => "Albums" + }, + { + "name" => "Clothing" + } + ], + "update": [ + { + "id": 10, + "description": "Nice hoodies" + } + ], + "delete": [ + 11, + 12 + ] +}' +``` + +```javascript +var data = { + create: [ + { + name: 'Albums' + }, + { + name: 'Clothing' + } + ], + update: [ + { + id: 10, + description: 'Nice hoodies' + } + ], + delete: [ + 11, + 12 + ] +}; + +WooCommerce.post('products/categories/batch', data, function(err, data, res) { + console.log(res); +}); +``` + +```php + [ + [ + 'name' => 'Albums' + ], + [ + 'name' => 'Clothing' + ] + ], + 'update' => [ + [ + 'id' => 10, + 'description' => 'Nice hoodies' + ] + ], + 'delete' => [ + 11, + 12 + ] +]; + +print_r($woocommerce->post('products/categories/batch', $data)); +?> +``` + +```python +data = { + "create": [ + { + "name": "Albums" + }, + { + "name": "Clothing" + } + ], + "update": [ + { + "id": 10, + "description": "Nice hoodies" + } + ], + "delete": [ + 11, + 12 + ] +} + +print(wcapi.post("products/categories/batch", data).json()) +``` + +```ruby +data = { + create: [ + { + name: "Albums" + }, + { + name: "Clothing" + } + ], + update: [ + { + id: 10, + description: "Nice hoodies" + } + ], + delete: [ + 11, + 12 + ] +} + +woocommerce.post("products/categories/batch", data).parsed_response +``` + +> JSON response example: + +```json +{ + "create": [ + { + "id": 15, + "name": "Albums", + "slug": "albums", + "parent": 11, + "description": "", + "display": "default", + "image": [], + "menu_order": 0, + "count": 0, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/categories/15" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/categories" + } + ], + "up": [ + { + "href": "https://example.com/wp-json/wc/v1/products/categories/11" + } + ] + } + }, + { + "id": 9, + "name": "Clothing", + "slug": "clothing", + "parent": 0, + "description": "", + "display": "default", + "image": [], + "menu_order": 0, + "count": 0, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/categories/9" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/categories" + } + ] + } + } + ], + "update": [ + { + "id": 10, + "name": "Hoodies", + "slug": "hoodies", + "parent": 9, + "description": "Nice hoodies", + "display": "default", + "image": [], + "menu_order": 0, + "count": 6, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/categories/10" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/categories" + } + ], + "up": [ + { + "href": "https://example.com/wp-json/wc/v1/products/categories/9" + } + ] + } + } + ], + "delete": [ + { + "id": 11, + "name": "Music", + "slug": "music", + "parent": 0, + "description": "", + "display": "default", + "image": [], + "menu_order": 0, + "count": 7, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/categories/11" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/categories" + } + ] + } + }, + { + "id": 12, + "name": "Posters", + "slug": "posters", + "parent": 0, + "description": "", + "display": "default", + "image": [], + "menu_order": 0, + "count": 5, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/categories/12" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/categories" + } + ] + } + } + ] +} +``` diff --git a/source/includes/wp-api-v1/_product-shipping-classes.md b/source/includes/wp-api-v1/_product-shipping-classes.md new file mode 100644 index 00000000..ce233d4e --- /dev/null +++ b/source/includes/wp-api-v1/_product-shipping-classes.md @@ -0,0 +1,625 @@ +# Product shipping classes # + +The product shipping class API allows you to create, view, update, and delete individual, or a batch, of shipping classes. + +## Shipping class properties ## + +| Attribute | Type | Description | +|---------------|---------|------------------------------------------------------------------------------------------| +| `id` | integer | Unique identifier for the resource. read-only | +| `name` | string | Shipping class name. required | +| `slug` | string | An alphanumeric identifier for the resource unique to its type. | +| `description` | string | HTML description of the resource. | +| `count` | integer | Number of published products for the resource. read-only | + +## Create a shipping class ## + +This API helps you to create a new product shipping class. + +### HTTP request ### + +
+
+ POST +
/wp-json/wc/v1/products/shipping_classes
+
+
+ +> Example of how to create a product shipping class: + +```shell +curl -X POST https://example.com/wp-json/wc/v1/products/shipping_classes \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "name": "Priority" +}' +``` + +```javascript +var data = { + name: 'Priority' +}; + +WooCommerce.post('products/shipping_classes', data, function(err, data, res) { + console.log(res); +}); +``` + +```php + 'Priority' +]; + +print_r($woocommerce->post('products/shipping_classes', $data)); +?> +``` + +```python +data = { + "name": "Priority" +} + +print(wcapi.post("products/shipping_classes", data).json()) +``` + +```ruby +data = { + name: "Priority" +} + +woocommerce.post("products/shipping_classes", data).parsed_response +``` + +> JSON response example: + +```json +{ + "id": 32, + "name": "Priority", + "slug": "priority", + "description": "", + "count": 0, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/shipping_classes/32" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/shipping_classes" + } + ] + } +} +``` + +## Retrieve a shipping class ## + +This API lets you retrieve a product shipping class by ID. + +
+
+ GET +
/wp-json/wc/v1/products/shipping_classes/<id>
+
+
+ +```shell +curl https://example.com/wp-json/wc/v1/products/shipping_classes/32 \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('products/shipping_classes/32', function(err, data, res) { + console.log(res); +}); +``` + +```php +get('products/shipping_classes/32')); ?> +``` + +```python +print(wcapi.get("products/shipping_classes/32").json()) +``` + +```ruby +woocommerce.get("products/shipping_classes/32").parsed_response +``` + +> JSON response example: + +```json +{ + "id": 32, + "name": "Priority", + "slug": "priority", + "description": "", + "count": 0, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/shipping_classes/32" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/shipping_classes" + } + ] + } +} +``` + +## List all shipping classes ## + +This API lets you retrieve all product shipping classes. + +
+
+ GET +
/wp-json/wc/v1/products/shipping_classes
+
+
+ +```shell +curl https://example.com/wp-json/wc/v1/products/shipping_classes \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('products/shipping_classes', function(err, data, res) { + console.log(res); +}); +``` + +```php +get('products/shipping_classes')); ?> +``` + +```python +print(wcapi.get("products/shipping_classes").json()) +``` + +```ruby +woocommerce.get("products/shipping_classes").parsed_response +``` + +> JSON response example: + +```json +[ + { + "id": 33, + "name": "Express", + "slug": "express", + "description": "", + "count": 0, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/shipping_classes/33" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/shipping_classes" + } + ] + } + }, + { + "id": 32, + "name": "Priority", + "slug": "priority", + "description": "", + "count": 0, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/shipping_classes/32" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/shipping_classes" + } + ] + } + } +] +``` + +#### Available parameters #### + +| Parameter | Type | Description | +|--------------|---------|--------------------------------------------------------------------------------------------------------------------------------------------| +| `context` | string | Scope under which the request is made; determines fields present in response. Options: `view` and `edit`. | +| `page` | integer | Current page of the collection. | +| `per_page` | integer | Maximum number of items to be returned in result set. | +| `search` | string | Limit results to those matching a string. | +| `exclude` | string | Ensure result set excludes specific ids. | +| `include` | string | Limit result set to specific ids. | +| `order` | string | Order sort attribute ascending or descending. Default is `asc`. Options: `asc` and `desc`. | +| `orderby` | string | Sort collection by object attribute. Default is `name`. Options: `id`, `include`, `name`, `slug`, `term_group`, `description` and `count`. | +| `hide_empty` | bool | Whether to hide resources not assigned to any products. Default is `false`. | +| `product` | integer | Limit result set to resources assigned to a specific product. | +| `slug` | string | Limit result set to resources with a specific slug. | + +## Update a shipping class ## + +This API lets you make changes to a product shipping class. + +### HTTP request ### + +
+
+ PUT +
/wp-json/wc/v1/products/shipping_classes/<id>
+
+
+ +```shell +curl -X PUT https://example.com/wp-json/wc/v1/products/shipping_classes/32 \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "description": "Priority mail." +}' +``` + +```javascript +var data = { + description: 'Priority mail.' +}; + +WooCommerce.put('products/shipping_classes/32', data, function(err, data, res) { + console.log(res); +}); +``` + +```php + 'Priority mail.' +]; + +print_r($woocommerce->put('products/shipping_classes/32', $data)); +?> +``` + +```python +data = { + "description": "Priority mail." +} + +print(wcapi.put("products/shipping_classes/32", data).json()) +``` + +```ruby +data = { + description: "Priority mail." +} + +woocommerce.put("products/shipping_classes/32", data).parsed_response +``` + +> JSON response example: + +```json +{ + "id": 32, + "name": "Priority", + "slug": "priority", + "description": "Priority mail.", + "count": 0, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/shipping_classes/32" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/shipping_classes" + } + ] + } +} +``` + +## Delete a shipping class ## + +This API helps you delete a product shipping class. + +### HTTP request ### + +
+
+ DELETE +
/wp-json/wc/v1/products/shipping_classes/<id>
+
+
+ +```shell +curl -X DELETE https://example.com/wp-json/wc/v1/products/shipping_classes/32?force=true \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.delete('products/shipping_classes/32?force=true', function(err, data, res) { + console.log(res); +}); +``` + +```php +delete('products/shipping_classes/32', ['force' => true])); ?> +``` + +```python +print(wcapi.delete("products/shipping_classes/32?force=true").json()) +``` + +```ruby +woocommerce.delete("products/shipping_classes/32", force: true).parsed_response +``` + +> JSON response example: + +```json +{ + "id": 32, + "name": "Priority", + "slug": "priority", + "description": "Priority mail.", + "count": 0, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/shipping_classes/32" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/shipping_classes" + } + ] + } +} +``` + +#### Available parameters #### + +| Parameter | Type | Description | +|-----------|--------|---------------------------------------------------------------| +| `force` | string | Required to be `true`, as resource does not support trashing. | + +## Batch update shipping classes ## + +This API helps you to batch create, update and delete multiple product shipping classes. + +### HTTP request ### + +
+
+ POST +
/wp-json/wc/v1/products/shipping_classes/batch
+
+
+ +```shell +curl -X POST https://example.com//wp-json/wc/v1/products/shipping_classes/batch \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "create": [ + { + "name" => "Small items" + }, + { + "name" => "Large items" + } + ], + "update": [ + { + "id": 33, + "description": "Express shipping" + } + ], + "delete": [ + 32 + ] +}' +``` + +```javascript +var data = { + create: [ + { + name: 'Small items' + }, + { + name: 'Large items' + } + ], + update: [ + { + id: 33, + description: 'Express shipping' + } + ], + delete: [ + 32 + ] +}; + +WooCommerce.post('products/shipping_classes/batch', data, function(err, data, res) { + console.log(res); +}); +``` + +```php + [ + [ + 'name' => 'Small items' + ], + [ + 'name' => 'Large items' + ] + ], + 'update' => [ + [ + 'id' => 33, + 'description' => 'Express shipping' + ] + ], + 'delete' => [ + 32 + ] +]; + +print_r($woocommerce->post('products/shipping_classes/batch', $data)); +?> +``` + +```python +data = { + "create": [ + { + "name": "Small items" + }, + { + "name": "Large items" + } + ], + "update": [ + { + "id": 33, + "description": "Express shipping" + } + ], + "delete": [ + 32 + ] +} + +print(wcapi.post("products/shipping_classes/batch", data).json()) +``` + +```ruby +data = { + create: [ + { + name: "Small items" + }, + { + name: "Large items" + } + ], + update: [ + { + id: 33, + description: "Express shipping" + } + ], + delete: [ + 32 + ] +} + +woocommerce.post("products/shipping_classes/batch", data).parsed_response +``` + +> JSON response example: + +```json +{ + "create": [ + { + "id": 34, + "name": "Small items", + "slug": "small-items", + "description": "", + "count": 0, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/shipping_classes/34" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/shipping_classes" + } + ] + } + }, + { + "id": 35, + "name": "Large items", + "slug": "large-items", + "description": "", + "count": 0, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/shipping_classes/35" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/shipping_classes" + } + ] + } + } + ], + "update": [ + { + "id": 33, + "name": "Express", + "slug": "express", + "description": "Express shipping", + "count": 0, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/shipping_classes/33" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/shipping_classes" + } + ] + } + } + ], + "delete": [ + { + "id": 32, + "name": "Priority", + "slug": "priority", + "description": "", + "count": 0, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/shipping_classes/32" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/shipping_classes" + } + ] + } + } + ] +} +``` diff --git a/source/includes/wp-api-v1/_product-tags.md b/source/includes/wp-api-v1/_product-tags.md new file mode 100644 index 00000000..16e3f04e --- /dev/null +++ b/source/includes/wp-api-v1/_product-tags.md @@ -0,0 +1,625 @@ +# Product tags # + +The product tags API allows you to create, view, update, and delete individual, or a batch, of product tags. + +## Product tag properties ## + +| Attribute | Type | Description | +|---------------|---------|------------------------------------------------------------------------------------------| +| `id` | integer | Unique identifier for the resource. read-only | +| `name` | string | Tag name. required | +| `slug` | string | An alphanumeric identifier for the resource unique to its type. | +| `description` | string | HTML description of the resource. | +| `count` | integer | Number of published products for the resource. read-only | + +## Create a product tag ## + +This API helps you to create a new product tag. + +### HTTP request ### + +
+
+ POST +
/wp-json/wc/v1/products/tags
+
+
+ +> Example of how to create a product tag: + +```shell +curl -X POST https://example.com/wp-json/wc/v1/products/tags \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "name": "Leather Shoes" +}' +``` + +```javascript +var data = { + name: 'Leather Shoes' +}; + +WooCommerce.post('products/tags', data, function(err, data, res) { + console.log(res); +}); +``` + +```php +post('products/tags', $data)); +?> +``` + +```python +data = { + "name": "Leather Shoes" +} + +print(wcapi.post("products/tags", data).json()) +``` + +```ruby +data = { + name: "Leather Shoes" +} + +woocommerce.post("products/tags", data).parsed_response +``` + +> JSON response example: + +```json +{ + "id": 34, + "name": "Leather Shoes", + "slug": "leather-shoes", + "description": "", + "count": 0, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/tags/34" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/tags" + } + ] + } +} +``` + +## Retrieve a product tag ## + +This API lets you retrieve a product tag by ID. + +
+
+ GET +
/wp-json/wc/v1/products/tags/<id>
+
+
+ +```shell +curl https://example.com/wp-json/wc/v1/products/tags/34 \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('products/tags/34', function(err, data, res) { + console.log(res); +}); +``` + +```php +get('products/tags/34')); ?> +``` + +```python +print(wcapi.get("products/tags/34").json()) +``` + +```ruby +woocommerce.get("products/tags/34").parsed_response +``` + +> JSON response example: + +```json +{ + "id": 34, + "name": "Leather Shoes", + "slug": "leather-shoes", + "description": "", + "count": 0, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/tags/34" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/tags" + } + ] + } +} +``` + +## List all product tags ## + +This API lets you retrieve all product tag. + +
+
+ GET +
/wp-json/wc/v1/products/tags
+
+
+ +```shell +curl https://example.com/wp-json/wc/v1/products/tags \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('products/tags', function(err, data, res) { + console.log(res); +}); +``` + +```php +get('products/tags')); ?> +``` + +```python +print(wcapi.get("products/tags").json()) +``` + +```ruby +woocommerce.get("products/tags").parsed_response +``` + +> JSON response example: + +```json +[ + { + "id": 34, + "name": "Leather Shoes", + "slug": "leather-shoes", + "description": "", + "count": 0, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/tags/34" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/tags" + } + ] + } + }, + { + "id": 35, + "name": "Oxford Shoes", + "slug": "oxford-shoes", + "description": "", + "count": 0, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/tags/35" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/tags" + } + ] + } + } +] +``` + +#### Available parameters #### + +| Parameter | Type | Description | +|--------------|---------|--------------------------------------------------------------------------------------------------------------------------------------------| +| `context` | string | Scope under which the request is made; determines fields present in response. Options: `view` and `edit`. | +| `page` | integer | Current page of the collection. | +| `per_page` | integer | Maximum number of items to be returned in result set. | +| `search` | string | Limit results to those matching a string. | +| `exclude` | string | Ensure result set excludes specific ids. | +| `include` | string | Limit result set to specific ids. | +| `order` | string | Order sort attribute ascending or descending. Default is `asc`. Options: `asc` and `desc`. | +| `orderby` | string | Sort collection by object attribute. Default is `name`. Options: `id`, `include`, `name`, `slug`, `term_group`, `description` and `count`. | +| `hide_empty` | bool | Whether to hide resources not assigned to any products. Default is `false`. | +| `product` | integer | Limit result set to resources assigned to a specific product. | +| `slug` | string | Limit result set to resources with a specific slug. | + +## Update a product tag ## + +This API lets you make changes to a product tag. + +### HTTP request ### + +
+
+ PUT +
/wp-json/wc/v1/products/tags/<id>
+
+
+ +```shell +curl -X PUT https://example.com/wp-json/wc/v1/products/tags/34 \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "description": "Genuine leather." +}' +``` + +```javascript +var data = { + description: 'Genuine leather.' +}; + +WooCommerce.put('products/tags/34', data, function(err, data, res) { + console.log(res); +}); +``` + +```php +put('products/tags/34', $data)); +?> +``` + +```python +data = { + "description": "Genuine leather." +} + +print(wcapi.put("products/tags/34", data).json()) +``` + +```ruby +data = { + description: "Genuine leather." +} + +woocommerce.put("products/tags/34", data).parsed_response +``` + +> JSON response example: + +```json +{ + "id": 34, + "name": "Leather Shoes", + "slug": "leather-shoes", + "description": "Genuine leather.", + "count": 0, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/tags/34" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/tags" + } + ] + } +} +``` + +## Delete a product tag ## + +This API helps you delete a product tag. + +### HTTP request ### + +
+
+ DELETE +
/wp-json/wc/v1/products/tag/<id>
+
+
+ +```shell +curl -X DELETE https://example.com/wp-json/wc/v1/products/tag/34?force=true \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.delete('products/tag/34?force=true', function(err, data, res) { + console.log(res); +}); +``` + +```php +delete('products/tags/34', ['force' => true])); ?> +``` + +```python +print(wcapi.delete("products/tag/34?force=true").json()) +``` + +```ruby +woocommerce.delete("products/tag/34", force: true).parsed_response +``` + +> JSON response example: + +```json +{ + "id": 34, + "name": "Leather Shoes", + "slug": "leather-shoes", + "description": "Genuine leather.", + "count": 0, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/tags/34" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/tags" + } + ] + } +} +``` + +#### Available parameters #### + +| Parameter | Type | Description | +|-----------|--------|---------------------------------------------------------------| +| `force` | string | Required to be `true`, as resource does not support trashing. | + +## Batch update product tags ## + +This API helps you to batch create, update and delete multiple product tags. + +### HTTP request ### + +
+
+ POST +
/wp-json/wc/v1/products/tags/batch
+
+
+ +```shell +curl -X POST https://example.com//wp-json/wc/v1/products/tags/batch \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "create": [ + { + "name" => "Round toe" + }, + { + "name" => "Flat" + } + ], + "update": [ + { + "id": 34, + "description": "Genuine leather." + } + ], + "delete": [ + 35 + ] +}' +``` + +```javascript +var data = { + create: [ + { + name: 'Round toe' + }, + { + name: 'Flat' + } + ], + update: [ + { + id: 34, + description: 'Genuine leather.' + } + ], + delete: [ + 35 + ] +}; + +WooCommerce.post('products/tags/batch', data, function(err, data, res) { + console.log(res); +}); +``` + +```php + [ + [ + 'name' => 'Round toe' + ], + [ + 'name' => 'Flat' + ] + ], + 'update' => [ + [ + 'id' => 34, + 'description' => 'Genuine leather.' + ] + ], + 'delete' => [ + 35 + ] +]; + +print_r($woocommerce->post('products/tags/batch', $data)); +?> +``` + +```python +data = { + "create": [ + { + "name": "Round toe" + }, + { + "name": "Flat" + } + ], + "update": [ + { + "id": 34, + "description": "Genuine leather." + } + ], + "delete": [ + 35 + ] +} + +print(wcapi.post("products/tags/batch", data).json()) +``` + +```ruby +data = { + create: [ + { + name: "Round toe" + }, + { + name: "Flat" + } + ], + update: [ + { + id: 34, + description: "Genuine leather." + } + ], + delete: [ + 35 + ] +} + +woocommerce.post("products/tags/batch", data).parsed_response +``` + +> JSON response example: + +```json +{ + "create": [ + { + "id": 36, + "name": "Round toe", + "slug": "round-toe", + "description": "", + "count": 0, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/tags/36" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/tags" + } + ] + } + }, + { + "id": 37, + "name": "Flat", + "slug": "flat", + "description": "", + "count": 0, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/tags/37" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/tags" + } + ] + } + } + ], + "update": [ + { + "id": 34, + "name": "Leather Shoes", + "slug": "leather-shoes", + "description": "Genuine leather.", + "count": 0, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/tags/34" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/tags" + } + ] + } + } + ], + "delete": [ + { + "id": 35, + "name": "Oxford Shoes", + "slug": "oxford-shoes", + "description": "", + "count": 0, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/tags/35" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/tags" + } + ] + } + } + ] +} +``` diff --git a/source/includes/wp-api-v1/_products.md b/source/includes/wp-api-v1/_products.md new file mode 100644 index 00000000..4e8b5651 --- /dev/null +++ b/source/includes/wp-api-v1/_products.md @@ -0,0 +1,3447 @@ +# Products # + +The products API allows you to create, view, update, and delete individual, or a batch, of products. + +## Product properties ## + +| Attribute | Type | Description | +|------------------------|-----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `id` | integer | Unique identifier for the resource. read-only | +| `name` | string | Product name. | +| `slug` | string | Product slug. | +| `permalink` | string | Product URL. read-only | +| `date_created` | date-time | The date the product was created, in the site's timezone. read-only | +| `date_modified` | date-time | The date the product was last modified, in the site's timezone. read-only | +| `type` | string | Product type. Default is `simple`. Options (plugins may add new options): `simple`, `grouped`, `external`, `variable`. | +| `status` | string | Product status (post status). Default is `publish`. Options (plugins may add new options): `draft`, `pending`, `private` and `publish`. | +| `featured` | boolean | Featured product. Default is `false`. | +| `catalog_visibility` | string | Catalog visibility. Default is `visible`. Options: `visible` (Catalog and search), `catalog` (Only in catalog), `search` (Only in search) and `hidden` (Hidden from all). | +| `description` | string | Product description. | +| `short_description` | string | Product short description. | +| `sku` | string | Unique identifier. | +| `price` | string | Current product price. This is setted from `regular_price` and `sale_price`. read-only | +| `regular_price` | string | Product regular price. | +| `sale_price` | string | Product sale price. | +| `date_on_sale_from` | string | Start date of sale price. Date in the `YYYY-MM-DD` format. | +| `date_on_sale_to` | string | Sets the sale end date. Date in the `YYYY-MM-DD` format. | +| `price_html` | string | Price formatted in HTML, e.g. `$ 3.00 $ 2.00` read-only | +| `on_sale` | boolean | Shows if the product is on sale. read-only | +| `purchasable` | boolean | Shows if the product can be bought. read-only | +| `total_sales` | integer | Amount of sales. read-only | +| `virtual` | boolean | If the product is virtual. Virtual products are intangible and aren't shipped. Default is `false`. | +| `downloadable` | boolean | If the product is downloadable. Downloadable products give access to a file upon purchase. Default is `false`. | +| `downloads` | array | List of downloadable files. See [Downloads Properties](#download-properties). | +| `download_limit` | integer | Amount of times the product can be downloaded, the `-1` values means **unlimited re-downloads**. Default is `-1`. | +| `download_expiry` | integer | Number of days that the customer has up to be able to download the product, the `-1` means that **downloads never expires**. Default is `-1`. | +| `download_type` | string | Download type, this controls the [schema](http://schema.org/) on the front-end. Default is `standard`. Options: `'standard'` (Standard Product), `application` (Application/Software) and `music` (Music). | +| `external_url` | string | Product external URL. Only for `external` products. | +| `button_text` | string | Product external button text. Only for `external` products. | +| `tax_status` | string | Tax status. Default is `taxable`. Options: `taxable`, `shipping` (Shipping only) and `none`. | +| `tax_class` | string | Tax class. | +| `manage_stock` | boolean | Stock management at product level. Default is `false`. | +| `stock_quantity` | integer | Stock quantity. If is a variable product this value will be used to control stock for all variations, unless you define stock at variation level. | +| `in_stock` | boolean | Controls whether or not the product is listed as "in stock" or "out of stock" on the frontend. Default is `true`. | +| `backorders` | string | If managing stock, this controls if backorders are allowed. If enabled, stock quantity can go below `0`. Default is `no`. Options are: `no` (Do not allow), `notify` (Allow, but notify customer), and `yes` (Allow). | +| `backorders_allowed` | boolean | Shows if backorders are allowed. read-only | +| `backordered` | boolean | Shows if a product is on backorder (if the product have the `stock_quantity` negative). read-only | +| `sold_individually` | boolean | Allow one item to be bought in a single order. Default is `false`. | +| `weight` | string | Product weight in decimal format. | +| `dimensions` | array | Product dimensions. See [Dimensions Properties](#dimension-properties). | +| `shipping_required` | boolean | Shows if the product need to be shipped. read-only | +| `shipping_taxable` | boolean | Shows whether or not the product shipping is taxable. read-only | +| `shipping_class` | string | Shipping class slug. Shipping classes are used by certain shipping methods to group similar products. | +| `shipping_class_id` | integer | Shipping class ID. read-only | +| `reviews_allowed` | boolean | Allow reviews. Default is `true`. | +| `average_rating` | string | Reviews average rating. read-only | +| `rating_count` | integer | Amount of reviews that the product have. read-only | +| `related_ids` | array | List of related products IDs (`integer`). read-only | +| `upsell_ids` | array | List of up-sell products IDs (`integer`). Up-sells are products which you recommend instead of the currently viewed product, for example, products that are more profitable or better quality or more expensive. | +| `cross_sell_ids` | array | List of cross-sell products IDs. Cross-sells are products which you promote in the cart, based on the current product. | +| `parent_id` | integer | Product parent ID (`post_parent`). | +| `purchase_note` | string | Optional note to send the customer after purchase. | +| `categories` | array | List of categories. See [Categories Properties](#category-properties). | +| `tags` | array | List of tags. See [Tags Properties](#tag-properties). | +| `images` | array | List of images. See [Images Properties](#image-properties) | +| `attributes` | array | List of attributes. See [Attributes Properties](#attribute-properties). | +| `default_attributes` | array | Defaults variation attributes, used only for variations and pre-selecte attributes on the frontend. See [Default Attributes Properties](#default-attribute-properties). | +| `variations` | array | List of variations. See [Variations Properties](#variation-properties) | +| `grouped_products_ids` | string | List of grouped products ID, only for `group` type products. read-only | +| `menu_order` | integer | Menu order, used to custom sort products. | + +### Download properties ### + +| Attribute | Type | Description | +|-----------|--------|----------------------------------------------------------------------| +| `id` | string | File MD5 hash. read-only | +| `name` | string | File name. | +| `file` | string | File URL. In write-mode you can use this property to send new files. | + +### Dimension properties ### + +| Attribute | Type | Description | +|-----------|--------|-----------------------------------| +| `length` | string | Product length in decimal format. | +| `width` | string | Product width in decimal format. | +| `height` | string | Product height in decimal format. | + +### Category properties ### + +| Attribute | Type | Description | +|-----------|---------|----------------------------------------------------------| +| `id` | integer | Category ID. | +| `name` | string | Category name. read-only | +| `slug` | string | Category slug. read-only | + +### Tag properties ### + +| Attribute | Type | Description | +|-----------|---------|----------------------------------------------------------| +| `id` | integer | Tag ID. | +| `name` | string | Tag name. read-only | +| `slug` | string | Tag slug. read-only | + +### Image properties ### + +| Attribute | Type | Description | +|-----------------|-----------|---------------------------------------------------------------------------------------------------------| +| `id` | integer | Image ID (attachment ID). In write-mode used to attach pre-existing images. | +| `date_created` | date-time | The date the image was created, in the site's timezone. read-only | +| `date_modified` | date-time | The date the image was last modified, in the site's timezone. read-only | +| `src` | string | Image URL. In write-mode used to upload new images. | +| `name` | string | Image name. | +| `alt` | string | Image alternative text. | +| `position` | integer | Image position. `0` means that the image is featured. | + +### Attribute properties ### + +| Attribute | Type | Description | +|-------------|---------|-------------------------------------------------------------------------------------------------------------------| +| `id` | integer | Attribute ID (required if is a global attribute). | +| `name` | string | Attribute name (required if is a non-global attribute). | +| `position` | integer | Attribute position. | +| `visible` | boolean | Define if the attribute is visible on the "Additional Information" tab in the product's page. Default is `false`. | +| `variation` | boolean | Define if the attribute can be used as variation. Default is `false`. | +| `options` | array | List of available term names of the attribute. | + +### Default attribute properties ### + +| Attribute | Type | Description | +|-----------|---------|---------------------------------------------------------| +| `id` | integer | Attribute ID (required if is a global attribute). | +| `name` | string | Attribute name (required if is a non-global attribute). | +| `option` | string | Selected attribute term name. | + +### Variation properties ### + +| Attribute | Type | Description | +|----------------------|-----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `id` | integer | Variation ID. read-only | +| `date_created` | date-time | The date the variation was created, in the site's timezone. read-only | +| `date_modified` | date-time | The date the variation was last modified, in the site's timezone. read-only | +| `permalink` | string | Variation URL. read-only | +| `sku` | string | Unique identifier. | +| `price` | string | Current variation price. This is setted from `regular_price` and `sale_price`. read-only | +| `regular_price` | string | Variation regular price. | +| `sale_price` | string | Variation sale price. | +| `date_on_sale_from` | string | Start date of sale price. Date in the `YYYY-MM-DD` format. | +| `date_on_sale_to` | string | Start date of sale price. Date in the `YYYY-MM-DD` format. | +| `on_sale` | boolean | Shows if the variation is on sale. read-only | +| `purchasable` | boolean | Shows if the variation can be bought. read-only | +| `virtual` | boolean | If the variation is virtual. Virtual variations are intangible and aren't shipped. Default is `false`. | +| `downloadable` | boolean | If the variation is downloadable. Downloadable variations give access to a file upon purchase. Default is `false`. | +| `downloads` | array | List of downloadable files. See [Downloads Properties](#download-properties). | +| `download_limit` | integer | Amount of times the variation can be downloaded, the `-1` values means **unlimited re-downloads**. Default is `-1`. | +| `download_expiry` | integer | Number of days that the customer has up to be able to download the variation, the `-1` means that **downloads never expires**. Default is `-1`. | +| `tax_status` | string | Tax status. Default is `taxable`. Options: `taxable`, `shipping` (Shipping only) and `none`. | +| `tax_class` | string | Tax class. | +| `manage_stock` | boolean | Stock management at variation level. Default is `false`. | +| `stock_quantity` | integer | Stock quantity. If is a variable variation this value will be used to control stock for all variations, unless you define stock at variation level. | +| `in_stock` | boolean | Controls whether or not the variation is listed as "in stock" or "out of stock" on the frontend. Default is `true`. | +| `backorders` | string | If managing stock, this controls if backorders are allowed. If enabled, stock quantity can go below `0`. Default is `no`. Options are: `no` (Do not allow), `notify` (Allow, but notify customer), and `yes` (Allow). | +| `backorders_allowed` | boolean | Shows if backorders are allowed." read-only | +| `backordered` | boolean | Shows if a variation is on backorder (if the variation have the `stock_quantity` negative). read-only | +| `purchaseable` | boolean | Shows if the variation can be bought read-only | +| `weight` | string | Variation weight in decimal format. | +| `dimensions` | array | Variation dimensions. See [Dimensions Properties](#dimension-properties). | +| `shipping_class` | string | Shipping class slug. Shipping classes are used by certain shipping methods to group similar products. | +| `shipping_class_id` | integer | Shipping class ID. read-only | +| `image` | array | Variation featured image. Only position `0` will be used. See [Images Properties](#image-properties). | +| `attributes` | array | List of variation attributes. See [Variation Attributes Properties](#variation-attribute-properties) | + +### Variation attribute properties ### + +| Attribute | Type | Description | +|-----------|---------|---------------------------------------------------------| +| `id` | integer | Attribute ID (required if is a global attribute). | +| `name` | string | Attribute name (required if is a non-global attribute). | +| `option` | string | Selected attribute term name. | + +## Create a product ## + +This API helps you to create a new product. + +### HTTP request ### + +
+
+ POST +
/wp-json/wc/v1/products
+
+
+ +> Example of how to create a `simple` product: + +```shell +curl -X POST https://example.com/wp-json/wc/v1/products \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "name": "Premium Quality", + "type": "simple", + "regular_price": "21.99", + "description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.", + "short_description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.", + "categories": [ + { + "id": 9 + }, + { + "id": 14 + } + ], + "images": [ + { + "src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg", + "position": 0 + }, + { + "src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_back.jpg", + "position": 1 + } + ] +}' +``` + +```javascript +var data = { + name: 'Premium Quality', + type: 'simple', + regular_price: '21.99', + description: 'Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.', + short_description: 'Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.', + categories: [ + { + id: 9 + }, + { + id: 14 + } + ], + images: [ + { + src: 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg', + position: 0 + }, + { + src: 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_back.jpg', + position: 1 + } + ] +}; + +WooCommerce.post('products', data, function(err, data, res) { + console.log(res); +}); +``` + +```php + 'Premium Quality', + 'type' => 'simple', + 'regular_price' => '21.99', + 'description' => 'Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.', + 'short_description' => 'Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.', + 'categories' => [ + [ + 'id': 9 + ], + [ + 'id': 14 + ] + ], + 'images' => [ + [ + 'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg', + 'position' => 0 + ], + [ + 'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_back.jpg', + 'position' => 1 + ] + ] +]; + +print_r($woocommerce->post('products', $data)); +?> +``` + +```python +data = { + "name": "Premium Quality", + "type": "simple", + "regular_price": "21.99", + "description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.", + "short_description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.", + "categories": [ + { + "id": 9 + }, + { + "id": 14 + } + ], + "images": [ + { + "src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg", + "position": 0 + }, + { + "src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_back.jpg", + "position": 1 + } + ] +} + +print(wcapi.post("products", data).json()) +``` + +```ruby +data = { + name: "Premium Quality", + type: "simple", + regular_price: "21.99", + description: "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.", + short_description: "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.", + categories: [ + { + id: 9 + }, + { + id: 14 + } + ], + images: [ + { + src: "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg", + position: 0 + }, + { + src: "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_back.jpg", + position: 1 + } + ] +} + +woocommerce.post("products", data).parsed_response +``` + +> JSON response example: + +```json +{ + "id": 162, + "name": "Premium Quality", + "slug": "premium-quality-3", + "permalink": "https://example.com/product/premium-quality-3/", + "date_created": "2016-05-31T23:40:07", + "date_modified": "2016-05-31T23:40:07", + "type": "simple", + "status": "publish", + "featured": false, + "catalog_visibility": "visible", + "description": "

Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.

\n", + "short_description": "

Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.

\n", + "sku": "", + "price": "21.99", + "regular_price": "21.99", + "sale_price": "", + "date_on_sale_from": "", + "date_on_sale_to": "", + "price_html": "R$21,99", + "on_sale": false, + "purchasable": true, + "total_sales": 0, + "virtual": false, + "downloadable": false, + "downloads": [], + "download_limit": -1, + "download_expiry": -1, + "download_type": "standard", + "external_url": "", + "button_text": "", + "tax_status": "taxable", + "tax_class": "", + "manage_stock": false, + "stock_quantity": null, + "in_stock": true, + "backorders": "no", + "backorders_allowed": false, + "backordered": false, + "sold_individually": false, + "weight": "", + "dimensions": { + "length": "", + "width": "", + "height": "" + }, + "shipping_required": true, + "shipping_taxable": true, + "shipping_class": "", + "shipping_class_id": 0, + "reviews_allowed": true, + "average_rating": "0.00", + "rating_count": 0, + "related_ids": [], + "upsell_ids": [], + "cross_sell_ids": [], + "parent_id": 0, + "purchase_note": "", + "categories": [ + { + "id": 9, + "name": "Clothing", + "slug": "clothing" + }, + { + "id": 14, + "name": "T-shirts", + "slug": "t-shirts" + } + ], + "tags": [], + "images": [ + { + "id": 163, + "date_created": "2016-05-31T23:40:07", + "date_modified": "2016-05-31T23:40:07", + "src": "https://example.com/wp-content/uploads/2016/05/T_2_front.jpg", + "title": "", + "alt": "", + "position": 0 + }, + { + "id": 164, + "date_created": "2016-05-31T23:40:10", + "date_modified": "2016-05-31T23:40:10", + "src": "https://example.com/wp-content/uploads/2016/05/T_2_back.jpg", + "title": "", + "alt": "", + "position": 1 + } + ], + "attributes": [], + "default_attributes": [], + "variations": [], + "grouped_products": [], + "menu_order": 0, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/162" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products" + } + ] + } +} +``` + +> Example of how to create a `variable` product with global and non-global attributes: + +```shell +curl -X POST https://example.com/wp-json/wc/v1/products \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "name": "Ship Your Idea", + "type": "variable", + "description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.", + "short_description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.", + "categories": [ + { + "id": 9 + }, + { + "id": 14 + } + ], + "images": [ + { + "src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_front.jpg", + "position": 0 + }, + { + "src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_back.jpg", + "position": 1 + }, + { + "src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_front.jpg", + "position": 2 + }, + { + "src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_back.jpg", + "position": 3 + } + ], + "attributes": [ + { + "id": 6, + "position": 0, + "visible": false, + "variation": true, + "options": [ + "Black", + "Green" + ] + }, + { + "name": "Size", + "position": 0, + "visible": true, + "variation": true, + "options": [ + "S", + "M" + ] + } + ], + "default_attributes": [ + { + "id": 6, + "option": "Black" + }, + { + "name": "Size", + "option": "S" + } + ], + "variations": [ + { + "regular_price": "19.99", + "image": [ + { + "src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_front.jpg", + "position": 0 + } + ], + "attributes": [ + { + "id": 6, + "option": "black" + }, + { + "name": "Size", + "option": "S" + } + ] + }, + { + "regular_price": "19.99", + "image": [ + { + "src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_front.jpg", + "position": 0 + } + ], + "attributes": [ + { + "id": 6, + "option": "green" + }, + { + "name": "Size", + "option": "M" + } + ] + } + ] +}' +``` + +```javascript +var data = { + name: 'Ship Your Idea', + type: 'variable', + description: 'Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.', + short_description: 'Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.', + categories: [ + { + id: 9 + }, + { + id: 14 + } + ], + images: [ + { + src: 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_front.jpg', + position: 0 + }, + { + src: 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_back.jpg', + position: 1 + }, + { + src: 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_front.jpg', + position: 2 + }, + { + src: 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_back.jpg', + position: 3 + } + ], + attributes: [ + { + id: 6, + position: 0, + visible: true, + variation: true, + options: [ + 'Black', + 'Green' + ] + } + { + name: 'Size', + position: 0, + visible: false, + variation: true, + options: [ + 'S', + 'M' + ] + } + ], + default_attributes: [ + { + id: 6, + option: 'Black' + }, + { + name: 'Size', + option: 'S' + } + ], + variations: [ + { + regular_price: '19.99', + image: [ + { + src: 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_front.jpg', + position: 0 + } + ], + attributes: [ + { + id: 6, + option: 'black' + }, + { + name: 'Size', + option: 'S' + } + ] + }, + { + regular_price: '19.99', + image: [ + { + src: 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_front.jpg', + position: 0 + } + ], + attributes: [ + { + id: 6, + option: 'green' + }, + { + name: 'Size', + option: 'M' + } + ] + } + ] +}; + +WooCommerce.post('products', data, function(err, data, res) { + console.log(res); +}); +``` + +```php + 'Ship Your Idea', + 'type' => 'variable', + 'description' => 'Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.', + 'short_description' => 'Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.', + 'categories' => [ + [ + 'id': 9 + ], + [ + 'id': 14 + ] + ], + 'images' => [ + [ + 'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_front.jpg', + 'position' => 0 + ], + [ + 'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_back.jpg', + 'position' => 1 + ], + [ + 'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_front.jpg', + 'position' => 2 + ], + [ + 'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_back.jpg', + 'position' => 3 + ] + ], + 'attributes' => [ + [ + 'id' => 6, + 'position' => 0, + 'visible' => false, + 'variation' => true, + 'options' => [ + 'Black', + 'Green' + ] + ], + [ + 'name' => 'Size', + 'position' => 0, + 'visible' => true, + 'variation' => true, + 'options' => [ + 'S', + 'M' + ] + ] + ], + 'default_attributes' => [ + [ + 'id' => 6, + 'option' => 'Black' + ], + [ + 'name' => 'Size', + 'option' => 'S' + ] + ], + 'variations' => [ + [ + 'regular_price' => '19.99', + 'image' => [ + [ + 'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_front.jpg', + 'position' => 0 + ] + ], + 'attributes' => [ + [ + 'id' => 6, + 'option' => 'black' + ], + [ + 'name' => 'Size', + 'option' => 'S' + ] + ] + ], + [ + 'regular_price' => '19.99', + 'image' => [ + [ + 'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_front.jpg', + 'position' => 0 + ] + ], + 'attributes' => [ + [ + 'id' => 6, + 'option' => 'green' + ], + [ + 'name' => 'Size', + 'option' => 'M' + ] + ] + ] + ] +]; + +print_r($woocommerce->post('products', $data)); +?> +``` + +```python +data = { + "name": "Ship Your Idea", + "type": "variable", + "description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.", + "short_description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.", + "categories": [ + { + "id": 9 + }, + { + "id": 14 + } + ], + "images": [ + { + "src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_front.jpg", + "position": 0 + }, + { + "src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_back.jpg", + "position": 1 + }, + { + "src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_front.jpg", + "position": 2 + }, + { + "src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_back.jpg", + "position": 3 + } + ], + "attributes": [ + { + "id": 6, + "position": 0, + "visible": False, + "variation": True, + "options": [ + "Black", + "Green" + ] + }, + { + "name": "Size", + "position": 0, + "visible": True, + "variation": True, + "options": [ + "S", + "M" + ] + } + ], + "default_attributes": [ + { + "id": 6, + "option": "Black" + }, + { + "name": "Size", + "option": "S" + } + ], + "variations": [ + { + "regular_price": "19.99", + "image": [ + { + "src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_front.jpg", + "position": 0 + } + ], + "attributes": [ + { + "id": 6, + "option": "black" + }, + { + "name": "Size", + "option": "S" + } + ] + }, + { + "regular_price": "19.99", + "image": [ + { + "src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_front.jpg", + "position": 0 + } + ], + "attributes": [ + { + "id": 6, + "option": "green" + }, + { + "name": "Size", + "option": "M" + } + ] + } + ] +} + +print(wcapi.post("products", data).json()) +``` + +```ruby +data = { + name: "Ship Your Idea", + type: "variable", + description: "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.", + short_description: "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.", + categories: [ + { + id: 9 + }, + { + id: 14 + } + ], + images: [ + { + src: "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_front.jpg", + position: 0 + }, + { + src: "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_back.jpg", + position: 1 + }, + { + src: "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_front.jpg", + position: 2 + }, + { + src: "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_back.jpg", + position: 3 + } + ], + attributes: [ + { + id: 6, + position: 0, + visible: false, + variation: true, + options: [ + "Black", + "Green" + ] + }, + { + name: "Size", + position: 0, + visible: true, + variation: true, + options: [ + "S", + "M" + ] + } + ], + default_attributes: [ + { + id: 6, + option: "Black" + }, + { + name: "Size", + option: "S" + } + ], + variations: [ + { + regular_price: "19.99", + image: [ + { + src: "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_front.jpg", + position: 0 + } + ], + attributes: [ + { + id: 6, + option: "black" + }, + { + name: "Size", + option: "S" + } + ] + }, + { + regular_price: "19.99", + image: [ + { + src: "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_front.jpg", + position: 0 + } + ], + attributes: [ + { + id: 6, + option: "green" + }, + { + name: "Size", + option: "M" + } + ] + } + ] +} + +woocommerce.post("products", data).parsed_response +``` + +> JSON response example: + +```json +{ + "id": 165, + "name": "Ship Your Idea", + "slug": "ship-your-idea-4", + "permalink": "https://example.com/product/ship-your-idea-4/", + "date_created": "2016-05-31T23:50:56", + "date_modified": "2016-06-02T23:11:41", + "type": "variable", + "status": "publish", + "featured": false, + "catalog_visibility": "visible", + "description": "

Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.

\n", + "short_description": "

Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.

\n", + "sku": "", + "price": "19.99", + "regular_price": "", + "sale_price": "", + "date_on_sale_from": "", + "date_on_sale_to": "", + "price_html": "R$19,99", + "on_sale": false, + "purchasable": true, + "total_sales": 0, + "virtual": false, + "downloadable": false, + "downloads": [], + "download_limit": -1, + "download_expiry": -1, + "download_type": "standard", + "external_url": "", + "button_text": "", + "tax_status": "taxable", + "tax_class": "", + "manage_stock": false, + "stock_quantity": null, + "in_stock": true, + "backorders": "no", + "backorders_allowed": false, + "backordered": false, + "sold_individually": false, + "weight": "", + "dimensions": { + "length": "", + "width": "", + "height": "" + }, + "shipping_required": true, + "shipping_taxable": true, + "shipping_class": "", + "shipping_class_id": 0, + "reviews_allowed": true, + "average_rating": "0.00", + "rating_count": 0, + "related_ids": [ + 34, + 37, + 187, + 205, + 31 + ], + "upsell_ids": [], + "cross_sell_ids": [], + "parent_id": 0, + "purchase_note": "", + "categories": [ + { + "id": 9, + "name": "Clothing", + "slug": "clothing" + }, + { + "id": 14, + "name": "T-shirts", + "slug": "t-shirts" + } + ], + "tags": [], + "images": [ + { + "id": 166, + "date_created": "2016-05-31T23:50:57", + "date_modified": "2016-05-31T23:50:57", + "src": "https://example.com/wp-content/uploads/2016/05/T_4_front.jpg", + "title": "", + "alt": "", + "position": 0 + }, + { + "id": 167, + "date_created": "2016-05-31T23:50:57", + "date_modified": "2016-05-31T23:50:57", + "src": "https://example.com/wp-content/uploads/2016/05/T_4_back.jpg", + "title": "", + "alt": "", + "position": 1 + }, + { + "id": 168, + "date_created": "2016-05-31T23:50:58", + "date_modified": "2016-05-31T23:50:58", + "src": "https://example.com/wp-content/uploads/2016/05/T_3_front.jpg", + "title": "", + "alt": "", + "position": 2 + }, + { + "id": 169, + "date_created": "2016-05-31T23:50:59", + "date_modified": "2016-05-31T23:50:59", + "src": "https://example.com/wp-content/uploads/2016/05/T_3_back.jpg", + "title": "", + "alt": "", + "position": 3 + } + ], + "attributes": [ + { + "id": 6, + "name": "Color", + "position": 0, + "visible": false, + "variation": true, + "options": [ + "Black", + "Green" + ] + }, + { + "id": 0, + "name": "Size", + "position": 1, + "visible": true, + "variation": true, + "options": [ + "S", + "M" + ] + } + ], + "default_attributes": [ + { + "id": 6, + "name": "Color", + "option": "black" + }, + { + "id": 0, + "name": "size", + "option": "S" + } + ], + "variations": [ + { + "id": 170, + "date_created": "2016-05-31T23:50:56", + "date_modified": "2016-06-02T23:11:41", + "permalink": "https://example.com/product/ship-your-idea-4/?attribute_pa_color=black&attribute_size=S", + "sku": "", + "price": "19.99", + "regular_price": "19.99", + "sale_price": "", + "date_on_sale_from": "", + "date_on_sale_to": "", + "on_sale": false, + "purchasable": true, + "virtual": false, + "downloadable": false, + "downloads": [], + "download_limit": -1, + "download_expiry": -1, + "tax_status": "taxable", + "tax_class": "", + "manage_stock": false, + "stock_quantity": null, + "in_stock": true, + "backorders": "no", + "backorders_allowed": false, + "backordered": false, + "weight": "", + "dimensions": { + "length": "", + "width": "", + "height": "" + }, + "shipping_class": "", + "shipping_class_id": 0, + "image": [ + { + "id": 171, + "date_created": "2016-05-31T23:51:01", + "date_modified": "2016-05-31T23:51:01", + "src": "https://example.com/wp-content/uploads/2016/05/T_4_front-1.jpg", + "title": "", + "alt": "", + "position": 0 + } + ], + "attributes": [ + { + "id": 6, + "name": "Color", + "option": "black" + }, + { + "id": 0, + "name": "size", + "option": "S" + } + ] + }, + { + "id": 172, + "date_created": "2016-05-31T23:50:56", + "date_modified": "2016-06-02T23:11:41", + "permalink": "https://example.com/product/ship-your-idea-4/?attribute_pa_color=green&attribute_size=M", + "sku": "", + "price": "19.99", + "regular_price": "19.99", + "sale_price": "", + "date_on_sale_from": "", + "date_on_sale_to": "", + "on_sale": false, + "purchasable": true, + "virtual": false, + "downloadable": false, + "downloads": [], + "download_limit": -1, + "download_expiry": -1, + "tax_status": "taxable", + "tax_class": "", + "manage_stock": false, + "stock_quantity": null, + "in_stock": true, + "backorders": "no", + "backorders_allowed": false, + "backordered": false, + "weight": "", + "dimensions": { + "length": "", + "width": "", + "height": "" + }, + "shipping_class": "", + "shipping_class_id": 0, + "image": [ + { + "id": 173, + "date_created": "2016-05-31T23:51:03", + "date_modified": "2016-05-31T23:51:03", + "src": "https://example.com/wp-content/uploads/2016/05/T_3_front-1.jpg", + "title": "", + "alt": "", + "position": 0 + } + ], + "attributes": [ + { + "id": 6, + "name": "Color", + "option": "green" + }, + { + "id": 0, + "name": "size", + "option": "M" + } + ] + } + ], + "grouped_products": [], + "menu_order": 0, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/165" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products" + } + ] + } +} +``` + +## Retrieve a product ## + +This API lets you retrieve and view a specific product by ID. + +### HTTP request ### + +
+
+ GET +
/wp-json/wc/v1/products/<id>
+
+
+ +```shell +curl https://example.com/wp-json/wc/v1/products/162 \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('products/162', function(err, data, res) { + console.log(res); +}); +``` + +```php +get('products/162')); ?> +``` + +```python +print(wcapi.get("products/162").json()) +``` + +```ruby +woocommerce.get("products/162").parsed_response +``` + +> JSON response example: + +```json +{ + "id": 162, + "name": "Premium Quality", + "slug": "premium-quality-3", + "permalink": "https://example.com/product/premium-quality-3/", + "date_created": "2016-05-31T23:40:07", + "date_modified": "2016-05-31T23:40:07", + "type": "simple", + "status": "publish", + "featured": false, + "catalog_visibility": "visible", + "description": "

Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.

\n", + "short_description": "

Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.

\n", + "sku": "", + "price": "21.99", + "regular_price": "21.99", + "sale_price": "", + "date_on_sale_from": "", + "date_on_sale_to": "", + "price_html": "R$21,99", + "on_sale": false, + "purchasable": true, + "total_sales": 0, + "virtual": false, + "downloadable": false, + "downloads": [], + "download_limit": -1, + "download_expiry": -1, + "download_type": "standard", + "external_url": "", + "button_text": "", + "tax_status": "taxable", + "tax_class": "", + "manage_stock": false, + "stock_quantity": null, + "in_stock": true, + "backorders": "no", + "backorders_allowed": false, + "backordered": false, + "sold_individually": false, + "weight": "", + "dimensions": { + "length": "", + "width": "", + "height": "" + }, + "shipping_required": true, + "shipping_taxable": true, + "shipping_class": "", + "shipping_class_id": 0, + "reviews_allowed": true, + "average_rating": "0.00", + "rating_count": 0, + "related_ids": [], + "upsell_ids": [], + "cross_sell_ids": [], + "parent_id": 0, + "purchase_note": "", + "categories": [ + { + "id": 9, + "name": "Clothing", + "slug": "clothing" + }, + { + "id": 14, + "name": "T-shirts", + "slug": "t-shirts" + } + ], + "tags": [], + "images": [ + { + "id": 163, + "date_created": "2016-05-31T23:40:07", + "date_modified": "2016-05-31T23:40:07", + "src": "https://example.com/wp-content/uploads/2016/05/T_2_front.jpg", + "title": "", + "alt": "", + "position": 0 + }, + { + "id": 164, + "date_created": "2016-05-31T23:40:10", + "date_modified": "2016-05-31T23:40:10", + "src": "https://example.com/wp-content/uploads/2016/05/T_2_back.jpg", + "title": "", + "alt": "", + "position": 1 + } + ], + "attributes": [], + "default_attributes": [], + "variations": [], + "grouped_products": [], + "menu_order": 0, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/162" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products" + } + ] + } +} +``` + +## List all products ## + +This API helps you to view all the products. + +### HTTP request ### + +
+
+ GET +
/wp-json/wc/v1/products
+
+
+ +```shell +curl https://example.com/wp-json/wc/v1/products \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('products', function(err, data, res) { + console.log(res); +}); +``` + +```php +get('products')); ?> +``` + +```python +print(wcapi.get("products").json()) +``` + +```ruby +woocommerce.get("products").parsed_response +``` + +> JSON response example: + +```json +[ + { + "id": 165, + "name": "Ship Your Idea", + "slug": "ship-your-idea-4", + "permalink": "https://example.com/product/ship-your-idea-4/", + "date_created": "2016-05-31T23:50:56", + "date_modified": "2016-06-02T23:11:41", + "type": "variable", + "status": "publish", + "featured": false, + "catalog_visibility": "visible", + "description": "

Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.

\n", + "short_description": "

Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.

\n", + "sku": "", + "price": "19.99", + "regular_price": "", + "sale_price": "", + "date_on_sale_from": "", + "date_on_sale_to": "", + "price_html": "R$19,99", + "on_sale": false, + "purchasable": true, + "total_sales": 0, + "virtual": false, + "downloadable": false, + "downloads": [], + "download_limit": -1, + "download_expiry": -1, + "download_type": "standard", + "external_url": "", + "button_text": "", + "tax_status": "taxable", + "tax_class": "", + "manage_stock": false, + "stock_quantity": null, + "in_stock": true, + "backorders": "no", + "backorders_allowed": false, + "backordered": false, + "sold_individually": false, + "weight": "", + "dimensions": { + "length": "", + "width": "", + "height": "" + }, + "shipping_required": true, + "shipping_taxable": true, + "shipping_class": "", + "shipping_class_id": 0, + "reviews_allowed": true, + "average_rating": "0.00", + "rating_count": 0, + "related_ids": [ + 34, + 37, + 187, + 205, + 31 + ], + "upsell_ids": [], + "cross_sell_ids": [], + "parent_id": 0, + "purchase_note": "", + "categories": [ + { + "id": 9, + "name": "Clothing", + "slug": "clothing" + }, + { + "id": 14, + "name": "T-shirts", + "slug": "t-shirts" + } + ], + "tags": [], + "images": [ + { + "id": 166, + "date_created": "2016-05-31T23:50:57", + "date_modified": "2016-05-31T23:50:57", + "src": "https://example.com/wp-content/uploads/2016/05/T_4_front.jpg", + "title": "", + "alt": "", + "position": 0 + }, + { + "id": 167, + "date_created": "2016-05-31T23:50:57", + "date_modified": "2016-05-31T23:50:57", + "src": "https://example.com/wp-content/uploads/2016/05/T_4_back.jpg", + "title": "", + "alt": "", + "position": 1 + }, + { + "id": 168, + "date_created": "2016-05-31T23:50:58", + "date_modified": "2016-05-31T23:50:58", + "src": "https://example.com/wp-content/uploads/2016/05/T_3_front.jpg", + "title": "", + "alt": "", + "position": 2 + }, + { + "id": 169, + "date_created": "2016-05-31T23:50:59", + "date_modified": "2016-05-31T23:50:59", + "src": "https://example.com/wp-content/uploads/2016/05/T_3_back.jpg", + "title": "", + "alt": "", + "position": 3 + } + ], + "attributes": [ + { + "id": 6, + "name": "Color", + "position": 0, + "visible": false, + "variation": true, + "options": [ + "Black", + "Green" + ] + }, + { + "id": 0, + "name": "Size", + "position": 1, + "visible": true, + "variation": true, + "options": [ + "S", + "M" + ] + } + ], + "default_attributes": [ + { + "id": 6, + "name": "Color", + "option": "black" + }, + { + "id": 0, + "name": "size", + "option": "S" + } + ], + "variations": [ + { + "id": 170, + "date_created": "2016-05-31T23:50:56", + "date_modified": "2016-06-02T23:11:41", + "permalink": "https://example.com/product/ship-your-idea-4/?attribute_pa_color=black&attribute_size=S", + "sku": "", + "price": "19.99", + "regular_price": "19.99", + "sale_price": "", + "date_on_sale_from": "", + "date_on_sale_to": "", + "on_sale": false, + "purchasable": true, + "virtual": false, + "downloadable": false, + "downloads": [], + "download_limit": -1, + "download_expiry": -1, + "tax_status": "taxable", + "tax_class": "", + "manage_stock": false, + "stock_quantity": null, + "in_stock": true, + "backorders": "no", + "backorders_allowed": false, + "backordered": false, + "weight": "", + "dimensions": { + "length": "", + "width": "", + "height": "" + }, + "shipping_class": "", + "shipping_class_id": 0, + "image": [ + { + "id": 171, + "date_created": "2016-05-31T23:51:01", + "date_modified": "2016-05-31T23:51:01", + "src": "https://example.com/wp-content/uploads/2016/05/T_4_front-1.jpg", + "title": "", + "alt": "", + "position": 0 + } + ], + "attributes": [ + { + "id": 6, + "name": "Color", + "option": "black" + }, + { + "id": 0, + "name": "size", + "option": "S" + } + ] + }, + { + "id": 172, + "date_created": "2016-05-31T23:50:56", + "date_modified": "2016-06-02T23:11:41", + "permalink": "https://example.com/product/ship-your-idea-4/?attribute_pa_color=green&attribute_size=M", + "sku": "", + "price": "19.99", + "regular_price": "19.99", + "sale_price": "", + "date_on_sale_from": "", + "date_on_sale_to": "", + "on_sale": false, + "purchasable": true, + "virtual": false, + "downloadable": false, + "downloads": [], + "download_limit": -1, + "download_expiry": -1, + "tax_status": "taxable", + "tax_class": "", + "manage_stock": false, + "stock_quantity": null, + "in_stock": true, + "backorders": "no", + "backorders_allowed": false, + "backordered": false, + "weight": "", + "dimensions": { + "length": "", + "width": "", + "height": "" + }, + "shipping_class": "", + "shipping_class_id": 0, + "image": [ + { + "id": 173, + "date_created": "2016-05-31T23:51:03", + "date_modified": "2016-05-31T23:51:03", + "src": "https://example.com/wp-content/uploads/2016/05/T_3_front-1.jpg", + "title": "", + "alt": "", + "position": 0 + } + ], + "attributes": [ + { + "id": 6, + "name": "Color", + "option": "green" + }, + { + "id": 0, + "name": "size", + "option": "M" + } + ] + } + ], + "grouped_products": [], + "menu_order": 0, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/165" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products" + } + ] + } + }, + { + "id": 162, + "name": "Premium Quality", + "slug": "premium-quality-3", + "permalink": "https://example.com/product/premium-quality-3/", + "date_created": "2016-05-31T23:40:07", + "date_modified": "2016-05-31T23:40:07", + "type": "simple", + "status": "publish", + "featured": false, + "catalog_visibility": "visible", + "description": "

Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.

\n", + "short_description": "

Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.

\n", + "sku": "", + "price": "21.99", + "regular_price": "21.99", + "sale_price": "", + "date_on_sale_from": "", + "date_on_sale_to": "", + "price_html": "R$21,99", + "on_sale": false, + "purchasable": true, + "total_sales": 0, + "virtual": false, + "downloadable": false, + "downloads": [], + "download_limit": -1, + "download_expiry": -1, + "download_type": "standard", + "external_url": "", + "button_text": "", + "tax_status": "taxable", + "tax_class": "", + "manage_stock": false, + "stock_quantity": null, + "in_stock": true, + "backorders": "no", + "backorders_allowed": false, + "backordered": false, + "sold_individually": false, + "weight": "", + "dimensions": { + "length": "", + "width": "", + "height": "" + }, + "shipping_required": true, + "shipping_taxable": true, + "shipping_class": "", + "shipping_class_id": 0, + "reviews_allowed": true, + "average_rating": "0.00", + "rating_count": 0, + "related_ids": [], + "upsell_ids": [], + "cross_sell_ids": [], + "parent_id": 0, + "purchase_note": "", + "categories": [ + { + "id": 9, + "name": "Clothing", + "slug": "clothing" + }, + { + "id": 14, + "name": "T-shirts", + "slug": "t-shirts" + } + ], + "tags": [], + "images": [ + { + "id": 163, + "date_created": "2016-05-31T23:40:07", + "date_modified": "2016-05-31T23:40:07", + "src": "https://example.com/wp-content/uploads/2016/05/T_2_front.jpg", + "title": "", + "alt": "", + "position": 0 + }, + { + "id": 164, + "date_created": "2016-05-31T23:40:10", + "date_modified": "2016-05-31T23:40:10", + "src": "https://example.com/wp-content/uploads/2016/05/T_2_back.jpg", + "title": "", + "alt": "", + "position": 1 + } + ], + "attributes": [], + "default_attributes": [], + "variations": [], + "grouped_products": [], + "menu_order": 0, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/162" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products" + } + ] + } + } +] +``` + +#### Available parameters #### + +| Parameter | Type | Description | +|------------------|---------|-------------------------------------------------------------------------------------------------------------------------------------------------| +| `context` | string | Scope under which the request is made; determines fields present in response. Options: `view` and `edit`. | +| `page` | integer | Current page of the collection. | +| `per_page` | integer | Maximum number of items to be returned in result set. | +| `search` | string | Limit results to those matching a string. | +| `after` | string | Limit response to resources published after a given ISO8601 compliant date. | +| `before` | string | Limit response to resources published before a given ISO8601 compliant date. | +| `exclude` | string | Ensure result set excludes specific ids. | +| `include` | string | Limit result set to specific ids. | +| `offset` | integer | Offset the result set by a specific number of items. | +| `order` | string | Order sort attribute ascending or descending. Default is `asc`. Options: `asc` and `desc`. | +| `orderby` | string | Sort collection by object attribute. Default is `date`, Options: `date`, `id`, `include`, `title` and `slug`. | +| `filter` | string | Use WP Query arguments to modify the response; private query vars require appropriate authorization. | +| `slug` | string | Limit result set to products with a specific slug. | +| `status` | string | Limit result set to products assigned a specific status. Default is `any`. Options: `any`, `draft`, `pending`, `private` and `publish`. | +| `customer` | string | Limit result set to orders assigned a specific customer. | +| `category` | string | Limit result set to products assigned a specific category, e.g. `?category=9,14`. | +| `tag` | string | Limit result set to products assigned a specific tag, e.g. `?tag=9,14`. | +| `shipping_class` | string | Limit result set to products assigned a specific shipping class, e.g. `?shipping_class=9,14`. | +| `attribute` | string | Limit result set to products with a specific attribute, e.g. `?attribute=pa_color`. | +| `attribute_term` | string | Limit result set to products with a specific attribute term (required an assigned `attribute`), e.g. `?attribute=pa_color&attribute_term=9,14`. | +| `sku` | string | Limit result set to products with a specific SKU. | + +## Update a product ## + +This API lets you make changes to a product. + +### HTTP request ### + +
+
+ PUT +
/wp-json/wc/v1/products/<id>
+
+
+ +```shell +curl -X PUT https://example.com/wp-json/wc/v1/products/162 \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "regular_price": "24.54" +}' +``` + +```javascript +var data = { + regular_price: '24.54' +}; + +WooCommerce.put('products/162', data, function(err, data, res) { + console.log(res); +}); +``` + +```php + '24.54' +]; + +print_r($woocommerce->put('products/162', $data)); +?> +``` + +```python +data = { + "regular_price": "24.54" +} + +print(wcapi.put("products/162", data).json()) +``` + +```ruby +data = { + regular_price: "24.54" +} + +woocommerce.put("products/162", data).parsed_response +``` + +> JSON response example: + +```json +{ + "id": 162, + "name": "Premium Quality", + "slug": "premium-quality-3", + "permalink": "https://example.com/product/premium-quality-3/", + "date_created": "2016-05-31T23:40:07", + "date_modified": "2016-05-31T23:40:07", + "type": "simple", + "status": "publish", + "featured": false, + "catalog_visibility": "visible", + "description": "

Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.

\n", + "short_description": "

Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.

\n", + "sku": "", + "price": "24.54", + "regular_price": "24.54", + "sale_price": "", + "date_on_sale_from": "", + "date_on_sale_to": "", + "price_html": "R$24,54", + "on_sale": false, + "purchasable": true, + "total_sales": 0, + "virtual": false, + "downloadable": false, + "downloads": [], + "download_limit": -1, + "download_expiry": -1, + "download_type": "standard", + "external_url": "", + "button_text": "", + "tax_status": "taxable", + "tax_class": "", + "manage_stock": false, + "stock_quantity": null, + "in_stock": true, + "backorders": "no", + "backorders_allowed": false, + "backordered": false, + "sold_individually": false, + "weight": "", + "dimensions": { + "length": "", + "width": "", + "height": "" + }, + "shipping_required": true, + "shipping_taxable": true, + "shipping_class": "", + "shipping_class_id": 0, + "reviews_allowed": true, + "average_rating": "0.00", + "rating_count": 0, + "related_ids": [], + "upsell_ids": [], + "cross_sell_ids": [], + "parent_id": 0, + "purchase_note": "", + "categories": [ + { + "id": 9, + "name": "Clothing", + "slug": "clothing" + }, + { + "id": 14, + "name": "T-shirts", + "slug": "t-shirts" + } + ], + "tags": [], + "images": [ + { + "id": 163, + "date_created": "2016-05-31T23:40:07", + "date_modified": "2016-05-31T23:40:07", + "src": "https://example.com/wp-content/uploads/2016/05/T_2_front.jpg", + "title": "", + "alt": "", + "position": 0 + }, + { + "id": 164, + "date_created": "2016-05-31T23:40:10", + "date_modified": "2016-05-31T23:40:10", + "src": "https://example.com/wp-content/uploads/2016/05/T_2_back.jpg", + "title": "", + "alt": "", + "position": 1 + } + ], + "attributes": [], + "default_attributes": [], + "variations": [], + "grouped_products": [], + "menu_order": 0, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/162" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products" + } + ] + } +} +``` + +## Delete a product ## + +This API helps you delete a product. + +### HTTP request ### + +
+
+ DELETE +
/wp-json/wc/v1/products/<id>
+
+
+ +```shell +curl -X DELETE https://example.com/wp-json/wc/v1/products/162?force=true \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.delete('products/162?force=true', function(err, data, res) { + console.log(res); +}); +``` + +```php +delete('products/162', ['force' => true])); ?> +``` + +```python +print(wcapi.delete("products/162?force=true").json()) +``` + +```ruby +woocommerce.delete("products/162", force: true).parsed_response +``` + +> JSON response example: + +```json +{ + "id": 162, + "name": "Premium Quality", + "slug": "premium-quality-3", + "permalink": "https://example.com/product/premium-quality-3/", + "date_created": "2016-05-31T23:40:07", + "date_modified": "2016-05-31T23:40:07", + "type": "simple", + "status": "publish", + "featured": false, + "catalog_visibility": "visible", + "description": "

Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.

\n", + "short_description": "

Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.

\n", + "sku": "", + "price": "24.54", + "regular_price": "24.54", + "sale_price": "", + "date_on_sale_from": "", + "date_on_sale_to": "", + "price_html": "R$24,54", + "on_sale": false, + "purchasable": true, + "total_sales": 0, + "virtual": false, + "downloadable": false, + "downloads": [], + "download_limit": -1, + "download_expiry": -1, + "download_type": "standard", + "external_url": "", + "button_text": "", + "tax_status": "taxable", + "tax_class": "", + "manage_stock": false, + "stock_quantity": null, + "in_stock": true, + "backorders": "no", + "backorders_allowed": false, + "backordered": false, + "sold_individually": false, + "weight": "", + "dimensions": { + "length": "", + "width": "", + "height": "" + }, + "shipping_required": true, + "shipping_taxable": true, + "shipping_class": "", + "shipping_class_id": 0, + "reviews_allowed": true, + "average_rating": "0.00", + "rating_count": 0, + "related_ids": [], + "upsell_ids": [], + "cross_sell_ids": [], + "parent_id": 0, + "purchase_note": "", + "categories": [ + { + "id": 9, + "name": "Clothing", + "slug": "clothing" + }, + { + "id": 14, + "name": "T-shirts", + "slug": "t-shirts" + } + ], + "tags": [], + "images": [ + { + "id": 163, + "date_created": "2016-05-31T23:40:07", + "date_modified": "2016-05-31T23:40:07", + "src": "https://example.com/wp-content/uploads/2016/05/T_2_front.jpg", + "title": "", + "alt": "", + "position": 0 + }, + { + "id": 164, + "date_created": "2016-05-31T23:40:10", + "date_modified": "2016-05-31T23:40:10", + "src": "https://example.com/wp-content/uploads/2016/05/T_2_back.jpg", + "title": "", + "alt": "", + "position": 1 + } + ], + "attributes": [], + "default_attributes": [], + "variations": [], + "grouped_products": [], + "menu_order": 0, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/162" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products" + } + ] + } +} +``` + +#### Available parameters #### + +| Parameter | Type | Description | +|-----------|--------|---------------------------------------------------------------------------| +| `force` | string | Use `true` whether to permanently delete the product, Default is `false`. | + +## Batch update products ## + +This API helps you to batch create, update and delete multiple products. + +### HTTP request ### + +
+
+ POST +
/wp-json/wc/v1/products/batch
+
+
+ +```shell +curl -X POST https://example.com/wp-json/wc/v1/products/batch \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "create": [ + { + "name": "Woo Single #1", + "type": "simple", + "regular_price": "21.99", + "virtual": true, + "downloadable": true, + "downloads": [ + { + "name": "Woo Single", + "file": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg" + } + ], + "categories": [ + { + "id": 11 + }, + { + "id": 13 + } + ], + "images": [ + { + "src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg", + "position": 0 + } + ] + }, + { + "name": "New Premium Quality", + "type": "simple", + "regular_price": "21.99", + "description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.", + "short_description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.", + "categories": [ + { + "id": 9 + }, + { + "id": 14 + } + ], + "images": [ + { + "src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg", + "position": 0 + }, + { + "src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_back.jpg", + "position": 1 + } + ] + } + ], + "update": [ + { + "id": 165, + "variations": [ + { + "id": 170, + "regular_price": "29.99" + }, + { + "id": 172, + "regular_price": "29.99" + } + ] + } + ], + "delete": [ + 162 + ] +}' +``` + +```javascript +var data = { + create: [ + { + name: 'Woo Single #1', + type: 'simple', + regular_price: '21.99', + virtual: true, + downloadable: true, + downloads: [ + { + name: 'Woo Single', + file: 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg' + } + ], + categories: [ + { + id: 11 + }, + { + id: 13 + } + ], + images: [ + { + src: 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg', + position: 0 + } + ] + }, + { + name: 'New Premium Quality', + type: 'simple', + regular_price: '21.99', + description: 'Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.', + short_description: 'Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.', + categories: [ + { + id: 9 + }, + { + id: 14 + } + ], + images: [ + { + src: 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg', + position: 0 + }, + { + src: 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_back.jpg', + position: 1 + } + ] + } + ], + update: [ + { + id: 165, + variations: [ + { + id: 170, + regular_price: '29.99' + }, + { + id: 172, + regular_price: '29.99' + } + ] + } + ], + delete: [ + 162 + ] +}; + +WooCommerce.post('products/batch', data, function(err, data, res) { + console.log(res); +}); +``` + +```php + [ + [ + 'name' => 'Woo Single #1', + 'type' => 'simple', + 'regular_price' => '21.99', + 'virtual' => true, + 'downloadable' => true, + 'downloads' => [ + [ + 'name' => 'Woo Single', + 'file' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg' + ] + ], + 'categories' => [ + [ + 'id': 11 + ], + [ + 'id': 13 + ] + ], + 'images' => [ + [ + 'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg', + 'position' => 0 + ] + ] + ], + [ + 'name' => 'New Premium Quality', + 'type' => 'simple', + 'regular_price' => '21.99', + 'description' => 'Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.', + 'short_description' => 'Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.', + 'categories' => [ + [ + 'id': 9 + ], + [ + 'id': 14 + ] + ], + 'images' => [ + [ + 'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg', + 'position' => 0 + ], + [ + 'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_back.jpg', + 'position' => 1 + ] + ] + ] + ], + 'update' => [ + [ + 'id' => 165, + 'variations' => [ + [ + 'id' => 170, + 'regular_price' => '29.99' + ], + [ + 'id' => 172, + 'regular_price' => '29.99' + ] + ] + ] + ], + 'delete' => [ + 162 + ] +]; + +print_r($woocommerce->post('products/batch', $data)); +?> +``` + +```python +data = { + "create": [ + { + "name": "Woo Single #1", + "type": "simple", + "regular_price": "21.99", + "virtual": True, + "downloadable": True, + "downloads": [ + { + "name": "Woo Single", + "file": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg" + } + ], + "categories": [ + { + "id": 11 + }, + { + "id": 13 + } + ], + "images": [ + { + "src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg", + "position": 0 + } + ] + }, + { + "name": "New Premium Quality", + "type": "simple", + "regular_price": "21.99", + "description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.", + "short_description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.", + "categories": [ + { + "id": 9 + }, + { + "id": 14 + } + ], + "images": [ + { + "src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg", + "position": 0 + }, + { + "src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_back.jpg", + "position": 1 + } + ] + } + ], + "update": [ + { + "id": 165, + "variations": [ + { + "id": 170, + "regular_price": "29.99" + }, + { + "id": 172, + "regular_price": "29.99" + } + ] + } + ], + "delete": [ + 162 + ] +} + +print(wcapi.post("products/batch", data).json()) +``` + +```ruby +data = { + create: [ + { + name: "Woo Single #1", + type: "simple", + regular_price: "21.99", + virtual: true, + downloadable: true, + downloads: [ + { + name: "Woo Single", + file: "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg" + } + ], + categories: [ + { + id: 11 + }, + { + id: 13 + } + ], + images: [ + { + src: "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg", + position: 0 + } + ] + }, + { + name: "New Premium Quality", + type: "simple", + regular_price: "21.99", + description: "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.", + short_description: "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.", + categories: [ + { + id: 9 + }, + { + id: 14 + } + ], + images: [ + { + src: "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg", + position: 0 + }, + { + src: "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_back.jpg", + position: 1 + } + ] + } + ], + update: [ + { + id: 165, + variations: [ + { + id: 170, + regular_price: "29.99" + }, + { + id: 172, + regular_price: "29.99" + } + ] + } + ], + delete: [ + 162 + ] +} + +woocommerce.post("products/batch", data).parsed_response +``` + +> JSON response example: + +```json +{ + "create": [ + { + "id": 174, + "name": "Woo Single #1", + "slug": "woo-single-1-2", + "permalink": "https://example.com/product/woo-single-1-2/", + "date_created": "2016-06-01T00:21:30", + "date_modified": "2016-06-01T00:21:30", + "type": "simple", + "status": "publish", + "featured": false, + "catalog_visibility": "visible", + "description": "", + "short_description": "", + "sku": "", + "price": "21.99", + "regular_price": "21.99", + "sale_price": "", + "date_on_sale_from": "", + "date_on_sale_to": "", + "price_html": "R$21,99", + "on_sale": false, + "purchasable": true, + "total_sales": 0, + "virtual": true, + "downloadable": true, + "downloads": [ + { + "id": "7b5a304f737cfa35dc527c9e790399bf", + "name": "Woo Single", + "file": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg" + } + ], + "download_limit": -1, + "download_expiry": -1, + "download_type": "standard", + "external_url": "", + "button_text": "", + "tax_status": "taxable", + "tax_class": "", + "manage_stock": false, + "stock_quantity": null, + "in_stock": true, + "backorders": "no", + "backorders_allowed": false, + "backordered": false, + "sold_individually": false, + "weight": "", + "dimensions": { + "length": "", + "width": "", + "height": "" + }, + "shipping_required": false, + "shipping_taxable": true, + "shipping_class": "", + "shipping_class_id": 0, + "reviews_allowed": true, + "average_rating": "0.00", + "rating_count": 0, + "related_ids": [], + "upsell_ids": [], + "cross_sell_ids": [], + "parent_id": 0, + "purchase_note": "", + "categories": [ + { + "id": 11, + "name": "Music", + "slug": "music" + }, + { + "id": 13, + "name": "Singles", + "slug": "singles" + } + ], + "tags": [], + "images": [ + { + "id": 175, + "date_created": "2016-06-01T00:21:31", + "date_modified": "2016-06-01T00:21:31", + "src": "https://example.com/wp-content/uploads/2016/05/cd_4_angle.jpg", + "title": "", + "alt": "", + "position": 0 + } + ], + "attributes": [], + "default_attributes": [], + "variations": [], + "grouped_products": [], + "menu_order": 0, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/174" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products" + } + ] + } + }, + { + "id": 176, + "name": "New Premium Quality", + "slug": "new-premium-quality", + "permalink": "https://example.com/product/new-premium-quality/", + "date_created": "2016-06-01T00:21:33", + "date_modified": "2016-06-01T00:21:33", + "type": "simple", + "status": "publish", + "featured": false, + "catalog_visibility": "visible", + "description": "

Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.

\n", + "short_description": "

Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.

\n", + "sku": "", + "price": "21.99", + "regular_price": "21.99", + "sale_price": "", + "date_on_sale_from": "", + "date_on_sale_to": "", + "price_html": "R$21,99", + "on_sale": false, + "purchasable": true, + "total_sales": 0, + "virtual": false, + "downloadable": false, + "downloads": [], + "download_limit": -1, + "download_expiry": -1, + "download_type": "standard", + "external_url": "", + "button_text": "", + "tax_status": "taxable", + "tax_class": "", + "manage_stock": false, + "stock_quantity": null, + "in_stock": true, + "backorders": "no", + "backorders_allowed": false, + "backordered": false, + "sold_individually": false, + "weight": "", + "dimensions": { + "length": "", + "width": "", + "height": "" + }, + "shipping_required": true, + "shipping_taxable": true, + "shipping_class": "", + "shipping_class_id": 0, + "reviews_allowed": true, + "average_rating": "0.00", + "rating_count": 0, + "related_ids": [], + "upsell_ids": [], + "cross_sell_ids": [], + "parent_id": 0, + "purchase_note": "", + "categories": [ + { + "id": 9, + "name": "Clothing", + "slug": "clothing" + }, + { + "id": 14, + "name": "T-shirts", + "slug": "t-shirts" + } + ], + "tags": [], + "images": [ + { + "id": 177, + "date_created": "2016-06-01T00:21:33", + "date_modified": "2016-06-01T00:21:33", + "src": "https://example.com/wp-content/uploads/2016/05/T_2_front-1.jpg", + "title": "", + "alt": "", + "position": 0 + }, + { + "id": 178, + "date_created": "2016-06-01T00:21:34", + "date_modified": "2016-06-01T00:21:34", + "src": "https://example.com/wp-content/uploads/2016/05/T_2_back-1.jpg", + "title": "", + "alt": "", + "position": 1 + } + ], + "attributes": [], + "default_attributes": [], + "variations": [], + "grouped_products": [], + "menu_order": 0, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/176" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products" + } + ] + } + } + ], + "update": [ + { + "id": 165, + "name": "Ship Your Idea", + "slug": "ship-your-idea-4", + "permalink": "https://example.com/product/ship-your-idea-4/", + "date_created": "2016-05-31T23:50:56", + "date_modified": "2016-06-02T23:11:41", + "type": "variable", + "status": "publish", + "featured": false, + "catalog_visibility": "visible", + "description": "

Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.

\n", + "short_description": "

Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.

\n", + "sku": "", + "price": "29.99", + "regular_price": "", + "sale_price": "", + "date_on_sale_from": "", + "date_on_sale_to": "", + "price_html": "R$29,99", + "on_sale": false, + "purchasable": true, + "total_sales": 0, + "virtual": false, + "downloadable": false, + "downloads": [], + "download_limit": -1, + "download_expiry": -1, + "download_type": "standard", + "external_url": "", + "button_text": "", + "tax_status": "taxable", + "tax_class": "", + "manage_stock": false, + "stock_quantity": null, + "in_stock": true, + "backorders": "no", + "backorders_allowed": false, + "backordered": false, + "sold_individually": false, + "weight": "", + "dimensions": { + "length": "", + "width": "", + "height": "" + }, + "shipping_required": true, + "shipping_taxable": true, + "shipping_class": "", + "shipping_class_id": 0, + "reviews_allowed": true, + "average_rating": "0.00", + "rating_count": 0, + "related_ids": [ + 34, + 37, + 187, + 205, + 31 + ], + "upsell_ids": [], + "cross_sell_ids": [], + "parent_id": 0, + "purchase_note": "", + "categories": [ + { + "id": 9, + "name": "Clothing", + "slug": "clothing" + }, + { + "id": 14, + "name": "T-shirts", + "slug": "t-shirts" + } + ], + "tags": [], + "images": [ + { + "id": 166, + "date_created": "2016-05-31T23:50:57", + "date_modified": "2016-05-31T23:50:57", + "src": "https://example.com/wp-content/uploads/2016/05/T_4_front.jpg", + "title": "", + "alt": "", + "position": 0 + }, + { + "id": 167, + "date_created": "2016-05-31T23:50:57", + "date_modified": "2016-05-31T23:50:57", + "src": "https://example.com/wp-content/uploads/2016/05/T_4_back.jpg", + "title": "", + "alt": "", + "position": 1 + }, + { + "id": 168, + "date_created": "2016-05-31T23:50:58", + "date_modified": "2016-05-31T23:50:58", + "src": "https://example.com/wp-content/uploads/2016/05/T_3_front.jpg", + "title": "", + "alt": "", + "position": 2 + }, + { + "id": 169, + "date_created": "2016-05-31T23:50:59", + "date_modified": "2016-05-31T23:50:59", + "src": "https://example.com/wp-content/uploads/2016/05/T_3_back.jpg", + "title": "", + "alt": "", + "position": 3 + } + ], + "attributes": [ + { + "id": 6, + "name": "Color", + "position": 0, + "visible": false, + "variation": true, + "options": [ + "Black", + "Green" + ] + }, + { + "id": 0, + "name": "Size", + "position": 1, + "visible": true, + "variation": true, + "options": [ + "S", + "M" + ] + } + ], + "default_attributes": [ + { + "id": 6, + "name": "Color", + "option": "black" + }, + { + "id": 0, + "name": "size", + "option": "S" + } + ], + "variations": [ + { + "id": 170, + "date_created": "2016-05-31T23:50:56", + "date_modified": "2016-06-02T23:11:41", + "permalink": "https://example.com/product/ship-your-idea-4/?attribute_pa_color=black&attribute_size=S", + "sku": "", + "price": "29.99", + "regular_price": "29.99", + "sale_price": "", + "date_on_sale_from": "", + "date_on_sale_to": "", + "on_sale": false, + "purchasable": true, + "virtual": false, + "downloadable": false, + "downloads": [], + "download_limit": -1, + "download_expiry": -1, + "tax_status": "taxable", + "tax_class": "", + "manage_stock": false, + "stock_quantity": null, + "in_stock": true, + "backorders": "no", + "backorders_allowed": false, + "backordered": false, + "weight": "", + "dimensions": { + "length": "", + "width": "", + "height": "" + }, + "shipping_class": "", + "shipping_class_id": 0, + "image": [ + { + "id": 171, + "date_created": "2016-05-31T23:51:01", + "date_modified": "2016-05-31T23:51:01", + "src": "https://example.com/wp-content/uploads/2016/05/T_4_front-1.jpg", + "title": "", + "alt": "", + "position": 0 + } + ], + "attributes": [ + { + "id": 6, + "name": "Color", + "option": "black" + }, + { + "id": 0, + "name": "size", + "option": "S" + } + ] + }, + { + "id": 172, + "date_created": "2016-05-31T23:50:56", + "date_modified": "2016-06-02T23:11:41", + "permalink": "https://example.com/product/ship-your-idea-4/?attribute_pa_color=green&attribute_size=M", + "sku": "", + "price": "29.99", + "regular_price": "29.99", + "sale_price": "", + "date_on_sale_from": "", + "date_on_sale_to": "", + "on_sale": false, + "purchasable": true, + "virtual": false, + "downloadable": false, + "downloads": [], + "download_limit": -1, + "download_expiry": -1, + "tax_status": "taxable", + "tax_class": "", + "manage_stock": false, + "stock_quantity": null, + "in_stock": true, + "backorders": "no", + "backorders_allowed": false, + "backordered": false, + "weight": "", + "dimensions": { + "length": "", + "width": "", + "height": "" + }, + "shipping_class": "", + "shipping_class_id": 0, + "image": [ + { + "id": 173, + "date_created": "2016-05-31T23:51:03", + "date_modified": "2016-05-31T23:51:03", + "src": "https://example.com/wp-content/uploads/2016/05/T_3_front-1.jpg", + "title": "", + "alt": "", + "position": 0 + } + ], + "attributes": [ + { + "id": 6, + "name": "Color", + "option": "green" + }, + { + "id": 0, + "name": "size", + "option": "M" + } + ] + } + ], + "grouped_products": [], + "menu_order": 0, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/165" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products" + } + ] + } + } + ], + "delete": [ + { + "id": 162, + "name": "Premium Quality", + "slug": "premium-quality-3", + "permalink": "https://example.com/product/premium-quality-3/", + "date_created": "2016-05-31T23:40:07", + "date_modified": "2016-06-01T00:13:45", + "type": "simple", + "status": "publish", + "featured": false, + "catalog_visibility": "visible", + "description": "

Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.

\n", + "short_description": "

Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.

\n", + "sku": "", + "price": "24.54", + "regular_price": "24.54", + "sale_price": "", + "date_on_sale_from": "", + "date_on_sale_to": "", + "price_html": "R$24,54", + "on_sale": false, + "purchasable": true, + "total_sales": 0, + "virtual": false, + "downloadable": false, + "downloads": [], + "download_limit": -1, + "download_expiry": -1, + "download_type": "standard", + "external_url": "", + "button_text": "", + "tax_status": "taxable", + "tax_class": "", + "manage_stock": false, + "stock_quantity": null, + "in_stock": true, + "backorders": "no", + "backorders_allowed": false, + "backordered": false, + "sold_individually": false, + "weight": "", + "dimensions": { + "length": "", + "width": "", + "height": "" + }, + "shipping_required": true, + "shipping_taxable": true, + "shipping_class": "", + "shipping_class_id": 0, + "reviews_allowed": true, + "average_rating": "0.00", + "rating_count": 0, + "related_ids": [], + "upsell_ids": [], + "cross_sell_ids": [], + "parent_id": 0, + "purchase_note": "", + "categories": [ + { + "id": 9, + "name": "Clothing", + "slug": "clothing" + }, + { + "id": 14, + "name": "T-shirts", + "slug": "t-shirts" + } + ], + "tags": [], + "images": [ + { + "id": 163, + "date_created": "2016-05-31T23:40:07", + "date_modified": "2016-05-31T23:40:07", + "src": "https://example.com/wp-content/uploads/2016/05/T_2_front.jpg", + "title": "", + "alt": "", + "position": 0 + }, + { + "id": 164, + "date_created": "2016-05-31T23:40:10", + "date_modified": "2016-05-31T23:40:10", + "src": "https://example.com/wp-content/uploads/2016/05/T_2_back.jpg", + "title": "", + "alt": "", + "position": 1 + } + ], + "attributes": [], + "default_attributes": [], + "variations": [], + "grouped_products": [], + "menu_order": 0, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/162" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products" + } + ] + } + } + ] +} +``` + +## Retrieve product reviews ## + +This API lets you retrieve and view a specific product review by ID. + +### HTTP request ### + +
+
+ GET +
/wp-json/wc/v1/products/<product_id>/reviews/<id>
+
+
+ +```shell +curl https://example.com/wp-json/wc/v1/products/162/reviews/9 \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('products/162/reviews/9', function(err, data, res) { + console.log(res); +}); +``` + +```php +get('products/162')); ?> +``` + +```python +print(wcapi.get("products/162/reviews/9").json()) +``` + +```ruby +woocommerce.get("products/162/reviews/9").parsed_response +``` + +> JSON response example: + +```json +{ + "id": 9, + "date_created": "2015-05-07T13:01:25", + "review": "This will go great with my Hoodie that I ordered a few weeks ago.", + "rating": 5, + "name": "Stuart", + "email": "stuart@example.com", + "verified": false, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/162/reviews/9" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/162/reviews" + } + ], + "up": [ + { + "href": "https://example.com/wp-json/wc/v1/products/162" + } + ] + } +} +``` + +### Product review properties ### + +| Attribute | Type | Description | +|----------------|---------|----------------------------------------------------------------------------------------------------| +| `id` | integer | Unique identifier for the resource. read-only | +| `date_created` | string | The date the review was created, in the site's timezone. read-only | +| `rating` | integer | Review rating (0 to 5). read-only | +| `name` | string | Reviewer name. read-only | +| `email` | string | Reviewer email. read-only | +| `verified` | boolean | Shows if the reviewer bought the product or not. read-only | + +## List all product reviews ## + +This API lets you retrieve all reviews of a product. + +
+
+ GET +
/wp-json/wc/v1/products/<product_id>/reviews
+
+
+ +```shell +curl https://example.com/wp-json/wc/v1/products/162/reviews \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('products/162/reviews', function(err, data, res) { + console.log(res); +}); +``` + +```php +get('products/162/reviews')); ?> +``` + +```python +print(wcapi.get("products/162/reviews").json()) +``` + +```ruby +woocommerce.get("products/162/reviews").parsed_response +``` + +> JSON response example: + +```json +[ + { + "id": 9, + "date_created": "2015-05-07T13:01:25", + "review": "This will go great with my Hoodie that I ordered a few weeks ago.", + "rating": 5, + "name": "Stuart", + "email": "stuart@example.com", + "verified": false, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/162/reviews/9" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/162/reviews" + } + ], + "up": [ + { + "href": "https://example.com/wp-json/wc/v1/products/162" + } + ] + } + }, + { + "id": 10, + "date_created": "2015-05-07T15:49:53", + "review": "Love this shirt! The ninja near and dear to my heart. <3", + "rating": 5, + "name": "Maria", + "email": "maria@example.com", + "verified": false, + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/products/162/reviews/10" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/products/162/reviews" + } + ], + "up": [ + { + "href": "https://example.com/wp-json/wc/v1/products/162" + } + ] + } + } +] +``` diff --git a/source/includes/wp-api-v1/_reports.md b/source/includes/wp-api-v1/_reports.md new file mode 100644 index 00000000..58834652 --- /dev/null +++ b/source/includes/wp-api-v1/_reports.md @@ -0,0 +1,302 @@ +# Reports # + +The reports API allows you to view all types of reports available. + +## List all reports ## + +This API lets you retrieve and view a simple list of available reports. + +### HTTP request ### + +
+
+ GET +
/wp-json/wc/v1/reports
+
+
+ +```shell +curl https://example.com/wp-json/wc/v1/reports \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('reports', function(err, data, res) { + console.log(res); +}); +``` + +```php +get('reports')); ?> +``` + +```python +print(wcapi.get("reports").json()) +``` + +```ruby +woocommerce.get("reports").parsed_response +``` + +> JSON response example: + +```json +[ + { + "slug": "sales", + "description": "List of sales reports.", + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/reports/sales" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/reports" + } + ] + } + }, + { + "slug": "top_sellers", + "description": "List of top sellers products.", + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/reports/top_sellers" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/reports" + } + ] + } + } +] +``` + +## Retrieve sales report ## + +This API lets you retrieve and view a sales report. + +### HTTP request ### + +
+
+ GET +
/wp-json/wc/v1/reports/sales
+
+
+ +```shell +curl https://example.com/wp-json/wc/v1/reports/sales?date_min=2016-05-03&date_max=2016-05-04 \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('reports/sales?date_min=2016-05-03&date_max=2016-05-04', function(err, data, res) { + console.log(res); +}); +``` + +```php + '2016-05-03', + 'date_max' => '2016-05-04' +]; + +print_r($woocommerce->get('reports/sales', $query)); +?> +``` + +```python +print(wcapi.get("reports/sales?date_min=2016-05-03&date_max=2016-05-04").json()) +``` + +```ruby +query = { + date_min: "2016-05-03", + date_max: "2016-05-04" +} + +woocommerce.get("reports/sales", query).parsed_response +``` + +> JSON response example: + +```json +[ + { + "total_sales": "14.00", + "net_sales": "4.00", + "average_sales": "2.00", + "total_orders": 3, + "total_items": 6, + "total_tax": "0.00", + "total_shipping": "10.00", + "total_refunds": 0, + "total_discount": "0.00", + "totals_grouped_by": "day", + "totals": { + "2016-05-03": { + "sales": "14.00", + "orders": 3, + "items": 6, + "tax": "0.00", + "shipping": "10.00", + "discount": "0.00", + "customers": 0 + }, + "2016-05-04": { + "sales": "0.00", + "orders": 0, + "items": 0, + "tax": "0.00", + "shipping": "0.00", + "discount": "0.00", + "customers": 0 + } + }, + "total_customers": 0, + "_links": { + "about": [ + { + "href": "https://example.com/wp-json/wc/v1/reports" + } + ] + } + } +] +``` + +#### Sales report properties #### + +| Attribute | Type | Description | +|---------------------|---------|-----------------------------------------------------------------------| +| `total_sales` | string | Gross sales in the period. read-only | +| `net_sales` | string | Net sales in the period. read-only | +| `average_sales` | string | Average net daily sales. read-only | +| `total_orders` | integer | Total of orders placed. read-only | +| `total_items` | integer | Total of items purchased. read-only | +| `total_tax` | string | Total charged for taxes. read-only | +| `total_shipping` | string | Total charged for shipping. read-only | +| `total_refunds` | integer | Total of refunded orders. read-only | +| `total_discount` | integer | Total of coupons used. read-only | +| `totals_grouped_by` | string | Group type. read-only | +| `totals` | array | Totals. read-only | + +#### Available parameters #### + +| Parameter | Type | Description | +|------------|--------|-------------------------------------------------------------------------------------------------------------------| +| `context` | string | Scope under which the request is made; determines fields present in response. Default is `view`. Options: `view`. | +| `period` | string | Report period. Default is `week`. Options: `week`, `month`, `last_month` and `year` | +| `date_min` | string | Return sales for a specific start date, the date need to be in the YYYY-MM-AA format. | +| `date_max` | string | Return sales for a specific end date, the date need to be in the YYYY-MM-AA format. | + +## Retrieve top sellers report ## + +This API lets you retrieve and view a list of top sellers report. + +### HTTP request ### + +
+
+ GET +
/wp-json/wc/v1/reports/sales/top_sellers
+
+
+ +```shell +curl https://example.com/wp-json/wc/v1/reports/sales/top_sellers?period=last_month \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('reports/sales/top_sellers?period=last_month', function(err, data, res) { + console.log(res); +}); +``` + +```php + 'last_month' +]; + +print_r($woocommerce->get('reports/sales/top_sellers', $query)); +?> +``` + +```python +print(wcapi.get("reports/sales/top_sellers?period=last_month").json()) +``` + +```ruby +query = { + period: "last_month" +} + +woocommerce.get("reports/sales/top_sellers", query).parsed_response +``` + +> JSON response example: + +```json +[ + { + "title": "Happy Ninja", + "product_id": 37, + "quantity": 1, + "_links": { + "about": [ + { + "href": "https://example.com/wp-json/wc/v1/reports" + } + ], + "product": [ + { + "href": "https://example.com/wp-json/wc/v1/products/37" + } + ] + } + }, + { + "title": "Woo Album #4", + "product_id": 96, + "quantity": 1, + "_links": { + "about": [ + { + "href": "https://example.com/wp-json/wc/v1/reports" + } + ], + "product": [ + { + "href": "https://example.com/wp-json/wc/v1/products/96" + } + ] + } + } +] +``` + +#### Top sellers report properties #### + +| Attribute | Type | Description | +|---------------------|---------|-----------------------------------------------------------------------| +| `title` | string | Product title. read-only | +| `product_id` | integer | Product ID. read-only | +| `quantity` | integer | Total number of purchases. read-only | + +#### Available parameters #### + +| Parameter | Type | Description | +|------------|--------|-------------------------------------------------------------------------------------------------------------------| +| `context` | string | Scope under which the request is made; determines fields present in response. Default is `view`. Options: `view`. | +| `period` | string | Report period. Default is `week`. Options: `week`, `month`, `last_month` and `year` | +| `date_min` | string | Return sales for a specific start date, the date need to be in the YYYY-MM-AA format. | +| `date_max` | string | Return sales for a specific end date, the date need to be in the YYYY-MM-AA format. | diff --git a/source/includes/wp-api-v1/_tax-classes.md b/source/includes/wp-api-v1/_tax-classes.md new file mode 100644 index 00000000..51733859 --- /dev/null +++ b/source/includes/wp-api-v1/_tax-classes.md @@ -0,0 +1,222 @@ +# Tax classes # + +The tax classes API allows you to create, view, and delete individual tax classes. + +## Tax class properties ## + +| Attribute | Type | Description | +|-----------|--------|-------------------------------------------------------------------------------| +| `slug` | string | Unique identifier for the resource. read-only | +| `name` | string | Tax class name. required | + +## Create a tax class ## + +This API helps you to create a new tax class. + +### HTTP request ### + +
+
+ POST +
/wp-json/wc/v1/taxes/classes
+
+
+ +```shell +curl -X POST https://example.com/wp-json/wc/v1/taxes/classes \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "name": "Zero Rate" +}' +``` + +```javascript +var data = { + name: 'Zero Rate' +}; + +WooCommerce.post('taxes/classes', data, function(err, data, res) { + console.log(res); +}); +``` + +```php + 'Zero Rate' +]; + +print_r($woocommerce->post('taxes/classes', $data)); +?> +``` + +```python +data = { + "name": "Zero Rate" +} + +print(wcapi.post("taxes/classes", data).json()) +``` + +```ruby +data = { + name: "Zero Rate" +} + +woocommerce.post("taxes/classes", data).parsed_response +``` + +> JSON response example: + +```json +{ + "slug": "zero-rate", + "name": "Zero Rate", + "_links": { + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/taxes/classes" + } + ] + } +} +``` + +## List all tax classes ## + +This API helps you to view all tax classes. + +### HTTP request ### + +
+
+ GET +
/wp-json/wc/v1/taxes/classes
+
+
+ +```shell +curl https://example.com/wp-json/wc/v1/taxes/classes \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('taxes/classes', function(err, data, res) { + console.log(res); +}); +``` + +```php +get('taxes/classes')); ?> +``` + +```python +print(wcapi.get("taxes/classes").json()) +``` + +```ruby +woocommerce.get("taxes/classes").parsed_response +``` + +> JSON response example: + +```json +[ + { + "slug": "standard", + "name": "Standard Rate", + "_links": { + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/taxes/classes" + } + ] + } + }, + { + "slug": "reduced-rate", + "name": "Reduced Rate", + "_links": { + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/taxes/classes" + } + ] + } + }, + { + "slug": "zero-rate", + "name": "Zero Rate", + "_links": { + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/taxes/classes" + } + ] + } + } +] +``` + +## Delete a tax class ## + +This API helps you delete a tax class. + + + +### HTTP request ### + +
+
+ DELETE +
/wp-json/wc/v1/taxes/classes/<slug>
+
+
+ +```shell +curl -X DELETE https://example.com/wp-json/wc/v1/taxes/classes/zero-rate?force=true \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.delete('taxes/classes/zero-rate?force=true', function(err, data, res) { + console.log(res); +}); +``` + +```php +delete('taxes/classes/zero-rate', ['force' => true])); ?> +``` + +```python +print(wcapi.delete("taxes/classes/zero-rate?force=true").json()) +``` + +```ruby +woocommerce.delete("taxes/classes/zero-rate", force: true).parsed_response +``` + +> JSON response example: + +```json +{ + "slug": "zero-rate", + "name": "Zero Rate", + "_links": { + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/taxes/classes" + } + ] + } +} +``` + +#### Available parameters #### + +| Parameter | Type | Description | +|-----------|--------|---------------------------------------------------------------| +| `force` | string | Required to be `true`, since this resource does not support trashing. | diff --git a/source/includes/wp-api-v1/_taxes.md b/source/includes/wp-api-v1/_taxes.md new file mode 100644 index 00000000..4a969ecb --- /dev/null +++ b/source/includes/wp-api-v1/_taxes.md @@ -0,0 +1,3916 @@ +# Tax rates # + +The taxes API allows you to create, view, update, and delete individual tax rates, or a batch of tax rates. + +## Tax rate properties ## + +| Attribute | Type | Description | +|------------|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `id` | integer | Unique identifier for the resource. read-only | +| `country` | string | Country ISO 3166 code. See [ISO 3166 Codes (Countries)](http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html) for more details | +| `state` | string | State code. | +| `postcode` | string | Postcode/ZIP. | +| `city` | string | City name. | +| `rate` | float | Tax rate. | +| `name` | string | Tax rate name. | +| `priority` | integer | Tax priority. Only 1 matching rate per priority will be used. To define multiple tax rates for a single area you need to specify a different priority per rate. Default is `1`. | +| `compound` | boolean | Whether or not this is a compound rate. Compound tax rates are applied on top of other tax rates. Default is `false`. | +| `shipping` | boolean | Whether or not this tax rate also gets applied to shipping. Default is `true`. | +| `order` | integer | Indicates the order that will appear in queries. | +| `class` | string | Tax class. Default is `standard`. | + +## Create a tax rate ## + +This API helps you to create a new tax rate. + +### HTTP request ### + +
+
+ POST +
/wp-json/wc/v1/taxes
+
+
+ +```shell +curl -X POST https://example.com/wp-json/wc/v1/taxes \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "country": "US", + "state": "AL", + "rate": "4", + "name": "State Tax", + "shipping": false +}' +``` + +```javascript +var data = { + country: 'US', + state: 'AL', + rate: '4', + name: 'State Tax', + shipping: false +}; + +WooCommerce.post('taxes', data, function(err, data, res) { + console.log(res); +}); +``` + +```php + 'US', + 'state' => 'AL', + 'rate' => '4', + 'name' => 'State Tax', + 'shipping' => false +]; + +print_r($woocommerce->post('taxes', $data)); +?> +``` + +```python +data = { + "country": "US", + "state": "AL", + "rate": "4", + "name": "State Tax", + "shipping": False +} + +print(wcapi.post("taxes", data).json()) +``` + +```ruby +data = { + country: "US", + state: "AL", + rate: "4", + name: "State Tax", + shipping: false +} + +woocommerce.post("taxes", data).parsed_response +``` + +> JSON response example: + +```json +{ + "id": 72, + "country": "US", + "state": "AL", + "postcode": "", + "city": "", + "rate": "4.0000", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": false, + "order": 1, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/taxes/72" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/taxes" + } + ] + } +} +``` + +## Retrieve a tax rate ## + +This API lets you retrieve and view a specific tax rate by ID. + +
+
+ GET +
/wp-json/wc/v1/taxes/<id>
+
+
+ +```shell +curl https://example.com/wp-json/wc/v1/taxes/72 \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('taxes/72', function(err, data, res) { + console.log(res); +}); +``` + +```php +get('taxes/72')); ?> +``` + +```python +print(wcapi.get("taxes/72").json()) +``` + +```ruby +woocommerce.get("taxes/72").parsed_response +``` + +> JSON response example: + +```json +{ + "id": 72, + "country": "US", + "state": "AL", + "postcode": "", + "city": "", + "rate": "4.0000", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": false, + "order": 1, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/taxes/72" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/taxes" + } + ] + } +} +``` + +## List all tax rates ## + +This API helps you to view all the tax rates. + +### HTTP request ### + +
+
+ GET +
/wp-json/wc/v1/taxes
+
+
+ +```shell +curl https://example.com/wp-json/wc/v1/taxes \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('taxes', function(err, data, res) { + console.log(res); +}); +``` + +```php +get('taxes')); ?> +``` + +```python +print(wcapi.get("taxes").json()) +``` + +```ruby +woocommerce.get("taxes").parsed_response +``` + +> JSON response example: + +```json +[ + { + "id": 72, + "country": "US", + "state": "AL", + "postcode": "", + "city": "", + "rate": "4.0000", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": false, + "order": 1, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/taxes/72" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 73, + "country": "US", + "state": "AZ", + "postcode": "", + "city": "", + "rate": "5.6000", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": false, + "order": 2, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/taxes/73" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 74, + "country": "US", + "state": "AR", + "postcode": "", + "city": "", + "rate": "6.5000", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": true, + "order": 3, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/taxes/74" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 75, + "country": "US", + "state": "CA", + "postcode": "", + "city": "", + "rate": "7.5000", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": false, + "order": 4, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/taxes/75" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 76, + "country": "US", + "state": "CO", + "postcode": "", + "city": "", + "rate": "2.9000", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": false, + "order": 5, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/taxes/76" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 77, + "country": "US", + "state": "CT", + "postcode": "", + "city": "", + "rate": "6.3500", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": true, + "order": 6, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/taxes/77" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 78, + "country": "US", + "state": "DC", + "postcode": "", + "city": "", + "rate": "5.7500", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": true, + "order": 7, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/taxes/78" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 79, + "country": "US", + "state": "FL", + "postcode": "", + "city": "", + "rate": "6.0000", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": true, + "order": 8, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/taxes/79" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 80, + "country": "US", + "state": "GA", + "postcode": "", + "city": "", + "rate": "4.0000", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": true, + "order": 9, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/taxes/80" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 81, + "country": "US", + "state": "GU", + "postcode": "", + "city": "", + "rate": "4.0000", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": false, + "order": 10, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/taxes/81" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/taxes" + } + ] + } + } +] +``` + +#### Available parameters #### + +| Parameter | Type | Description | +|------------|---------|--------------------------------------------------------------------------------------------------------------------------------------------| +| `context` | string | Scope under which the request is made; determines fields present in response. Options: `view` and `edit`. | +| `page` | integer | Current page of the collection. | +| `per_page` | integer | Maximum number of items to be returned in result set. | +| `search` | string | Limit results to those matching a string. | +| `exclude` | string | Ensure result set excludes specific ids. | +| `include` | string | Limit result set to specific ids. | +| `offset` | integer | Offset the result set by a specific number of items. | +| `order` | string | Order sort attribute ascending or descending. Default is `asc`. Options: `asc` and `desc`. | +| `orderby` | string | Sort collection by object attribute. Default is `name`. Options: `id`, `include`, `name`, `slug`, `term_group`, `description` and `count`. | +| `class` | string | Sort by tax class. | + +## Update a tax rate ## + +This API lets you make changes to a tax rate. + +### HTTP request ### + +
+
+ PUT +
/wp-json/wc/v1/taxes/<id>
+
+
+ +```shell +curl -X PUT https://example.com/wp-json/wc/v1/taxes/72 \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "name": "US Tax" +}' +``` + +```javascript +var data = { + name: 'US Tax' +}; + +WooCommerce.put('taxes/72', data, function(err, data, res) { + console.log(res); +}); +``` + +```php + 'US Tax' +]; + +print_r($woocommerce->put('taxes/72', $data)); +?> +``` + +```python +data = { + "name": "US Tax" +} + +print(wcapi.put("taxes/72", data).json()) +``` + +```ruby +data = { + name: "US Tax" +} + +woocommerce.put("taxes/72", data).parsed_response +``` + +> JSON response example: + +```json +{ + "id": 72, + "country": "US", + "state": "AL", + "postcode": "", + "city": "", + "rate": "4.0000", + "name": "US Tax", + "priority": 0, + "compound": false, + "shipping": false, + "order": 1, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/taxes/72" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/taxes" + } + ] + } +} +``` + +## Delete a tax rate ## + +This API helps you delete a tax rate. + +### HTTP request ### + +
+
+ DELETE +
/wp-json/wc/v1/taxes/<id>
+
+
+ +```shell +curl -X DELETE https://example.com/wp-json/wc/v1/taxes/72?force=true \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.delete('taxes/72?force=true', function(err, data, res) { + console.log(res); +}); +``` + +```php +delete('taxes/72', ['force' => true])); ?> +``` + +```python +print(wcapi.delete("taxes/72?force=true").json()) +``` + +```ruby +woocommerce.delete("taxes/72", force: true).parsed_response +``` + +> JSON response example: + +```json +{ + "id": 72, + "country": "US", + "state": "AL", + "postcode": "", + "city": "", + "rate": "4.0000", + "name": "US Tax", + "priority": 0, + "compound": false, + "shipping": false, + "order": 1, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/taxes/72" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/taxes" + } + ] + } +} +``` + +#### Available parameters #### + +| Parameter | Type | Description | +|-----------|--------|---------------------------------------------------------------| +| `force` | string | Required to be `true`, as resource does not support trashing. | + +## Batch update tax rates ## + +This API helps you to batch create, update and delete multiple tax rates. + +### HTTP request ### + +
+
+ POST +
/wp-json/wc/v1/taxes/batch
+
+
+ +> Example batch creating all US taxes: + +```shell +curl -X POST https://example.com/wp-json/wc/v1/taxes/batch \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "create": [ + { + "country": "US", + "state": "AL", + "rate": "4.0000", + "name": "State Tax", + "shipping": false, + "order": 1 + }, + { + "country": "US", + "state": "AZ", + "rate": "5.6000", + "name": "State Tax", + "shipping": false, + "order": 2 + }, + { + "country": "US", + "state": "AR", + "rate": "6.5000", + "name": "State Tax", + "shipping": true, + "order": 3 + }, + { + "country": "US", + "state": "CA", + "rate": "7.5000", + "name": "State Tax", + "shipping": false, + "order": 4 + }, + { + "country": "US", + "state": "CO", + "rate": "2.9000", + "name": "State Tax", + "shipping": false, + "order": 5 + }, + { + "country": "US", + "state": "CT", + "rate": "6.3500", + "name": "State Tax", + "shipping": true, + "order": 6 + }, + { + "country": "US", + "state": "DC", + "rate": "5.7500", + "name": "State Tax", + "shipping": true, + "order": 7 + }, + { + "country": "US", + "state": "FL", + "rate": "6.0000", + "name": "State Tax", + "shipping": true, + "order": 8 + }, + { + "country": "US", + "state": "GA", + "rate": "4.0000", + "name": "State Tax", + "shipping": true, + "order": 9 + }, + { + "country": "US", + "state": "GU", + "rate": "4.0000", + "name": "State Tax", + "shipping": false, + "order": 10 + }, + { + "country": "US", + "state": "HI", + "rate": "4.0000", + "name": "State Tax", + "shipping": true, + "order": 11 + }, + { + "country": "US", + "state": "ID", + "rate": "6.0000", + "name": "State Tax", + "shipping": false, + "order": 12 + }, + { + "country": "US", + "state": "IL", + "rate": "6.2500", + "name": "State Tax", + "shipping": false, + "order": 13 + }, + { + "country": "US", + "state": "IN", + "rate": "7.0000", + "name": "State Tax", + "shipping": false, + "order": 14 + }, + { + "country": "US", + "state": "IA", + "rate": "6.0000", + "name": "State Tax", + "shipping": false, + "order": 15 + }, + { + "country": "US", + "state": "KS", + "rate": "6.1500", + "name": "State Tax", + "shipping": true, + "order": 16 + }, + { + "country": "US", + "state": "KY", + "rate": "6.0000", + "name": "State Tax", + "shipping": true, + "order": 17 + }, + { + "country": "US", + "state": "LA", + "rate": "4.0000", + "name": "State Tax", + "shipping": false, + "order": 18 + }, + { + "country": "US", + "state": "ME", + "rate": "5.5000", + "name": "State Tax", + "shipping": false, + "order": 19 + }, + { + "country": "US", + "state": "MD", + "rate": "6.0000", + "name": "State Tax", + "shipping": false, + "order": 20 + }, + { + "country": "US", + "state": "MA", + "rate": "6.2500", + "name": "State Tax", + "shipping": false, + "order": 21 + }, + { + "country": "US", + "state": "MI", + "rate": "6.0000", + "name": "State Tax", + "shipping": true, + "order": 22 + }, + { + "country": "US", + "state": "MN", + "rate": "6.8750", + "name": "State Tax", + "shipping": true, + "order": 23 + }, + { + "country": "US", + "state": "MS", + "rate": "7.0000", + "name": "State Tax", + "shipping": true, + "order": 24 + }, + { + "country": "US", + "state": "MO", + "rate": "4.2250", + "name": "State Tax", + "shipping": false, + "order": 25 + }, + { + "country": "US", + "state": "NE", + "rate": "5.5000", + "name": "State Tax", + "shipping": true, + "order": 26 + }, + { + "country": "US", + "state": "NV", + "rate": "6.8500", + "name": "State Tax", + "shipping": false, + "order": 27 + }, + { + "country": "US", + "state": "NJ", + "rate": "7.0000", + "name": "State Tax", + "shipping": true, + "order": 28 + }, + { + "country": "US", + "state": "NM", + "rate": "5.1250", + "name": "State Tax", + "shipping": true, + "order": 29 + }, + { + "country": "US", + "state": "NY", + "rate": "4.0000", + "name": "State Tax", + "shipping": true, + "order": 30 + }, + { + "country": "US", + "state": "NC", + "rate": "4.7500", + "name": "State Tax", + "shipping": true, + "order": 31 + }, + { + "country": "US", + "state": "ND", + "rate": "5.0000", + "name": "State Tax", + "shipping": true, + "order": 32 + }, + { + "country": "US", + "state": "OH", + "rate": "5.7500", + "name": "State Tax", + "shipping": true, + "order": 33 + }, + { + "country": "US", + "state": "OK", + "rate": "4.5000", + "name": "State Tax", + "shipping": false, + "order": 34 + }, + { + "country": "US", + "state": "PA", + "rate": "6.0000", + "name": "State Tax", + "shipping": true, + "order": 35 + }, + { + "country": "US", + "state": "PR", + "rate": "6.0000", + "name": "State Tax", + "shipping": false, + "order": 36 + }, + { + "country": "US", + "state": "RI", + "rate": "7.0000", + "name": "State Tax", + "shipping": false, + "order": 37 + }, + { + "country": "US", + "state": "SC", + "rate": "6.0000", + "name": "State Tax", + "shipping": true, + "order": 38 + }, + { + "country": "US", + "state": "SD", + "rate": "4.0000", + "name": "State Tax", + "shipping": true, + "order": 39 + }, + { + "country": "US", + "state": "TN", + "rate": "7.0000", + "name": "State Tax", + "shipping": true, + "order": 40 + }, + { + "country": "US", + "state": "TX", + "rate": "6.2500", + "name": "State Tax", + "shipping": true, + "order": 41 + }, + { + "country": "US", + "state": "UT", + "rate": "5.9500", + "name": "State Tax", + "shipping": false, + "order": 42 + }, + { + "country": "US", + "state": "VT", + "rate": "6.0000", + "name": "State Tax", + "shipping": true, + "order": 43 + }, + { + "country": "US", + "state": "VA", + "rate": "5.3000", + "name": "State Tax", + "shipping": false, + "order": 44 + }, + { + "country": "US", + "state": "WA", + "rate": "6.5000", + "name": "State Tax", + "shipping": true, + "order": 45 + }, + { + "country": "US", + "state": "WV", + "rate": "6.0000", + "name": "State Tax", + "shipping": true, + "order": 46 + }, + { + "country": "US", + "state": "WI", + "rate": "5.0000", + "name": "State Tax", + "shipping": true, + "order": 47 + }, + { + "country": "US", + "state": "WY", + "rate": "4.0000", + "name": "State Tax", + "shipping": true, + "order": 48 + } + ] +}' +``` + +```javascript +var data = { + create: [ + { + country: 'US', + state: 'AL', + rate: '4.0000', + name: 'State Tax', + shipping: false, + order: 1 + }, + { + country: 'US', + state: 'AZ', + rate: '5.6000', + name: 'State Tax', + shipping: false, + order: 2 + }, + { + country: 'US', + state: 'AR', + rate: '6.5000', + name: 'State Tax', + shipping: true, + order: 3 + }, + { + country: 'US', + state: 'CA', + rate: '7.5000', + name: 'State Tax', + shipping: false, + order: 4 + }, + { + country: 'US', + state: 'CO', + rate: '2.9000', + name: 'State Tax', + shipping: false, + order: 5 + }, + { + country: 'US', + state: 'CT', + rate: '6.3500', + name: 'State Tax', + shipping: true, + order: 6 + }, + { + country: 'US', + state: 'DC', + rate: '5.7500', + name: 'State Tax', + shipping: true, + order: 7 + }, + { + country: 'US', + state: 'FL', + rate: '6.0000', + name: 'State Tax', + shipping: true, + order: 8 + }, + { + country: 'US', + state: 'GA', + rate: '4.0000', + name: 'State Tax', + shipping: true, + order: 9 + }, + { + country: 'US', + state: 'GU', + rate: '4.0000', + name: 'State Tax', + shipping: false, + order: 10 + }, + { + country: 'US', + state: 'HI', + rate: '4.0000', + name: 'State Tax', + shipping: true, + order: 11 + }, + { + country: 'US', + state: 'ID', + rate: '6.0000', + name: 'State Tax', + shipping: false, + order: 12 + }, + { + country: 'US', + state: 'IL', + rate: '6.2500', + name: 'State Tax', + shipping: false, + order: 13 + }, + { + country: 'US', + state: 'IN', + rate: '7.0000', + name: 'State Tax', + shipping: false, + order: 14 + }, + { + country: 'US', + state: 'IA', + rate: '6.0000', + name: 'State Tax', + shipping: false, + order: 15 + }, + { + country: 'US', + state: 'KS', + rate: '6.1500', + name: 'State Tax', + shipping: true, + order: 16 + }, + { + country: 'US', + state: 'KY', + rate: '6.0000', + name: 'State Tax', + shipping: true, + order: 17 + }, + { + country: 'US', + state: 'LA', + rate: '4.0000', + name: 'State Tax', + shipping: false, + order: 18 + }, + { + country: 'US', + state: 'ME', + rate: '5.5000', + name: 'State Tax', + shipping: false, + order: 19 + }, + { + country: 'US', + state: 'MD', + rate: '6.0000', + name: 'State Tax', + shipping: false, + order: 20 + }, + { + country: 'US', + state: 'MA', + rate: '6.2500', + name: 'State Tax', + shipping: false, + order: 21 + }, + { + country: 'US', + state: 'MI', + rate: '6.0000', + name: 'State Tax', + shipping: true, + order: 22 + }, + { + country: 'US', + state: 'MN', + rate: '6.8750', + name: 'State Tax', + shipping: true, + order: 23 + }, + { + country: 'US', + state: 'MS', + rate: '7.0000', + name: 'State Tax', + shipping: true, + order: 24 + }, + { + country: 'US', + state: 'MO', + rate: '4.2250', + name: 'State Tax', + shipping: false, + order: 25 + }, + { + country: 'US', + state: 'NE', + rate: '5.5000', + name: 'State Tax', + shipping: true, + order: 26 + }, + { + country: 'US', + state: 'NV', + rate: '6.8500', + name: 'State Tax', + shipping: false, + order: 27 + }, + { + country: 'US', + state: 'NJ', + rate: '7.0000', + name: 'State Tax', + shipping: true, + order: 28 + }, + { + country: 'US', + state: 'NM', + rate: '5.1250', + name: 'State Tax', + shipping: true, + order: 29 + }, + { + country: 'US', + state: 'NY', + rate: '4.0000', + name: 'State Tax', + shipping: true, + order: 30 + }, + { + country: 'US', + state: 'NC', + rate: '4.7500', + name: 'State Tax', + shipping: true, + order: 31 + }, + { + country: 'US', + state: 'ND', + rate: '5.0000', + name: 'State Tax', + shipping: true, + order: 32 + }, + { + country: 'US', + state: 'OH', + rate: '5.7500', + name: 'State Tax', + shipping: true, + order: 33 + }, + { + country: 'US', + state: 'OK', + rate: '4.5000', + name: 'State Tax', + shipping: false, + order: 34 + }, + { + country: 'US', + state: 'PA', + rate: '6.0000', + name: 'State Tax', + shipping: true, + order: 35 + }, + { + country: 'US', + state: 'PR', + rate: '6.0000', + name: 'State Tax', + shipping: false, + order: 36 + }, + { + country: 'US', + state: 'RI', + rate: '7.0000', + name: 'State Tax', + shipping: false, + order: 37 + }, + { + country: 'US', + state: 'SC', + rate: '6.0000', + name: 'State Tax', + shipping: true, + order: 38 + }, + { + country: 'US', + state: 'SD', + rate: '4.0000', + name: 'State Tax', + shipping: true, + order: 39 + }, + { + country: 'US', + state: 'TN', + rate: '7.0000', + name: 'State Tax', + shipping: true, + order: 40 + }, + { + country: 'US', + state: 'TX', + rate: '6.2500', + name: 'State Tax', + shipping: true, + order: 41 + }, + { + country: 'US', + state: 'UT', + rate: '5.9500', + name: 'State Tax', + shipping: false, + order: 42 + }, + { + country: 'US', + state: 'VT', + rate: '6.0000', + name: 'State Tax', + shipping: true, + order: 43 + }, + { + country: 'US', + state: 'VA', + rate: '5.3000', + name: 'State Tax', + shipping: false, + order: 44 + }, + { + country: 'US', + state: 'WA', + rate: '6.5000', + name: 'State Tax', + shipping: true, + order: 45 + }, + { + country: 'US', + state: 'WV', + rate: '6.0000', + name: 'State Tax', + shipping: true, + order: 46 + }, + { + country: 'US', + state: 'WI', + rate: '5.0000', + name: 'State Tax', + shipping: true, + order: 47 + }, + { + country: 'US', + state: 'WY', + rate: '4.0000', + name: 'State Tax', + shipping: true, + order: 48 + } + ] +}; + +WooCommerce.post('taxes/batch', data, function(err, data, res) { + console.log(res); +}); +``` + +```php + [ + [ + 'country' => 'US', + 'state' => 'AL', + 'rate' => '4.0000', + 'name' => 'State Tax', + 'shipping' => false, + 'order' => 1 + ], + [ + 'country' => 'US', + 'state' => 'AZ', + 'rate' => '5.6000', + 'name' => 'State Tax', + 'shipping' => false, + 'order' => 2 + ], + [ + 'country' => 'US', + 'state' => 'AR', + 'rate' => '6.5000', + 'name' => 'State Tax', + 'shipping' => true, + 'order' => 3 + ], + [ + 'country' => 'US', + 'state' => 'CA', + 'rate' => '7.5000', + 'name' => 'State Tax', + 'shipping' => false, + 'order' => 4 + ], + [ + 'country' => 'US', + 'state' => 'CO', + 'rate' => '2.9000', + 'name' => 'State Tax', + 'shipping' => false, + 'order' => 5 + ], + [ + 'country' => 'US', + 'state' => 'CT', + 'rate' => '6.3500', + 'name' => 'State Tax', + 'shipping' => true, + 'order' => 6 + ], + [ + 'country' => 'US', + 'state' => 'DC', + 'rate' => '5.7500', + 'name' => 'State Tax', + 'shipping' => true, + 'order' => 7 + ], + [ + 'country' => 'US', + 'state' => 'FL', + 'rate' => '6.0000', + 'name' => 'State Tax', + 'shipping' => true, + 'order' => 8 + ], + [ + 'country' => 'US', + 'state' => 'GA', + 'rate' => '4.0000', + 'name' => 'State Tax', + 'shipping' => true, + 'order' => 9 + ], + [ + 'country' => 'US', + 'state' => 'GU', + 'rate' => '4.0000', + 'name' => 'State Tax', + 'shipping' => false, + 'order' => 10 + ], + [ + 'country' => 'US', + 'state' => 'HI', + 'rate' => '4.0000', + 'name' => 'State Tax', + 'shipping' => true, + 'order' => 11 + ], + [ + 'country' => 'US', + 'state' => 'ID', + 'rate' => '6.0000', + 'name' => 'State Tax', + 'shipping' => false, + 'order' => 12 + ], + [ + 'country' => 'US', + 'state' => 'IL', + 'rate' => '6.2500', + 'name' => 'State Tax', + 'shipping' => false, + 'order' => 13 + ], + [ + 'country' => 'US', + 'state' => 'IN', + 'rate' => '7.0000', + 'name' => 'State Tax', + 'shipping' => false, + 'order' => 14 + ], + [ + 'country' => 'US', + 'state' => 'IA', + 'rate' => '6.0000', + 'name' => 'State Tax', + 'shipping' => false, + 'order' => 15 + ], + [ + 'country' => 'US', + 'state' => 'KS', + 'rate' => '6.1500', + 'name' => 'State Tax', + 'shipping' => true, + 'order' => 16 + ], + [ + 'country' => 'US', + 'state' => 'KY', + 'rate' => '6.0000', + 'name' => 'State Tax', + 'shipping' => true, + 'order' => 17 + ], + [ + 'country' => 'US', + 'state' => 'LA', + 'rate' => '4.0000', + 'name' => 'State Tax', + 'shipping' => false, + 'order' => 18 + ], + [ + 'country' => 'US', + 'state' => 'ME', + 'rate' => '5.5000', + 'name' => 'State Tax', + 'shipping' => false, + 'order' => 19 + ], + [ + 'country' => 'US', + 'state' => 'MD', + 'rate' => '6.0000', + 'name' => 'State Tax', + 'shipping' => false, + 'order' => 20 + ], + [ + 'country' => 'US', + 'state' => 'MA', + 'rate' => '6.2500', + 'name' => 'State Tax', + 'shipping' => false, + 'order' => 21 + ], + [ + 'country' => 'US', + 'state' => 'MI', + 'rate' => '6.0000', + 'name' => 'State Tax', + 'shipping' => true, + 'order' => 22 + ], + [ + 'country' => 'US', + 'state' => 'MN', + 'rate' => '6.8750', + 'name' => 'State Tax', + 'shipping' => true, + 'order' => 23 + ], + [ + 'country' => 'US', + 'state' => 'MS', + 'rate' => '7.0000', + 'name' => 'State Tax', + 'shipping' => true, + 'order' => 24 + ], + [ + 'country' => 'US', + 'state' => 'MO', + 'rate' => '4.2250', + 'name' => 'State Tax', + 'shipping' => false, + 'order' => 25 + ], + [ + 'country' => 'US', + 'state' => 'NE', + 'rate' => '5.5000', + 'name' => 'State Tax', + 'shipping' => true, + 'order' => 26 + ], + [ + 'country' => 'US', + 'state' => 'NV', + 'rate' => '6.8500', + 'name' => 'State Tax', + 'shipping' => false, + 'order' => 27 + ], + [ + 'country' => 'US', + 'state' => 'NJ', + 'rate' => '7.0000', + 'name' => 'State Tax', + 'shipping' => true, + 'order' => 28 + ], + [ + 'country' => 'US', + 'state' => 'NM', + 'rate' => '5.1250', + 'name' => 'State Tax', + 'shipping' => true, + 'order' => 29 + ], + [ + 'country' => 'US', + 'state' => 'NY', + 'rate' => '4.0000', + 'name' => 'State Tax', + 'shipping' => true, + 'order' => 30 + ], + [ + 'country' => 'US', + 'state' => 'NC', + 'rate' => '4.7500', + 'name' => 'State Tax', + 'shipping' => true, + 'order' => 31 + ], + [ + 'country' => 'US', + 'state' => 'ND', + 'rate' => '5.0000', + 'name' => 'State Tax', + 'shipping' => true, + 'order' => 32 + ], + [ + 'country' => 'US', + 'state' => 'OH', + 'rate' => '5.7500', + 'name' => 'State Tax', + 'shipping' => true, + 'order' => 33 + ], + [ + 'country' => 'US', + 'state' => 'OK', + 'rate' => '4.5000', + 'name' => 'State Tax', + 'shipping' => false, + 'order' => 34 + ], + [ + 'country' => 'US', + 'state' => 'PA', + 'rate' => '6.0000', + 'name' => 'State Tax', + 'shipping' => true, + 'order' => 35 + ], + [ + 'country' => 'US', + 'state' => 'PR', + 'rate' => '6.0000', + 'name' => 'State Tax', + 'shipping' => false, + 'order' => 36 + ], + [ + 'country' => 'US', + 'state' => 'RI', + 'rate' => '7.0000', + 'name' => 'State Tax', + 'shipping' => false, + 'order' => 37 + ], + [ + 'country' => 'US', + 'state' => 'SC', + 'rate' => '6.0000', + 'name' => 'State Tax', + 'shipping' => true, + 'order' => 38 + ], + [ + 'country' => 'US', + 'state' => 'SD', + 'rate' => '4.0000', + 'name' => 'State Tax', + 'shipping' => true, + 'order' => 39 + ], + [ + 'country' => 'US', + 'state' => 'TN', + 'rate' => '7.0000', + 'name' => 'State Tax', + 'shipping' => true, + 'order' => 40 + ], + [ + 'country' => 'US', + 'state' => 'TX', + 'rate' => '6.2500', + 'name' => 'State Tax', + 'shipping' => true, + 'order' => 41 + ], + [ + 'country' => 'US', + 'state' => 'UT', + 'rate' => '5.9500', + 'name' => 'State Tax', + 'shipping' => false, + 'order' => 42 + ], + [ + 'country' => 'US', + 'state' => 'VT', + 'rate' => '6.0000', + 'name' => 'State Tax', + 'shipping' => true, + 'order' => 43 + ], + [ + 'country' => 'US', + 'state' => 'VA', + 'rate' => '5.3000', + 'name' => 'State Tax', + 'shipping' => false, + 'order' => 44 + ], + [ + 'country' => 'US', + 'state' => 'WA', + 'rate' => '6.5000', + 'name' => 'State Tax', + 'shipping' => true, + 'order' => 45 + ], + [ + 'country' => 'US', + 'state' => 'WV', + 'rate' => '6.0000', + 'name' => 'State Tax', + 'shipping' => true, + 'order' => 46 + ], + [ + 'country' => 'US', + 'state' => 'WI', + 'rate' => '5.0000', + 'name' => 'State Tax', + 'shipping' => true, + 'order' => 47 + ], + [ + 'country' => 'US', + 'state' => 'WY', + 'rate' => '4.0000', + 'name' => 'State Tax', + 'shipping' => true, + 'order' => 48 + ] + ] +]; + +print_r($woocommerce->post('taxes/batch', $data)); +?> +``` + +```python +data = { + "create": [ + { + "country": "US", + "state": "AL", + "rate": "4.0000", + "name": "State Tax", + "shipping": False, + "order": 1 + }, + { + "country": "US", + "state": "AZ", + "rate": "5.6000", + "name": "State Tax", + "shipping": False, + "order": 2 + }, + { + "country": "US", + "state": "AR", + "rate": "6.5000", + "name": "State Tax", + "shipping": True, + "order": 3 + }, + { + "country": "US", + "state": "CA", + "rate": "7.5000", + "name": "State Tax", + "shipping": False, + "order": 4 + }, + { + "country": "US", + "state": "CO", + "rate": "2.9000", + "name": "State Tax", + "shipping": False, + "order": 5 + }, + { + "country": "US", + "state": "CT", + "rate": "6.3500", + "name": "State Tax", + "shipping": True, + "order": 6 + }, + { + "country": "US", + "state": "DC", + "rate": "5.7500", + "name": "State Tax", + "shipping": True, + "order": 7 + }, + { + "country": "US", + "state": "FL", + "rate": "6.0000", + "name": "State Tax", + "shipping": True, + "order": 8 + }, + { + "country": "US", + "state": "GA", + "rate": "4.0000", + "name": "State Tax", + "shipping": True, + "order": 9 + }, + { + "country": "US", + "state": "GU", + "rate": "4.0000", + "name": "State Tax", + "shipping": False, + "order": 10 + }, + { + "country": "US", + "state": "HI", + "rate": "4.0000", + "name": "State Tax", + "shipping": True, + "order": 11 + }, + { + "country": "US", + "state": "ID", + "rate": "6.0000", + "name": "State Tax", + "shipping": False, + "order": 12 + }, + { + "country": "US", + "state": "IL", + "rate": "6.2500", + "name": "State Tax", + "shipping": False, + "order": 13 + }, + { + "country": "US", + "state": "IN", + "rate": "7.0000", + "name": "State Tax", + "shipping": False, + "order": 14 + }, + { + "country": "US", + "state": "IA", + "rate": "6.0000", + "name": "State Tax", + "shipping": False, + "order": 15 + }, + { + "country": "US", + "state": "KS", + "rate": "6.1500", + "name": "State Tax", + "shipping": True, + "order": 16 + }, + { + "country": "US", + "state": "KY", + "rate": "6.0000", + "name": "State Tax", + "shipping": True, + "order": 17 + }, + { + "country": "US", + "state": "LA", + "rate": "4.0000", + "name": "State Tax", + "shipping": False, + "order": 18 + }, + { + "country": "US", + "state": "ME", + "rate": "5.5000", + "name": "State Tax", + "shipping": False, + "order": 19 + }, + { + "country": "US", + "state": "MD", + "rate": "6.0000", + "name": "State Tax", + "shipping": False, + "order": 20 + }, + { + "country": "US", + "state": "MA", + "rate": "6.2500", + "name": "State Tax", + "shipping": False, + "order": 21 + }, + { + "country": "US", + "state": "MI", + "rate": "6.0000", + "name": "State Tax", + "shipping": True, + "order": 22 + }, + { + "country": "US", + "state": "MN", + "rate": "6.8750", + "name": "State Tax", + "shipping": True, + "order": 23 + }, + { + "country": "US", + "state": "MS", + "rate": "7.0000", + "name": "State Tax", + "shipping": True, + "order": 24 + }, + { + "country": "US", + "state": "MO", + "rate": "4.2250", + "name": "State Tax", + "shipping": False, + "order": 25 + }, + { + "country": "US", + "state": "NE", + "rate": "5.5000", + "name": "State Tax", + "shipping": True, + "order": 26 + }, + { + "country": "US", + "state": "NV", + "rate": "6.8500", + "name": "State Tax", + "shipping": False, + "order": 27 + }, + { + "country": "US", + "state": "NJ", + "rate": "7.0000", + "name": "State Tax", + "shipping": True, + "order": 28 + }, + { + "country": "US", + "state": "NM", + "rate": "5.1250", + "name": "State Tax", + "shipping": True, + "order": 29 + }, + { + "country": "US", + "state": "NY", + "rate": "4.0000", + "name": "State Tax", + "shipping": True, + "order": 30 + }, + { + "country": "US", + "state": "NC", + "rate": "4.7500", + "name": "State Tax", + "shipping": True, + "order": 31 + }, + { + "country": "US", + "state": "ND", + "rate": "5.0000", + "name": "State Tax", + "shipping": True, + "order": 32 + }, + { + "country": "US", + "state": "OH", + "rate": "5.7500", + "name": "State Tax", + "shipping": True, + "order": 33 + }, + { + "country": "US", + "state": "OK", + "rate": "4.5000", + "name": "State Tax", + "shipping": False, + "order": 34 + }, + { + "country": "US", + "state": "PA", + "rate": "6.0000", + "name": "State Tax", + "shipping": True, + "order": 35 + }, + { + "country": "US", + "state": "PR", + "rate": "6.0000", + "name": "State Tax", + "shipping": False, + "order": 36 + }, + { + "country": "US", + "state": "RI", + "rate": "7.0000", + "name": "State Tax", + "shipping": False, + "order": 37 + }, + { + "country": "US", + "state": "SC", + "rate": "6.0000", + "name": "State Tax", + "shipping": True, + "order": 38 + }, + { + "country": "US", + "state": "SD", + "rate": "4.0000", + "name": "State Tax", + "shipping": True, + "order": 39 + }, + { + "country": "US", + "state": "TN", + "rate": "7.0000", + "name": "State Tax", + "shipping": True, + "order": 40 + }, + { + "country": "US", + "state": "TX", + "rate": "6.2500", + "name": "State Tax", + "shipping": True, + "order": 41 + }, + { + "country": "US", + "state": "UT", + "rate": "5.9500", + "name": "State Tax", + "shipping": False, + "order": 42 + }, + { + "country": "US", + "state": "VT", + "rate": "6.0000", + "name": "State Tax", + "shipping": True, + "order": 43 + }, + { + "country": "US", + "state": "VA", + "rate": "5.3000", + "name": "State Tax", + "shipping": False, + "order": 44 + }, + { + "country": "US", + "state": "WA", + "rate": "6.5000", + "name": "State Tax", + "shipping": True, + "order": 45 + }, + { + "country": "US", + "state": "WV", + "rate": "6.0000", + "name": "State Tax", + "shipping": True, + "order": 46 + }, + { + "country": "US", + "state": "WI", + "rate": "5.0000", + "name": "State Tax", + "shipping": True, + "order": 47 + }, + { + "country": "US", + "state": "WY", + "rate": "4.0000", + "name": "State Tax", + "shipping": True, + "order": 48 + } + ] +} + +print(wcapi.post("taxes/batch", data).json()) +``` + +```ruby +data = { + create: [ + { + country: "US", + state: "AL", + rate: "4.0000", + name: "State Tax", + shipping: false, + order: 1 + }, + { + country: "US", + state: "AZ", + rate: "5.6000", + name: "State Tax", + shipping: false, + order: 2 + }, + { + country: "US", + state: "AR", + rate: "6.5000", + name: "State Tax", + shipping: true, + order: 3 + }, + { + country: "US", + state: "CA", + rate: "7.5000", + name: "State Tax", + shipping: false, + order: 4 + }, + { + country: "US", + state: "CO", + rate: "2.9000", + name: "State Tax", + shipping: false, + order: 5 + }, + { + country: "US", + state: "CT", + rate: "6.3500", + name: "State Tax", + shipping: true, + order: 6 + }, + { + country: "US", + state: "DC", + rate: "5.7500", + name: "State Tax", + shipping: true, + order: 7 + }, + { + country: "US", + state: "FL", + rate: "6.0000", + name: "State Tax", + shipping: true, + order: 8 + }, + { + country: "US", + state: "GA", + rate: "4.0000", + name: "State Tax", + shipping: true, + order: 9 + }, + { + country: "US", + state: "GU", + rate: "4.0000", + name: "State Tax", + shipping: false, + order: 10 + }, + { + country: "US", + state: "HI", + rate: "4.0000", + name: "State Tax", + shipping: true, + order: 11 + }, + { + country: "US", + state: "ID", + rate: "6.0000", + name: "State Tax", + shipping: false, + order: 12 + }, + { + country: "US", + state: "IL", + rate: "6.2500", + name: "State Tax", + shipping: false, + order: 13 + }, + { + country: "US", + state: "IN", + rate: "7.0000", + name: "State Tax", + shipping: false, + order: 14 + }, + { + country: "US", + state: "IA", + rate: "6.0000", + name: "State Tax", + shipping: false, + order: 15 + }, + { + country: "US", + state: "KS", + rate: "6.1500", + name: "State Tax", + shipping: true, + order: 16 + }, + { + country: "US", + state: "KY", + rate: "6.0000", + name: "State Tax", + shipping: true, + order: 17 + }, + { + country: "US", + state: "LA", + rate: "4.0000", + name: "State Tax", + shipping: false, + order: 18 + }, + { + country: "US", + state: "ME", + rate: "5.5000", + name: "State Tax", + shipping: false, + order: 19 + }, + { + country: "US", + state: "MD", + rate: "6.0000", + name: "State Tax", + shipping: false, + order: 20 + }, + { + country: "US", + state: "MA", + rate: "6.2500", + name: "State Tax", + shipping: false, + order: 21 + }, + { + country: "US", + state: "MI", + rate: "6.0000", + name: "State Tax", + shipping: true, + order: 22 + }, + { + country: "US", + state: "MN", + rate: "6.8750", + name: "State Tax", + shipping: true, + order: 23 + }, + { + country: "US", + state: "MS", + rate: "7.0000", + name: "State Tax", + shipping: true, + order: 24 + }, + { + country: "US", + state: "MO", + rate: "4.2250", + name: "State Tax", + shipping: false, + order: 25 + }, + { + country: "US", + state: "NE", + rate: "5.5000", + name: "State Tax", + shipping: true, + order: 26 + }, + { + country: "US", + state: "NV", + rate: "6.8500", + name: "State Tax", + shipping: false, + order: 27 + }, + { + country: "US", + state: "NJ", + rate: "7.0000", + name: "State Tax", + shipping: true, + order: 28 + }, + { + country: "US", + state: "NM", + rate: "5.1250", + name: "State Tax", + shipping: true, + order: 29 + }, + { + country: "US", + state: "NY", + rate: "4.0000", + name: "State Tax", + shipping: true, + order: 30 + }, + { + country: "US", + state: "NC", + rate: "4.7500", + name: "State Tax", + shipping: true, + order: 31 + }, + { + country: "US", + state: "ND", + rate: "5.0000", + name: "State Tax", + shipping: true, + order: 32 + }, + { + country: "US", + state: "OH", + rate: "5.7500", + name: "State Tax", + shipping: true, + order: 33 + }, + { + country: "US", + state: "OK", + rate: "4.5000", + name: "State Tax", + shipping: false, + order: 34 + }, + { + country: "US", + state: "PA", + rate: "6.0000", + name: "State Tax", + shipping: true, + order: 35 + }, + { + country: "US", + state: "PR", + rate: "6.0000", + name: "State Tax", + shipping: false, + order: 36 + }, + { + country: "US", + state: "RI", + rate: "7.0000", + name: "State Tax", + shipping: false, + order: 37 + }, + { + country: "US", + state: "SC", + rate: "6.0000", + name: "State Tax", + shipping: true, + order: 38 + }, + { + country: "US", + state: "SD", + rate: "4.0000", + name: "State Tax", + shipping: true, + order: 39 + }, + { + country: "US", + state: "TN", + rate: "7.0000", + name: "State Tax", + shipping: true, + order: 40 + }, + { + country: "US", + state: "TX", + rate: "6.2500", + name: "State Tax", + shipping: true, + order: 41 + }, + { + country: "US", + state: "UT", + rate: "5.9500", + name: "State Tax", + shipping: false, + order: 42 + }, + { + country: "US", + state: "VT", + rate: "6.0000", + name: "State Tax", + shipping: true, + order: 43 + }, + { + country: "US", + state: "VA", + rate: "5.3000", + name: "State Tax", + shipping: false, + order: 44 + }, + { + country: "US", + state: "WA", + rate: "6.5000", + name: "State Tax", + shipping: true, + order: 45 + }, + { + country: "US", + state: "WV", + rate: "6.0000", + name: "State Tax", + shipping: true, + order: 46 + }, + { + country: "US", + state: "WI", + rate: "5.0000", + name: "State Tax", + shipping: true, + order: 47 + }, + { + country: "US", + state: "WY", + rate: "4.0000", + name: "State Tax", + shipping: true, + order: 48 + } + ] +} + +woocommerce.post("taxes/batch", data).parsed_response +``` + +> JSON response example: + +```json +{ + "create": [ + { + "id": 72, + "country": "US", + "state": "AL", + "postcode": "", + "city": "", + "rate": "4.0000", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": false, + "order": 1, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/72" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 73, + "country": "US", + "state": "AZ", + "postcode": "", + "city": "", + "rate": "5.6000", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": false, + "order": 2, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/73" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 74, + "country": "US", + "state": "AR", + "postcode": "", + "city": "", + "rate": "6.5000", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": true, + "order": 3, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/74" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 75, + "country": "US", + "state": "CA", + "postcode": "", + "city": "", + "rate": "7.5000", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": false, + "order": 4, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/75" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 76, + "country": "US", + "state": "CO", + "postcode": "", + "city": "", + "rate": "2.9000", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": false, + "order": 5, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/76" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 77, + "country": "US", + "state": "CT", + "postcode": "", + "city": "", + "rate": "6.3500", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": true, + "order": 6, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/77" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 78, + "country": "US", + "state": "DC", + "postcode": "", + "city": "", + "rate": "5.7500", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": true, + "order": 7, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/78" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 79, + "country": "US", + "state": "FL", + "postcode": "", + "city": "", + "rate": "6.0000", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": true, + "order": 8, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/79" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 80, + "country": "US", + "state": "GA", + "postcode": "", + "city": "", + "rate": "4.0000", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": true, + "order": 9, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/80" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 81, + "country": "US", + "state": "GU", + "postcode": "", + "city": "", + "rate": "4.0000", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": false, + "order": 10, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/81" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 82, + "country": "US", + "state": "HI", + "postcode": "", + "city": "", + "rate": "4.0000", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": true, + "order": 11, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/82" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 83, + "country": "US", + "state": "ID", + "postcode": "", + "city": "", + "rate": "6.0000", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": false, + "order": 12, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/83" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 84, + "country": "US", + "state": "IL", + "postcode": "", + "city": "", + "rate": "6.2500", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": false, + "order": 13, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/84" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 85, + "country": "US", + "state": "IN", + "postcode": "", + "city": "", + "rate": "7.0000", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": false, + "order": 14, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/85" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 86, + "country": "US", + "state": "IA", + "postcode": "", + "city": "", + "rate": "6.0000", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": false, + "order": 15, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/86" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 87, + "country": "US", + "state": "KS", + "postcode": "", + "city": "", + "rate": "6.1500", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": true, + "order": 16, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/87" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 88, + "country": "US", + "state": "KY", + "postcode": "", + "city": "", + "rate": "6.0000", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": true, + "order": 17, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/88" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 89, + "country": "US", + "state": "LA", + "postcode": "", + "city": "", + "rate": "4.0000", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": false, + "order": 18, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/89" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 90, + "country": "US", + "state": "ME", + "postcode": "", + "city": "", + "rate": "5.5000", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": false, + "order": 19, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/90" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 91, + "country": "US", + "state": "MD", + "postcode": "", + "city": "", + "rate": "6.0000", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": false, + "order": 20, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/91" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 92, + "country": "US", + "state": "MA", + "postcode": "", + "city": "", + "rate": "6.2500", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": false, + "order": 21, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/92" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 93, + "country": "US", + "state": "MI", + "postcode": "", + "city": "", + "rate": "6.0000", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": true, + "order": 22, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/93" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 94, + "country": "US", + "state": "MN", + "postcode": "", + "city": "", + "rate": "6.8750", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": true, + "order": 23, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/94" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 95, + "country": "US", + "state": "MS", + "postcode": "", + "city": "", + "rate": "7.0000", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": true, + "order": 24, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/95" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 96, + "country": "US", + "state": "MO", + "postcode": "", + "city": "", + "rate": "4.2250", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": false, + "order": 25, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/96" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 97, + "country": "US", + "state": "NE", + "postcode": "", + "city": "", + "rate": "5.5000", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": true, + "order": 26, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/97" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 98, + "country": "US", + "state": "NV", + "postcode": "", + "city": "", + "rate": "6.8500", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": false, + "order": 27, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/98" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 99, + "country": "US", + "state": "NJ", + "postcode": "", + "city": "", + "rate": "7.0000", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": true, + "order": 28, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/99" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 100, + "country": "US", + "state": "NM", + "postcode": "", + "city": "", + "rate": "5.1250", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": true, + "order": 29, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/100" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 101, + "country": "US", + "state": "NY", + "postcode": "", + "city": "", + "rate": "4.0000", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": true, + "order": 30, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/101" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 102, + "country": "US", + "state": "NC", + "postcode": "", + "city": "", + "rate": "4.7500", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": true, + "order": 31, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/102" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 103, + "country": "US", + "state": "ND", + "postcode": "", + "city": "", + "rate": "5.0000", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": true, + "order": 32, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/103" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 104, + "country": "US", + "state": "OH", + "postcode": "", + "city": "", + "rate": "5.7500", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": true, + "order": 33, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/104" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 105, + "country": "US", + "state": "OK", + "postcode": "", + "city": "", + "rate": "4.5000", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": false, + "order": 34, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/105" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 106, + "country": "US", + "state": "PA", + "postcode": "", + "city": "", + "rate": "6.0000", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": true, + "order": 35, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/106" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 107, + "country": "US", + "state": "PR", + "postcode": "", + "city": "", + "rate": "6.0000", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": false, + "order": 36, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/107" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 108, + "country": "US", + "state": "RI", + "postcode": "", + "city": "", + "rate": "7.0000", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": false, + "order": 37, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/108" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 109, + "country": "US", + "state": "SC", + "postcode": "", + "city": "", + "rate": "6.0000", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": true, + "order": 38, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/109" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 110, + "country": "US", + "state": "SD", + "postcode": "", + "city": "", + "rate": "4.0000", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": true, + "order": 39, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/110" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 111, + "country": "US", + "state": "TN", + "postcode": "", + "city": "", + "rate": "7.0000", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": true, + "order": 40, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/111" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 112, + "country": "US", + "state": "TX", + "postcode": "", + "city": "", + "rate": "6.2500", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": true, + "order": 41, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/112" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 113, + "country": "US", + "state": "UT", + "postcode": "", + "city": "", + "rate": "5.9500", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": false, + "order": 42, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/113" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 114, + "country": "US", + "state": "VT", + "postcode": "", + "city": "", + "rate": "6.0000", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": true, + "order": 43, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/114" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 115, + "country": "US", + "state": "VA", + "postcode": "", + "city": "", + "rate": "5.3000", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": false, + "order": 44, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/115" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 116, + "country": "US", + "state": "WA", + "postcode": "", + "city": "", + "rate": "6.5000", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": true, + "order": 45, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/116" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 117, + "country": "US", + "state": "WV", + "postcode": "", + "city": "", + "rate": "6.0000", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": true, + "order": 46, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/117" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 118, + "country": "US", + "state": "WI", + "postcode": "", + "city": "", + "rate": "5.0000", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": true, + "order": 47, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/118" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + }, + { + "id": 119, + "country": "US", + "state": "WY", + "postcode": "", + "city": "", + "rate": "4.0000", + "name": "State Tax", + "priority": 0, + "compound": false, + "shipping": true, + "order": 48, + "class": "standard", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes/119" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/taxes" + } + ] + } + } + ] +} +``` diff --git a/source/includes/wp-api-v1/_webhooks.md b/source/includes/wp-api-v1/_webhooks.md new file mode 100644 index 00000000..e6a157da --- /dev/null +++ b/source/includes/wp-api-v1/_webhooks.md @@ -0,0 +1,1016 @@ +# Webhooks # + +The webhooks API allows you to create, view, update, and delete individual, or a batch, of webhooks. + +Webhooks can be managed via the WooCommerce settings screen or by using the REST API endpoints. The `WC_Webhook` class manages all data storage and retrieval of the webhook custom post type, as well as enqueuing webhook actions and processing/delivering/logging webhooks. On `woocommerce_init`, active webhooks are loaded. + +Each webhook has: + +* `status`: active (delivers payload), paused (delivery paused by admin), disabled (delivery paused by failure). +* `topic`: determines which resource events the webhook is triggered for. +* `delivery URL`: URL where the payload is delivered, must be HTTP or HTTPS. +* `secret`: an optional secret key that is used to generate a HMAC-SHA256 hash of the request body so the receiver can verify authenticity of the webhook. +* `hooks`: an array of hook names that are added and bound to the webhook for processing. + +### Topics ### + +The topic is a combination resource (e.g. order) and event (e.g. created) and maps to one or more hook names (e.g. `woocommerce_checkout_order_processed`). Webhooks can be created using the topic name and the appropriate hooks are automatically added. + +Core topics are: + +* Coupons: `coupon.created`, `coupon.updated` and `coupon.deleted`. +* Customers: `customer.created`, `customer.updated` and `customer.deleted`. +* Orders: `order.created`, `order.updated` and `order.deleted`. +* Products: `product.created`, `product.updated` and `product.deleted`. + +Custom topics can also be used which map to a single hook name, for example you could add a webhook with topic `action.woocommerce_add_to_cart` that is triggered on that event. Custom topics pass the first hook argument to the payload, so in this example the `cart_item_key` would be included in the payload. + +### Delivery/payload ### + +Delivery is performed using `wp_remote_post()` (HTTP POST) and processed in the background by default using wp-cron. A few custom headers are added to the request to help the receiver process the webhook: + +* `X-WC-Webhook-Topic` - e.g. `order.updated`. +* `X-WC-Webhook-Resource` - e.g. `order`. +* `X-WC-Webhook-Event` - e.g. `updated`. +* `X-WC-Webhook-Signature` - a base64 encoded HMAC-SHA256 hash of the payload. +* `X-WC-Webhook-ID` - webhook's post ID. +* `X-WC-Delivery-ID` - delivery log ID (a comment). + +The payload is JSON encoded and for API resources (coupons, customers, orders, products), the response is exactly the same as if requested via the REST API. + +### Logging ### + +Requests/responses are logged as comments on the webhook custom post type. Each delivery log includes: + +* Request duration. +* Request URL, method, headers, and body. +* Response Code, message, headers, and body. + +Only the 25 most recent delivery logs are kept in order to reduce comment table bloat. + +After 5 consecutive failed deliveries (as defined by a non HTTP 2xx response code), the webhook is disabled and must be edited via the REST API to re-enable. + +Delivery logs can be fetched through the REST API endpoint or in code using `WC_Webhook::get_delivery_logs()`. + +### Visual interface ### + +You can find the Webhooks interface going to "WooCommerce" > "Settings" > "API" > "Webhooks", see our [Visual Webhooks docs](https://docs.woothemes.com/document/webhooks/) for more details. + +## Webhook properties ## + +| Attribute | Type | Description | +|-----------------|-----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `id` | integer | Unique identifier for the resource. read-only | +| `name` | string | A friendly name for the webhook. Defaults is `Webhook created on <date>`. | +| `status` | string | Webhook status. Default is `active`. Options `active` (delivers payload), `paused` (does not deliver), or `disabled` (does not deliver due delivery failures). | +| `topic` | string | Webhook topic, e.g. `coupon.updated`. [See the complete list](#topics). required | +| `resource` | string | Webhook resource, e.g. `coupon` read-only | +| `event` | string | Webhook event, e.g. `updated` read-only | +| `hooks` | array | WooCommerce action names associated with the webhook. read-only | +| `delivery_url` | string | The URL where the webhook payload is delivered. required | +| `secret` | string | Secret key used to generate a hash of the delivered webhook and provided in the request headers. This will default is a MD5 hash from the current user's IDsusername if not provided. write-only | +| `date_created` | date-time | UTC DateTime when the webhook was created read-only | +| `date_modified` | date-time | UTC DateTime when the webhook was last updated read-only | + +### Webhooks delivery properties ### + +| Attribute | Type | Description | +|--------------------|-----------|--------------------------------------------------------------------------------------------------------------------------------------------| +| `id` | integer | Unique identifier for the resource. read-only | +| `duration` | string | The delivery duration, in seconds. read-only | +| `summary` | string | A friendly summary of the response including the HTTP response code, message, and body. read-only | +| `request_url` | string | The URL where the webhook was delivered. read-only | +| `request_headers` | array | Request headers. See [Request Headers Attributes](#request-header-properties) for more details. read-only | +| `request_body` | string | Request body. read-only | +| `response_code` | string | The HTTP response code from the receiving server. read-only | +| `response_message` | string | The HTTP response message from the receiving server. read-only | +| `response_headers` | array | Array of the response headers from the receiving server. read-only | +| `response_body` | string | The response body from the receiving server. read-only | +| `date_created` | date-time | The date the webhook delivery was logged, in the site's timezone. read-only | + +#### Request header properties #### + +| Attribute | Type | Description | +|----------------------------|---------|---------------------------------------------------------------------------------------------------------------------------------------| +| `User-Agent` | string | The request user agent, default is "WooCommerce/{version} Hookshot (WordPress/{version})". read-only | +| `Content-Type` | string | The request content-type, default is "application/json". read-only | +| `X-WC-Webhook-Topic` | string | The webhook topic. read-only | +| `X-WC-Webhook-Resource` | string | The webhook resource. read-only | +| `X-WC-Webhook-Event` | string | The webhook event. read-only | +| `X-WC-Webhook-Signature` | string | A base64 encoded HMAC-SHA256 hash of the payload. read-only | +| `X-WC-Webhook-ID` | integer | The webhook's ID. read-only | +| `X-WC-Webhook-Delivery-ID` | integer | The delivery ID. read-only | + +## Create a webhook ## + +This API helps you to create a new webhook. + +### HTTP request ### + +
+
+ POST +
/wp-json/wc/v1/webhooks
+
+
+ +```shell +curl -X POST https://example.com/wp-json/wc/v1/webhooks \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "name": "Order updated", + "topic": "order.updated", + "delivery_url": "http://requestb.in/1g0sxmo1" +}' +``` + +```javascript +var data = { + name: 'Order updated', + topic: 'order.updated', + delivery_url: 'http://requestb.in/1g0sxmo1' +}; + +WooCommerce.post('webhooks', data, function(err, data, res) { + console.log(res); +}); +``` + +```php + 'Order updated', + 'topic' => 'order.updated', + 'delivery_url' => 'http://requestb.in/1g0sxmo1' +]; + +print_r($woocommerce->post('webhooks', $data)); +?> +``` + +```python +data = { + "name": "Order updated", + "topic": "order.updated", + "delivery_url": "http://requestb.in/1g0sxmo1" +} + +print(wcapi.post("webhooks", data).json()) +``` + +```ruby +data = { + name: "Order updated", + topic: "order.updated", + delivery_url: "http://requestb.in/1g0sxmo1" +} + +woocommerce.post("webhooks", data).parsed_response +``` + +> JSON response example: + +```json +{ + "id": 142, + "name": "Order updated", + "status": "active", + "topic": "order.updated", + "resource": "order", + "event": "updated", + "hooks": [ + "woocommerce_process_shop_order_meta", + "woocommerce_api_edit_order", + "woocommerce_order_edit_status", + "woocommerce_order_status_changed" + ], + "delivery_url": "http://requestb.in/1g0sxmo1", + "date_created": "2016-05-15T20:17:52", + "date_modified": "2016-05-15T20:17:52", + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/webhooks/142" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/webhooks" + } + ] + } +} +``` + +## Retrieve a webhook ## + +This API lets you retrieve and view a specific webhook. + +### HTTP request ### + +
+
+ GET +
/wp-json/wc/v1/webhooks/<id>
+
+
+ +```shell +curl https://example.com/wp-json/wc/v1/webhooks/142 \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('webhooks/142', function(err, data, res) { + console.log(res); +}); +``` + +```php +get('webhooks/142')); ?> +``` + +```python +print(wcapi.get("webhooks/142").json()) +``` + +```ruby +woocommerce.get("webhooks/142").parsed_response +``` + +> JSON response example: + +```json +{ + "id": 142, + "name": "Order updated", + "status": "active", + "topic": "order.updated", + "resource": "order", + "event": "updated", + "hooks": [ + "woocommerce_process_shop_order_meta", + "woocommerce_api_edit_order", + "woocommerce_order_edit_status", + "woocommerce_order_status_changed" + ], + "delivery_url": "http://requestb.in/1g0sxmo1", + "date_created": "2016-05-15T20:17:52", + "date_modified": "2016-05-15T20:17:52", + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/webhooks/142" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/webhooks" + } + ] + } +} +``` + +## List all webhooks ## + +This API helps you to view all the webhooks. + +### HTTP request ### + +
+
+ GET +
/wp-json/wc/v1/webhooks
+
+
+ +```shell +curl https://example.com/wp-json/wc/v1/webhooks \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('webhooks', function(err, data, res) { + console.log(res); +}); +``` + +```php +get('webhooks')); ?> +``` + +```python +print(wcapi.get("webhooks").json()) +``` + +```ruby +woocommerce.get("webhooks").parsed_response +``` + +> JSON response example: + +```json +[ + { + "id": 143, + "name": "Customer created", + "status": "active", + "topic": "customer.created", + "resource": "customer", + "event": "created", + "hooks": [ + "user_register", + "woocommerce_created_customer", + "woocommerce_api_create_customer" + ], + "delivery_url": "http://requestb.in/1g0sxmo1", + "date_created": "2016-05-15T20:17:52", + "date_modified": "2016-05-15T20:17:52", + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/webhooks/143" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/webhooks" + } + ] + } + }, + { + "id": 142, + "name": "Order updated", + "status": "active", + "topic": "order.updated", + "resource": "order", + "event": "updated", + "hooks": [ + "woocommerce_process_shop_order_meta", + "woocommerce_api_edit_order", + "woocommerce_order_edit_status", + "woocommerce_order_status_changed" + ], + "delivery_url": "http://requestb.in/1g0sxmo1", + "date_created": "2016-05-15T20:17:52", + "date_modified": "2016-05-15T20:17:52", + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/webhooks/142" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/webhooks" + } + ] + } + } +] +``` + +#### Available parameters #### + +| Parameter | Type | Description | +|------------|---------|-------------------------------------------------------------------------------------------------------------------------------| +| `context` | string | Scope under which the request is made; determines fields present in response. Options: `view` and `edit`. | +| `page` | integer | Current page of the collection. | +| `per_page` | integer | Maximum number of items to be returned in result set. | +| `search` | string | Limit results to those matching a string. | +| `after` | string | Limit response to resources published after a given ISO8601 compliant date. | +| `before` | string | Limit response to resources published before a given ISO8601 compliant date. | +| `exclude` | string | Ensure result set excludes specific ids. | +| `include` | string | Limit result set to specific ids. | +| `offset` | integer | Offset the result set by a specific number of items. | +| `order` | string | Order sort attribute ascending or descending. Default is `asc`. Options: `asc` and `desc`. | +| `orderby` | string | Sort collection by object attribute. Default is `date`, Options: `date`, `id`, `include`, `title` and `slug`. | +| `slug` | string | Limit result set to posts with a specific slug. | +| `filter` | string | Use WP Query arguments to modify the response; private query vars require appropriate authorization. | +| `status` | string | Limit result set to webhooks assigned a specific status. Default is `all`. Options: `all`, `active`, `paused` and `disabled`. | + +## Update a webhook ## + +This API lets you make changes to a webhook. + +### HTTP request ### + +
+
+ PUT +
/wp-json/wc/v1/webhook/<id>
+
+
+ +```shell +curl -X PUT https://example.com/wp-json/wc/v1/webhook/142 \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "status": "paused" +}' +``` + +```javascript +var data = { + status: 'paused' +} + +WooCommerce.put('webhooks/142', data, function(err, data, res) { + console.log(res); +}); +``` + +```php + 'paused' +]; + +print_r($woocommerce->put('webhooks/142', $data)); +?> +``` + +```python +data = { + "status": "paused" +} + +print(wcapi.put("webhooks/142", data).json()) +``` + +```ruby +data = { + status: "paused" +} + +woocommerce.put("webhooks/142", data).parsed_response +``` + +> JSON response example: + +```json +{ + "id": 142, + "name": "Order updated", + "status": "paused", + "topic": "order.updated", + "resource": "order", + "event": "updated", + "hooks": [ + "woocommerce_process_shop_order_meta", + "woocommerce_api_edit_order", + "woocommerce_order_edit_status", + "woocommerce_order_status_changed" + ], + "delivery_url": "http://requestb.in/1g0sxmo1", + "date_created": "2016-05-15T20:17:52", + "date_modified": "2016-05-15T20:30:12", + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/webhooks/142" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/webhooks" + } + ] + } +} +``` + +## Delete a webhook ## + +This API helps you delete a webhook. + +### HTTP request ### + +
+
+ DELETE +
/wp-json/wc/v1/webhooks/<id>
+
+
+ +```shell +curl -X DELETE https://example.com/wp-json/wc/v1/webhooks/142 \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.delete('webhooks/142', function(err, data, res) { + console.log(res); +}); +``` + +```php +delete('webhooks/142')); ?> +``` + +```python +print(wcapi.delete("webhooks/142").json()) +``` + +```ruby +woocommerce.delete("webhooks/142").parsed_response +``` + +> JSON response example: + +```json +{ + "id": 142, + "name": "Order updated", + "status": "paused", + "topic": "order.updated", + "resource": "order", + "event": "updated", + "hooks": [ + "woocommerce_process_shop_order_meta", + "woocommerce_api_edit_order", + "woocommerce_order_edit_status", + "woocommerce_order_status_changed" + ], + "delivery_url": "http://requestb.in/1g0sxmo1", + "date_created": "2016-05-15T20:17:52", + "date_modified": "2016-05-15T20:30:12", + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/webhooks/142" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/webhooks" + } + ] + } +} +``` + +#### Available parameters #### + +| Parameter | Type | Description | +|-----------|--------|----------------------------------------------------------------------------| +| `force` | string | Use `true` whether to permanently delete the webhook, Defaults is `false`. | + +## Batch update webhooks ## + +This API helps you to batch create, update and delete multiple webhooks. + +### HTTP request ### + +
+
+ POST +
/wp-json/wc/v1/webhooks/batch
+
+
+ +```shell +curl -X POST https://example.com//wp-json/wc/v1/webhooks/batch \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "create": [ + { + "name": "Coupon created", + "topic": "coupon.created", + "delivery_url": "http://requestb.in/1g0sxmo1" + }, + { + "name": "Customer deleted", + "topic": "customer.deleted", + "delivery_url": "http://requestb.in/1g0sxmo1" + } + ], + "delete": [ + 143 + ] +}' +``` + +```javascript +var data = { + create: [ + { + name: 'Round toe', + topic: 'coupon.created', + delivery_url: 'http://requestb.in/1g0sxmo1' + }, + { + name: 'Customer deleted', + topic: 'customer.deleted', + delivery_url: 'http://requestb.in/1g0sxmo1' + } + ], + delete: [ + 143 + ] +}; + +WooCommerce.post('webhooks/batch', data, function(err, data, res) { + console.log(res); +}); +``` + +```php + [ + [ + 'name' => 'Round toe', + 'topic' => 'coupon.created', + 'delivery_url' => 'http://requestb.in/1g0sxmo1' + ], + [ + 'name' => 'Customer deleted', + 'topic' => 'customer.deleted', + 'delivery_url' => 'http://requestb.in/1g0sxmo1' + ] + ], + 'delete' => [ + 143 + ] +]; + +print_r($woocommerce->post('webhooks/batch', $data)); +?> +``` + +```python +data = { + "create": [ + { + "name": "Round toe", + "topic": "coupon.created", + "delivery_url": "http://requestb.in/1g0sxmo1" + }, + { + "name": "Customer deleted", + "topic": "customer.deleted", + "delivery_url": "http://requestb.in/1g0sxmo1" + } + ], + "delete": [ + 143 + ] +} + +print(wcapi.post("webhooks/batch", data).json()) +``` + +```ruby +data = { + create: [ + { + name: "Round toe", + topic: "coupon.created", + delivery_url: "http://requestb.in/1g0sxmo1" + }, + { + name: "Customer deleted", + topic: "customer.deleted", + delivery_url: "http://requestb.in/1g0sxmo1" + } + ], + delete: [ + 143 + ] +} + +woocommerce.post("webhooks/batch", data).parsed_response +``` + +> JSON response example: + +```json +{ + "create": [ + { + "id": 146, + "name": "Coupon created", + "status": "active", + "topic": "coupon.created", + "resource": "coupon", + "event": "created", + "hooks": [ + "woocommerce_process_shop_coupon_meta", + "woocommerce_api_create_coupon" + ], + "delivery_url": "http://requestb.in/1g0sxmo1", + "date_created": "2016-05-24T22:56:26", + "date_modified": "2016-05-24T22:56:26", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/webhooks/146" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/webhooks" + } + ] + } + }, + { + "id": 147, + "name": "Customer deleted", + "status": "active", + "topic": "customer.deleted", + "resource": "customer", + "event": "deleted", + "hooks": [ + "delete_user" + ], + "delivery_url": "http://requestb.in/1g0sxmo1", + "date_created": "2016-05-24T22:56:30", + "date_modified": "2016-05-24T22:56:30", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/webhooks/147" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/webhooks" + } + ] + } + } + ], + "delete": [ + { + "id": 143, + "name": "Webhook created on May 24, 2016 @ 03:20 AM", + "status": "active", + "topic": "customer.created", + "resource": "customer", + "event": "created", + "hooks": [ + "user_register", + "woocommerce_created_customer", + "woocommerce_api_create_customer" + ], + "delivery_url": "http://requestb.in/1g0sxmo1", + "date_created": "2016-05-15T20:17:52", + "date_modified": "2016-05-15T20:17:52", + "_links": { + "self": [ + { + "href": "https://woo.dev/wp-json/wc/v1/webhooks/143" + } + ], + "collection": [ + { + "href": "https://woo.dev/wp-json/wc/v1/webhooks" + } + ] + } + } + ] +} +``` + +## Retrieve webhook delivery ## + +This API lets you retrieve and view a specific webhook delivery. + +### HTTP request ### + +
+
+ GET +
/wp-json/wc/v1/webhooks/<id>/deliveries/<delivery_id>
+
+
+ +```shell +curl https://example.com/wp-json/wc/v1/webhooks/142/deliveries/54 \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('webhooks/142/deliveries/54', function(err, data, res) { + console.log(res); +}); +``` + +```php +get('webhooks/142/deliveries/54')); ?> +``` + +```python +print(wcapi.get("webhooks/142/deliveries/54").json()) +``` + +```ruby +woocommerce.get("webhooks/142/deliveries/54").parsed_response +``` + +> JSON response example: + +```json +{ + "id": 54, + "duration": "0.40888", + "summary": "HTTP 200 OK: ok", + "request_method": "POST", + "request_url": "http://requestb.in/1g0sxmo1", + "request_headers": { + "User-Agent": "WooCommerce/2.6.0 Hookshot (WordPress/4.5.2)", + "Content-Type": "application/json", + "X-WC-Webhook-Source": "http://example.com/", + "X-WC-Webhook-Topic": "order.updated", + "X-WC-Webhook-Resource": "order", + "X-WC-Webhook-Event": "updated", + "X-WC-Webhook-Signature": "J72iu7hL93aUt2dFnyOBoBypwbmP6nt6Aor33nnOHxU=", + "X-WC-Webhook-ID": 142, + "X-WC-Webhook-Delivery-ID": 54 + }, + "request_body": "{\"order\":{\"id\":118,\"order_number\":118,\"order_key\":\"wc_order_5728e9a347a2d\",\"created_at\":\"2016-05-03T18:10:00Z\",\"updated_at\":\"2016-05-16T03:30:30Z\",\"completed_at\":\"2016-05-16T03:29:19Z\",\"status\":\"completed\",\"currency\":\"BRL\",\"total\":\"14.00\",\"subtotal\":\"4.00\",\"total_line_items_quantity\":2,\"total_tax\":\"0.00\",\"total_shipping\":\"10.00\",\"cart_tax\":\"0.00\",\"shipping_tax\":\"0.00\",\"total_discount\":\"0.00\",\"shipping_methods\":\"Flat Rate\",\"payment_details\":{\"method_id\":\"bacs\",\"method_title\":\"Direct Bank Transfer\",\"paid\":true},\"billing_address\":{\"first_name\":\"John\",\"last_name\":\"Doe\",\"company\":\"\",\"address_1\":\"969 Market\",\"address_2\":\"\",\"city\":\"San Francisco\",\"state\":\"CA\",\"postcode\":\"94103\",\"country\":\"US\",\"email\":\"john.doe@claudiosmweb.com\",\"phone\":\"(555) 555-5555\"},\"shipping_address\":{\"first_name\":\"John\",\"last_name\":\"Doe\",\"company\":\"\",\"address_1\":\"969 Market\",\"address_2\":\"\",\"city\":\"San Francisco\",\"state\":\"CA\",\"postcode\":\"94103\",\"country\":\"US\"},\"note\":\"\",\"customer_ip\":\"127.0.0.1\",\"customer_user_agent\":\"curl/7.47.0\",\"customer_id\":0,\"view_order_url\":\"http://example.com/my-account/view-order/118\",\"line_items\":[{\"id\":8,\"subtotal\":\"4.00\",\"subtotal_tax\":\"0.00\",\"total\":\"4.00\",\"total_tax\":\"0.00\",\"price\":\"2.00\",\"quantity\":2,\"tax_class\":null,\"name\":\"Woo Single #2\",\"product_id\":99,\"sku\":\"12345\",\"meta\":[]}],\"shipping_lines\":[{\"id\":9,\"method_id\":\"flat_rate\",\"method_title\":\"Flat Rate\",\"total\":\"10.00\"}],\"tax_lines\":[],\"fee_lines\":[],\"coupon_lines\":[],\"is_vat_exempt\":false,\"customer\":{\"id\":0,\"email\":\"john.doe@claudiosmweb.com\",\"first_name\":\"John\",\"last_name\":\"Doe\",\"billing_address\":{\"first_name\":\"John\",\"last_name\":\"Doe\",\"company\":\"\",\"address_1\":\"969 Market\",\"address_2\":\"\",\"city\":\"San Francisco\",\"state\":\"CA\",\"postcode\":\"94103\",\"country\":\"US\",\"email\":\"john.doe@claudiosmweb.com\",\"phone\":\"(555) 555-5555\"},\"shipping_address\":{\"first_name\":\"John\",\"last_name\":\"Doe\",\"company\":\"\",\"address_1\":\"969 Market\",\"address_2\":\"\",\"city\":\"San Francisco\",\"state\":\"CA\",\"postcode\":\"94103\",\"country\":\"US\"}}}}", + "response_code": "200", + "response_message": "OK", + "response_headers": { + "connection": "close", + "server": "gunicorn/19.3.0", + "date": "Tue, 16 May 2016 03:30:31 GMT", + "content-type": "text/html; charset=utf-8", + "content-length": "2", + "sponsored-by": "https://www.runscope.com", + "via": "1.1 vegur" + }, + "response_body": "ok", + "date_created": "2016-05-16T03:30:31", + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/webhooks/142/deliveries/54" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/webhooks/142/deliveries" + } + ], + "up": [ + { + "href": "https://example.com/wp-json/wc/v1/webhooks/142" + } + ] + } +} +``` + + + +## List all webhook deliveries ## + +This API helps you to view all deliveries from a specific webhooks. + +### HTTP request ### + +
+
+ GET +
/wp-json/wc/v1/webhooks/<id>/deliveries
+
+
+ +```shell +curl https://example.com/wp-json/wc/v1/webhooks/142/deliveries \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('webhooks/142/deliveries', function(err, data, res) { + console.log(res); +}); +``` + +```php +get('webhooks/142/deliveries')); ?> +``` + +```python +print(wcapi.get("webhooks/142/deliveries").json()) +``` + +```ruby +woocommerce.get("webhooks/142/deliveries").parsed_response +``` + +> JSON response example: + +```json +[ + { + "id": 54, + "duration": "0.40888", + "summary": "HTTP 200 OK: ok", + "request_method": "POST", + "request_url": "http://requestb.in/1g0sxmo1", + "request_headers": { + "User-Agent": "WooCommerce/2.6.0 Hookshot (WordPress/4.5.2)", + "Content-Type": "application/json", + "X-WC-Webhook-Source": "http://example.com/", + "X-WC-Webhook-Topic": "order.updated", + "X-WC-Webhook-Resource": "order", + "X-WC-Webhook-Event": "updated", + "X-WC-Webhook-Signature": "J72iu7hL93aUt2dFnyOBoBypwbmP6nt6Aor33nnOHxU=", + "X-WC-Webhook-ID": 142, + "X-WC-Webhook-Delivery-ID": 54 + }, + "request_body": "{\"order\":{\"id\":118,\"order_number\":118,\"order_key\":\"wc_order_5728e9a347a2d\",\"created_at\":\"2016-05-03T18:10:00Z\",\"updated_at\":\"2016-05-16T03:30:30Z\",\"completed_at\":\"2016-05-16T03:29:19Z\",\"status\":\"completed\",\"currency\":\"BRL\",\"total\":\"14.00\",\"subtotal\":\"4.00\",\"total_line_items_quantity\":2,\"total_tax\":\"0.00\",\"total_shipping\":\"10.00\",\"cart_tax\":\"0.00\",\"shipping_tax\":\"0.00\",\"total_discount\":\"0.00\",\"shipping_methods\":\"Flat Rate\",\"payment_details\":{\"method_id\":\"bacs\",\"method_title\":\"Direct Bank Transfer\",\"paid\":true},\"billing_address\":{\"first_name\":\"John\",\"last_name\":\"Doe\",\"company\":\"\",\"address_1\":\"969 Market\",\"address_2\":\"\",\"city\":\"San Francisco\",\"state\":\"CA\",\"postcode\":\"94103\",\"country\":\"US\",\"email\":\"john.doe@claudiosmweb.com\",\"phone\":\"(555) 555-5555\"},\"shipping_address\":{\"first_name\":\"John\",\"last_name\":\"Doe\",\"company\":\"\",\"address_1\":\"969 Market\",\"address_2\":\"\",\"city\":\"San Francisco\",\"state\":\"CA\",\"postcode\":\"94103\",\"country\":\"US\"},\"note\":\"\",\"customer_ip\":\"127.0.0.1\",\"customer_user_agent\":\"curl/7.47.0\",\"customer_id\":0,\"view_order_url\":\"http://example.com/my-account/view-order/118\",\"line_items\":[{\"id\":8,\"subtotal\":\"4.00\",\"subtotal_tax\":\"0.00\",\"total\":\"4.00\",\"total_tax\":\"0.00\",\"price\":\"2.00\",\"quantity\":2,\"tax_class\":null,\"name\":\"Woo Single #2\",\"product_id\":99,\"sku\":\"12345\",\"meta\":[]}],\"shipping_lines\":[{\"id\":9,\"method_id\":\"flat_rate\",\"method_title\":\"Flat Rate\",\"total\":\"10.00\"}],\"tax_lines\":[],\"fee_lines\":[],\"coupon_lines\":[],\"is_vat_exempt\":false,\"customer\":{\"id\":0,\"email\":\"john.doe@claudiosmweb.com\",\"first_name\":\"John\",\"last_name\":\"Doe\",\"billing_address\":{\"first_name\":\"John\",\"last_name\":\"Doe\",\"company\":\"\",\"address_1\":\"969 Market\",\"address_2\":\"\",\"city\":\"San Francisco\",\"state\":\"CA\",\"postcode\":\"94103\",\"country\":\"US\",\"email\":\"john.doe@claudiosmweb.com\",\"phone\":\"(555) 555-5555\"},\"shipping_address\":{\"first_name\":\"John\",\"last_name\":\"Doe\",\"company\":\"\",\"address_1\":\"969 Market\",\"address_2\":\"\",\"city\":\"San Francisco\",\"state\":\"CA\",\"postcode\":\"94103\",\"country\":\"US\"}}}}", + "response_code": "200", + "response_message": "OK", + "response_headers": { + "connection": "close", + "server": "gunicorn/19.3.0", + "date": "Tue, 16 May 2016 03:30:31 GMT", + "content-type": "text/html; charset=utf-8", + "content-length": "2", + "sponsored-by": "https://www.runscope.com", + "via": "1.1 vegur" + }, + "response_body": "ok", + "date_created": "2016-05-16T03:30:31", + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/webhooks/142/deliveries/54" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/webhooks/142/deliveries" + } + ], + "up": [ + { + "href": "https://example.com/wp-json/wc/v1/webhooks/142" + } + ] + } + }, + { + "id": 53, + "duration": "0.7615", + "summary": "HTTP 200 OK: ok", + "request_method": "POST", + "request_url": "http://requestb.in/1g0sxmo1", + "request_headers": { + "User-Agent": "WooCommerce/2.6.0 Hookshot (WordPress/4.5.2)", + "Content-Type": "application/json", + "X-WC-Webhook-Source": "http://example.com/", + "X-WC-Webhook-Topic": "order.updated", + "X-WC-Webhook-Resource": "order", + "X-WC-Webhook-Event": "updated", + "X-WC-Webhook-Signature": "Z996ccyueeoqdXZFq2ND2ETpsPGrXmWKj+yvQ0c2N1w=", + "X-WC-Webhook-ID": 142, + "X-WC-Webhook-Delivery-ID": 53 + }, + "request_body": "{\"order\":{\"id\":118,\"order_number\":118,\"order_key\":\"wc_order_5728e9a347a2d\",\"created_at\":\"2016-05-03T18:10:00Z\",\"updated_at\":\"2016-05-16T03:29:13Z\",\"completed_at\":\"2016-05-16T03:29:19Z\",\"status\":\"completed\",\"currency\":\"BRL\",\"total\":\"14.00\",\"subtotal\":\"4.00\",\"total_line_items_quantity\":2,\"total_tax\":\"0.00\",\"total_shipping\":\"10.00\",\"cart_tax\":\"0.00\",\"shipping_tax\":\"0.00\",\"total_discount\":\"0.00\",\"shipping_methods\":\"Flat Rate\",\"payment_details\":{\"method_id\":\"bacs\",\"method_title\":\"Direct Bank Transfer\",\"paid\":true},\"billing_address\":{\"first_name\":\"John\",\"last_name\":\"Doe\",\"company\":\"\",\"address_1\":\"969 Market\",\"address_2\":\"\",\"city\":\"San Francisco\",\"state\":\"CA\",\"postcode\":\"94103\",\"country\":\"US\",\"email\":\"john.doe@claudiosmweb.com\",\"phone\":\"(555) 555-5555\"},\"shipping_address\":{\"first_name\":\"John\",\"last_name\":\"Doe\",\"company\":\"\",\"address_1\":\"969 Market\",\"address_2\":\"\",\"city\":\"San Francisco\",\"state\":\"CA\",\"postcode\":\"94103\",\"country\":\"US\"},\"note\":\"\",\"customer_ip\":\"127.0.0.1\",\"customer_user_agent\":\"curl/7.47.0\",\"customer_id\":0,\"view_order_url\":\"http://example.com/my-account/view-order/118\",\"line_items\":[{\"id\":8,\"subtotal\":\"4.00\",\"subtotal_tax\":\"0.00\",\"total\":\"4.00\",\"total_tax\":\"0.00\",\"price\":\"2.00\",\"quantity\":2,\"tax_class\":null,\"name\":\"Woo Single #2\",\"product_id\":99,\"sku\":\"12345\",\"meta\":[]}],\"shipping_lines\":[{\"id\":9,\"method_id\":\"flat_rate\",\"method_title\":\"Flat Rate\",\"total\":\"10.00\"}],\"tax_lines\":[],\"fee_lines\":[],\"coupon_lines\":[],\"is_vat_exempt\":false,\"customer\":{\"id\":0,\"email\":\"john.doe@claudiosmweb.com\",\"first_name\":\"John\",\"last_name\":\"Doe\",\"billing_address\":{\"first_name\":\"John\",\"last_name\":\"Doe\",\"company\":\"\",\"address_1\":\"969 Market\",\"address_2\":\"\",\"city\":\"San Francisco\",\"state\":\"CA\",\"postcode\":\"94103\",\"country\":\"US\",\"email\":\"john.doe@claudiosmweb.com\",\"phone\":\"(555) 555-5555\"},\"shipping_address\":{\"first_name\":\"John\",\"last_name\":\"Doe\",\"company\":\"\",\"address_1\":\"969 Market\",\"address_2\":\"\",\"city\":\"San Francisco\",\"state\":\"CA\",\"postcode\":\"94103\",\"country\":\"US\"}}}}", + "response_code": "200", + "response_message": "OK", + "response_headers": { + "connection": "close", + "server": "gunicorn/19.3.0", + "date": "Tue, 16 May 2016 03:29:20 GMT", + "content-type": "text/html; charset=utf-8", + "content-length": "2", + "sponsored-by": "https://www.runscope.com", + "via": "1.1 vegur" + }, + "response_body": "ok", + "date_created": "2016-05-16T03:29:19", + "_links": { + "self": [ + { + "href": "https://example.com/wp-json/wc/v1/webhooks/142/deliveries/53" + } + ], + "collection": [ + { + "href": "https://example.com/wp-json/wc/v1/webhooks/142/deliveries" + } + ], + "up": [ + { + "href": "https://example.com/wp-json/wc/v1/webhooks/142" + } + ] + } + } +] +``` diff --git a/source/index.md b/source/index.md index 70f23b1e..bc8e6c9c 100644 --- a/source/index.md +++ b/source/index.md @@ -1,5 +1,5 @@ --- -title: WooCommerce REST API Documentation v3 +title: WooCommerce REST API Documentation - WP REST API v1 language_tabs: - shell: cURL @@ -12,29 +12,29 @@ toc_footers: - Contributing to WC REST API Docs - REST API Source on GitHub - REST API Issues - - WooCommerce Documentation + - WooCommerce Documentation - WooCommerce Repository - Documentation Powered by Slate includes: - - v3/introduction - - v3/index - - v3/coupons - - v3/customers - - v3/orders - - v3/order-notes - - v3/order-refunds - - v3/products - - v3/product-attributes - - v3/product-attribute-terms - - v3/product-categories - - v3/product-shipping-classes - - v3/product-tags - - v3/reports - - v3/taxes - - v3/tax-classes - - v3/webhooks - - v3/authentication-endpoint + - wp-api-v1/introduction + - wp-api-v1/authentication + - wp-api-v1/index + - wp-api-v1/coupons + - wp-api-v1/customers + - wp-api-v1/orders + - wp-api-v1/order-notes + - wp-api-v1/order-refunds + - wp-api-v1/products + - wp-api-v1/product-attributes + - wp-api-v1/product-attribute-terms + - wp-api-v1/product-categories + - wp-api-v1/product-shipping-classes + - wp-api-v1/product-tags + - wp-api-v1/reports + - wp-api-v1/taxes + - wp-api-v1/tax-classes + - wp-api-v1/webhooks -search: true +search: false --- diff --git a/source/javascripts/app/_toc.js b/source/javascripts/app/_toc.js index d84bf8e1..bf1d77fa 100644 --- a/source/javascripts/app/_toc.js +++ b/source/javascripts/app/_toc.js @@ -18,7 +18,7 @@ hideEffectSpeed: 180, ignoreSelector: '.toc-ignore', highlightOffset: 60, - scrollTo: -1, + scrollTo: 0 < $("body.has-warning").length ? 30 : -1, scrollHistory: true, hashGenerator: function (text, element) { return element.prop('id'); @@ -47,4 +47,3 @@ $(animate); })(window); - diff --git a/source/layouts/layout.erb b/source/layouts/layout.erb index d6af4729..34b9d403 100644 --- a/source/layouts/layout.erb +++ b/source/layouts/layout.erb @@ -48,7 +48,9 @@ under the License.
- <%= image_tag "logo.png" %> + + <%= image_tag "logo.png" %> + <% if language_tabs %>
<% language_tabs.each do |lang| %> diff --git a/source/stylesheets/_syntax.scss.erb b/source/stylesheets/_syntax.scss.erb index dfeb0c15..5a300ce6 100644 --- a/source/stylesheets/_syntax.scss.erb +++ b/source/stylesheets/_syntax.scss.erb @@ -22,6 +22,6 @@ under the License. color: #909090; } -.highlight, .highlight .w { +.highlight code, .highlight .w { background-color: $code-bg; -} \ No newline at end of file +} diff --git a/source/stylesheets/_variables.scss b/source/stylesheets/_variables.scss index e8f4c2dc..857a1466 100644 --- a/source/stylesheets/_variables.scss +++ b/source/stylesheets/_variables.scss @@ -23,28 +23,27 @@ under the License. // BACKGROUND COLORS //////////////////// -$nav-bg: #393939; +$nav-bg: #f7f7f7; $examples-bg: #393939; $code-bg: #292929; -$code-annotation-bg: #1c1c1c; -$nav-subitem-bg: #262626; -$nav-active-bg: #2467af; +$nav-subitem-bg: #f7f7f7; +$nav-active-bg: #9B5C8F; $lang-select-border: #000; $lang-select-bg: #222; $lang-select-active-bg: $examples-bg; // feel free to change this to blue or something $lang-select-pressed-bg: #111; // color of language tab bg when mouse is pressed -$main-bg: #eaf2f6; -$aside-notice-bg: #8fbcd4; -$aside-warning-bg: #c97a7e; -$aside-success-bg: #6ac174; +$main-bg: #ffffff; +$aside-notice-bg: #9B5C8F; +$aside-warning-bg: #ca4949; +$aside-success-bg: #38a845; $search-notice-bg: #c97a7e; -$link-color: #255a8c; +$link-color: #804877; // TEXT COLORS //////////////////// $main-text: #333; // main content text color -$nav-text: #fff; +$nav-text: #3c3c3c; $nav-active-text: #fff; $lang-select-text: #fff; // color of unselected language tab text $lang-select-active-text: #fff; // color of selected language tab text @@ -57,10 +56,8 @@ $nav-width: 230px; // width of the navbar $examples-width: 50%; // portion of the screen taken up by code examples $logo-margin: 20px; // margin between nav items and logo, ignored if search is active $main-padding: 28px; // padding to left and right of content & examples -$nav-padding: 15px; // padding to left and right of navbar +$nav-padding: 20px; // padding to left and right of navbar $nav-v-padding: 10px; // padding used vertically around search boxes and results -$nav-indent: 10px; // extra padding for ToC subitems -$code-annotation-padding: 13px; // padding inside code annotations $h1-margin-bottom: 21px; // padding under the largest header tags $tablet-width: 930px; // min width before reverting to tablet size $phone-width: $tablet-width - $nav-width; // min width before reverting to mobile size @@ -87,7 +84,7 @@ $phone-width: $tablet-width - $nav-width; // min width before reverting to mobil // OTHER //////////////////// -$nav-active-shadow: #000; +$nav-active-shadow: #f7f7f7; $nav-footer-border-color: #666; $nav-embossed-border-top: #000; $nav-embossed-border-bottom: #939393; diff --git a/source/stylesheets/screen.css.scss b/source/stylesheets/screen.css.scss index b146c9fe..1dfb55af 100644 --- a/source/stylesheets/screen.css.scss +++ b/source/stylesheets/screen.css.scss @@ -12,7 +12,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT @@ -26,15 +26,15 @@ under the License. //////////////////////////////////////////////////////////////////////////////// html, body { - color: $main-text; - padding: 0; - margin: 0; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; - @extend %default-font; - background-color: $main-bg; - height: 100%; - -webkit-text-size-adjust: none; /* Never autoresize text */ + color: $main-text; + padding: 0; + margin: 0; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + @extend %default-font; + background-color: $main-bg; + height: 100%; + -webkit-text-size-adjust: none; /* Never autoresize text */ } //////////////////////////////////////////////////////////////////////////////// @@ -42,215 +42,165 @@ html, body { //////////////////////////////////////////////////////////////////////////////// #toc > ul > li > a > span { - float: right; - background-color: #2484FF; - border-radius: 40px; - width: 20px; -} - -@mixin embossed-bg { - background: - linear-gradient(to bottom, rgba(#000, 0.2), rgba(#000, 0) 8px), - linear-gradient(to top, rgba(#000, 0.2), rgba(#000, 0) 8px), - linear-gradient(to bottom, rgba($nav-embossed-border-top, 1), rgba($nav-embossed-border-top, 0) 1.5px), - linear-gradient(to top, rgba($nav-embossed-border-bottom, 1), rgba($nav-embossed-border-bottom, 0) 1.5px), - $nav-subitem-bg; + float: right; + background-color: #2484FF; + border-radius: 40px; + width: 20px; } .tocify-wrapper { - transition: left 0.3s ease-in-out; - - overflow-y: auto; - overflow-x: hidden; - position: fixed; - z-index: 30; - top: 0; - left: 0; - bottom: 0; - width: $nav-width; - background-color: $nav-bg; - font-size: 13px; - font-weight: bold; - - // language selector for mobile devices - .lang-selector { - display: none; - a { - padding-top: 0.5em; - padding-bottom: 0.5em; - } - } - - // This is the logo at the top of the ToC - &>img { - display: block; - } - - &>.search { - position: relative; - - input { - background: $nav-bg; - border-width: 0 0 1px 0; - border-color: $search-box-border-color; - padding: 6px 0 6px 20px; - box-sizing: border-box; - margin: $nav-v-padding $nav-padding; - width: $nav-width - 30; - outline: none; - color: $nav-text; - border-radius: 0; /* ios has a default border radius */ - } - - &:before { - position: absolute; - top: 17px; - left: $nav-padding; - color: $nav-text; - @extend %icon-search; - } - } - - img+.tocify { - margin-top: $logo-margin; - } - - .search-results { - margin-top: 0; - box-sizing: border-box; - height: 0; - overflow-y: auto; - overflow-x: hidden; - transition-property: height, margin; - transition-duration: 180ms; - transition-timing-function: ease-in-out; - &.visible { - height: 30%; - margin-bottom: 1em; - } - - @include embossed-bg; - - li { - margin: 1em $nav-padding; - line-height: 1; - } - - a { - color: $nav-text; - text-decoration: none; - - &:hover { - text-decoration: underline; - } - } - } - - - .tocify-item>a, .toc-footer li { - padding: 0 $nav-padding 0 $nav-padding; - display: block; - overflow-x: hidden; - white-space: nowrap; - text-overflow: ellipsis; - } - - // The Table of Contents is composed of multiple nested - // unordered lists. These styles remove the default - // styling of an unordered list because it is ugly. - ul, li { - list-style: none; - margin: 0; - padding: 0; - line-height: 28px; - } - - li { - color: $nav-text; - transition-property: background; - transition-timing-function: linear; - transition-duration: 230ms; - } - - // This is the currently selected ToC entry - .tocify-focus { - box-shadow: 0px 1px 0px $nav-active-shadow; - background-color: $nav-active-bg; - color: $nav-active-text; - } - - // Subheaders are the submenus that slide open - // in the table of contents. - .tocify-subheader { - display: none; // tocify will override this when needed - background-color: $nav-subitem-bg; - font-weight: 500; - .tocify-item>a { - padding-left: $nav-padding + $nav-indent; - font-size: 12px; - } - - // for embossed look: - @include embossed-bg; - &>li:last-child { - box-shadow: none; // otherwise it'll overflow out of the subheader - } - } - - .toc-footer { - padding: 1em 0; - margin-top: 1em; - border-top: 1px dashed $nav-footer-border-color; - - li,a { - color: $nav-text; - text-decoration: none; - } - - a:hover { - text-decoration: underline; - } - - li { - font-size: 0.8em; - line-height: 1.7; - text-decoration: none; - } - } + transition: left 0.3s ease-in-out; + + overflow-y: auto; + overflow-x: hidden; + position: fixed; + z-index: 30; + top: 0; + left: 0; + bottom: 0; + width: $nav-width; + background-color: $nav-bg; + font-size: 13px; + font-weight: bold; + border-right: 1px solid #ddd; + + // language selector for mobile devices + .lang-selector { + display: none; + a { + padding-top: 0.5em; + padding-bottom: 0.5em; + } + } + + // This is the logo at the top of the ToC + .logo-wrapper { + padding: 10px 20px; + margin: 0; + display: block; + border-bottom: 1px solid #ddd; + + img { + display: block; + width: 100%; + } + } + + img+.tocify { + margin-top: $logo-margin; + } + + .tocify-item>a, .toc-footer li { + padding: 10px $nav-padding; + line-height: 1; + display: block; + overflow-x: hidden; + white-space: nowrap; + text-overflow: ellipsis; + } + + // The Table of Contents is composed of multiple nested + // unordered lists. These styles remove the default + // styling of an unordered list because it is ugly. + ul, li { + list-style: none; + margin: 0; + padding: 0; + line-height: 28px; + } + + li { + color: $nav-text; + transition-property: background; + transition-timing-function: linear; + transition-duration: 230ms; + } + + a:hover { + background: #eee; + } + + // This is the currently selected ToC entry + .tocify-focus { + //box-shadow: 0px 1px 0px $nav-active-shadow; + background-color: $nav-active-bg; + color: $nav-active-text; + a:hover { + text-decoration: none; + background-color: $nav-active-bg; + } + } + + // Subheaders are the submenus that slide open + // in the table of contents. + .tocify-subheader { + display: none; // tocify will override this when needed + background-color: $nav-subitem-bg; + font-weight: 500; + + .tocify-item>a { + padding-left: $nav-padding + 10; + font-size: 12px; + } + + &>li:last-child { + box-shadow: none; // otherwise it'll overflow out of the subheader + } + } + + .toc-footer { + padding: 10px 0; + margin-top: 10px; + border-top: 1px solid #ddd; + + li,a { + color: $nav-text; + text-decoration: none; + } + + a:hover { + text-decoration: underline; + } + + li { + font-size: 0.8em; + text-decoration: none; + } + } } // button to show navigation on mobile devices #nav-button { - span { - display: block; - $side-pad: $main-padding / 2 - 8px; - padding: $side-pad $side-pad $side-pad; - background-color: rgba($main-bg, 0.7); - transform-origin: 0 0; - transform: rotate(-90deg) translate(-100%, 0); - border-radius: 0 0 0 5px; - } - padding: 0 1.5em 5em 0; // increase touch size area - display: none; - position: fixed; - top: 0; - left: 0; - z-index: 100; - color: #000; - text-decoration: none; - font-weight: bold; - opacity: 0.7; - line-height: 16px; - img { - height: 16px; - vertical-align: bottom; - } - - transition: left 0.3s ease-in-out; - - &:hover { opacity: 1; } - &.open {left: $nav-width} + span { + display: block; + $side-pad: $main-padding / 2 - 8px; + padding: $side-pad $side-pad $side-pad; + background-color: rgba($main-bg, 0.7); + transform-origin: 0 0; + transform: rotate(-90deg) translate(-100%, 0); + border-radius: 0 0 0 5px; + } + padding: 0 1.5em 5em 0; // increase touch size area + display: none; + position: fixed; + top: 0; + left: 0; + z-index: 100; + color: #000; + text-decoration: none; + font-weight: bold; + opacity: 0.7; + line-height: 16px; + img { + height: 16px; + vertical-align: bottom; + } + + transition: left 0.3s ease-in-out; + + &:hover { opacity: 1; } + &.open {left: $nav-width} } @@ -259,64 +209,67 @@ html, body { //////////////////////////////////////////////////////////////////////////////// .page-wrapper { - margin-left: $nav-width; - position: relative; - z-index: 10; - background-color: $main-bg; - min-height: 100%; - - padding-bottom: 1px; // prevent margin overflow - - // The dark box is what gives the code samples their dark background. - // It sits essentially under the actual content block, which has a - // transparent background. - // I know, it's hackish, but it's the simplist way to make the left - // half of the content always this background color. - .dark-box { - width: $examples-width; - background-color: $examples-bg; - position: absolute; - right: 0; - top: 0; - bottom: 0; - } - - .lang-selector { - position: fixed; - z-index: 50; - border-bottom: 5px solid $lang-select-active-bg; - } + margin-left: $nav-width; + position: relative; + z-index: 10; + background-color: $main-bg; + min-height: 100%; + + padding-bottom: 1px; // prevent margin overflow + + // The dark box is what gives the code samples their dark background. + // It sits essentially under the actual content block, which has a + // transparent background. + // I know, it's hackish, but it's the simplist way to make the left + // half of the content always this background color. + .dark-box { + width: $examples-width; + background-color: $examples-bg; + position: absolute; + right: 0; + top: 0; + bottom: 0; + } + + .lang-selector { + position: fixed; + z-index: 50; + border-bottom: 5px solid $lang-select-active-bg; + } } .lang-selector { - background-color: $lang-select-bg; - width: 100%; - font-weight: bold; - a { - display: block; - float:left; - color: $lang-select-text; - text-decoration: none; - padding: 0 10px; - line-height: 30px; - outline: 0; - - &:active, &:focus { - background-color: $lang-select-pressed-bg; - color: $lang-select-pressed-text; - } - - &.active { - background-color: $lang-select-active-bg; - color: $lang-select-active-text; - } - } - - &:after { - content: ''; - clear: both; - display: block; - } + background-color: $lang-select-bg; + width: 100%; + font-weight: bold; + a { + display: block; + float:left; + color: $lang-select-text; + text-decoration: none; + padding: 10px 20px; + line-height: 40px; + outline: 0; + border-top: 4px solid $lang-select-bg;; + + &:active, &:focus, &:hover { + background-color: $lang-select-pressed-bg; + color: $lang-select-pressed-text; + border-top-color: #9B5C8F; + } + + &.active { + background-color: $lang-select-active-bg; + color: $lang-select-active-text; + border-top-color: #9B5C8F; + } + } + + &:after { + content: ''; + clear: both; + display: block; + } } //////////////////////////////////////////////////////////////////////////////// @@ -325,195 +278,202 @@ html, body { // This is all the stuff with the light background in the left half of the page .content { - // to place content above the dark box - position: relative; - z-index: 30; - - &:after { - content: ''; - display: block; - clear: both; - } - - &>h1, &>h2, &>h3, &>h4, &>h5, &>h6, &>p, &>table, &>ul, &>ol, &>aside, &>dl { - margin-right: $examples-width; - padding: 0 $main-padding; - box-sizing: border-box; - display: block; - @include text-shadow($main-embossed-text-shadow); - - @extend %left-col; - } - - &>ul, &>ol { - padding-left: $main-padding + 15px; - } - - // the div is the tocify hidden div for placeholding stuff - &>h1, &>h2, &>div { - clear:both; - } - - h1 { - @extend %header-font; - font-size: 30px; - padding-top: 0.5em; - padding-bottom: 0.5em; - border-bottom: 1px solid #ccc; - margin-bottom: $h1-margin-bottom; - margin-top: 2em; - border-top: 1px solid #ddd; - background-image: linear-gradient(to bottom, #fff, #f9f9f9); - } - - h1:first-child, div:first-child + h1 { - border-top-width: 0; - margin-top: 0; - } - - h2 { - @extend %header-font; - font-size: 20px; - margin-top: 4em; - margin-bottom: 0; - border-top: 1px solid #ccc; - padding-top: 1.2em; - padding-bottom: 1.2em; - background-image: linear-gradient(to bottom, rgba(#fff, 0.4), rgba(#fff, 0)); - } - - // h2s right after h1s should bump right up - // against the h1s. - h1 + h2, h1 + div + h2 { - margin-top: $h1-margin-bottom * -1; - border-top: none; - } - - h3, h4, h5, h6 { - @extend %header-font; - font-size: 15px; - margin-top: 2.5em; - margin-bottom: 0.8em; - } - - h4, h5, h6 { - font-size: 10px; - } - - hr { - margin: 2em 0; - border-top: 2px solid $examples-bg; - border-bottom: 2px solid $main-bg; - } - - table { - margin-bottom: 1em; - overflow: auto; - th,td { - text-align: left; - vertical-align: top; - line-height: 1.6; - } - - th { - padding: 5px 10px; - border-bottom: 1px solid #ccc; - vertical-align: bottom; - } - - td { - padding: 10px; - } - - tr:last-child { - border-bottom: 1px solid #ccc; - } - - tr:nth-child(odd)>td { - background-color: lighten($main-bg,4.2%); - } - - tr:nth-child(even)>td { - background-color: lighten($main-bg,2.4%); - } - } - - dt { - font-weight: bold; - } - - dd { - margin-left: 15px; - } - - p, li, dt, dd { - line-height: 1.6; - margin-top: 0; - } - - img { - max-width: 100%; - } - - code { - background-color: rgba(0,0,0,0.05); - padding: 3px; - border-radius: 3px; - @extend %break-words; - @extend %code-font; - } - - pre>code { - background-color: transparent; - padding: 0; - } - - aside { - padding-top: 1em; - padding-bottom: 1em; - @include text-shadow(0 1px 0 lighten($aside-notice-bg, 15%)); - margin-top: 1.5em; - margin-bottom: 1.5em; - background: $aside-notice-bg; - line-height: 1.6; - - &.warning { - background-color: $aside-warning-bg; - @include text-shadow(0 1px 0 lighten($aside-warning-bg, 15%)); - } - - &.success { - background-color: $aside-success-bg; - @include text-shadow(0 1px 0 lighten($aside-success-bg, 15%)); - } - } - - aside:before { - vertical-align: middle; - padding-right: 0.5em; - font-size: 14px; - } - - aside.notice:before { - @extend %icon-info-sign; - } - - aside.warning:before { - @extend %icon-exclamation-sign; - } - - aside.success:before { - @extend %icon-ok-sign; - } - - .search-highlight { - padding: 2px; - margin: -2px; - border-radius: 4px; - border: 1px solid #F7E633; - @include text-shadow(1px 1px 0 #666); - background: linear-gradient(to top left, #F7E633 0%, #F1D32F 100%); - } + // to place content above the dark box + position: relative; + z-index: 30; + padding-top: 40px; + + &:after { + content: ''; + display: block; + clear: both; + } + + &>h1, &>h2, &>h3, &>h4, &>h5, &>h6, &>p, &>table, &>ul, &>ol, &>aside, &>dl { + margin-right: $examples-width; + padding: 0 $main-padding; + box-sizing: border-box; + display: block; + @extend %left-col; + font-weight: normal; + } + + &>ul, &>ol { + padding-left: $main-padding + 15px; + } + + // the div is the tocify hidden div for placeholding stuff + &>h1, &>h2, &>div { + clear:both; + } + + h1 { + @extend %header-font; + font-size: 35px; + margin-top: 4em; + margin-bottom: 20px; + padding-top: 25px; + border-top: 1px solid #ddd; + } + + h1:first-child, div:first-child + h1 { + border-top-width: 0; + margin-top: 0; + border-top: 0; + } + + h2 { + @extend %header-font; + font-size: 25px; + margin-top: 40px; + padding-top: 25px; + margin-bottom: 20px; + } + + h4 { + font-weight: bold; + } + + // h2s right after h1s should bump right up + // against the h1s. + h1 + h2, h1 + div + h2 { + margin-top: $h1-margin-bottom * -1; + border-top: none; + } + + h3, h4, h5, h6 { + @extend %header-font; + font-size: 20px; + margin-top: 2.5em; + margin-bottom: 0.8em; + } + + h4, h5, h6 { + font-size: 15px; + } + + hr { + margin: 2em 0; + border-top: 2px solid $examples-bg; + border-bottom: 2px solid $main-bg; + } + + table { + margin-bottom: 1em; + overflow: auto; + th,td { + text-align: left; + vertical-align: top; + line-height: 1.6; + } + + th { + padding: 5px 10px; + border-bottom: 1px solid #ccc; + vertical-align: bottom; + } + + td { + padding: 10px; + } + + tr:last-child { + border-bottom: 1px solid #ccc; + } + + tr:nth-child(odd)>td { + background-color: lighten($main-bg,4.2%); + } + + tr:nth-child(even)>td { + background-color: lighten($main-bg,2.4%); + } + } + + dt { + font-weight: bold; + } + + dd { + margin-left: 15px; + } + + p, li, dt, dd { + line-height: 1.6; + margin-top: 0; + } + + img { + max-width: 100%; + } + + code { + background-color: rgba(0,0,0,0.05); + padding: 3px; + border-radius: 3px; + @extend %break-words; + @extend %code-font; + } + + pre>code { + background-color: transparent; + padding: 0; + } + + aside { + padding-top: 1em; + padding-bottom: 1em; + @include text-shadow(0 1px 0 darken($aside-notice-bg, 15%)); + margin-top: 1.5em; + margin-bottom: 1.5em; + background: $aside-notice-bg; + line-height: 1.6; + color: lighten($aside-notice-bg, 80%); + + a { + color: lighten($aside-notice-bg, 80%); + text-decoration: underline; + } + + &.warning { + background-color: $aside-warning-bg; + @include text-shadow(0 1px 0 darken($aside-warning-bg, 15%)); + color: lighten($aside-notice-bg, 80%); + } + + &.success { + background-color: $aside-success-bg; + @include text-shadow(0 1px 0 darken($aside-success-bg, 15%)); + color: lighten($aside-notice-bg, 80%); + } + } + + aside:before { + vertical-align: middle; + padding-right: 0.5em; + font-size: 14px; + } + + aside.notice:before { + @extend %icon-info-sign; + } + + aside.warning:before { + @extend %icon-exclamation-sign; + } + + aside.success:before { + @extend %icon-ok-sign; + } + + .search-highlight { + padding: 2px; + margin: -2px; + border-radius: 4px; + border: 1px solid #F7E633; + @include text-shadow(1px 1px 0 #666); + background: linear-gradient(to top left, #F7E633 0%, #F1D32F 100%); + } } //////////////////////////////////////////////////////////////////////////////// @@ -522,45 +482,38 @@ html, body { // This is all the stuff that appears in the right half of the page .content { - pre, blockquote { - background-color: $code-bg; - color: #fff; - - padding: 2em $main-padding; - margin: 0; - width: $examples-width; - - float:right; - clear:right; - - box-sizing: border-box; - @include text-shadow(0px 1px 2px rgba(0,0,0,0.4)); - - @extend %right-col; - - &>p { margin: 0; } - - a { - color: #fff; - text-decoration: none; - border-bottom: dashed 1px #ccc; - } - } - - pre { - @extend %code-font; - } - - blockquote { - &>p { - background-color: $code-annotation-bg; - border-radius: 5px; - padding: $code-annotation-padding; - color: #ccc; - border-top: 1px solid #000; - border-bottom: 1px solid #404040; - } - } + pre, blockquote { + color: #fff; + margin: 0 0 20px; + @extend %right-col; + box-sizing: border-box; + float:right; + clear:right; + width: $examples-width; + padding: 0 20px; + white-space: normal; + + &>p { margin: 0; } + + a { + color: #fff; + text-decoration: none; + border-bottom: dashed 1px #ccc; + } + } + + pre { + @extend %code-font; + background: $examples-bg; + white-space: pre-wrap; + + code { + padding: 20px; + border-radius: 5px; + display: block; + background-color: $code-bg; + } + } } //////////////////////////////////////////////////////////////////////////////// @@ -570,137 +523,137 @@ html, body { // There are also a couple styles disperesed @media (max-width: $tablet-width) { - .tocify-wrapper { - left: -$nav-width; - - &.open { - left: 0; - } - } - - .page-wrapper { - margin-left: 0; - } - - #nav-button { - display: block; - } - - .tocify-wrapper .tocify-item > a { - padding-top: 0.3em; - padding-bottom: 0.3em; - } + .tocify-wrapper { + left: -$nav-width; + + &.open { + left: 0; + } + } + + .page-wrapper { + margin-left: 0; + } + + #nav-button { + display: block; + } + + .tocify-wrapper .tocify-item > a { + padding-top: 0.3em; + padding-bottom: 0.3em; + } } @media (max-width: $phone-width) { - .dark-box { - display: none; - } - - %left-col { - margin-right: 0; - } - - .tocify-wrapper .lang-selector { - display: block; - } - - .page-wrapper .lang-selector { - display: none; - } - - %right-col { - width: auto; - float: none; - } - - %right-col + %left-col { - margin-top: $main-padding; - } + .dark-box { + display: none; + } + + %left-col { + margin-right: 0; + } + + .tocify-wrapper .lang-selector { + display: block; + } + + .page-wrapper .lang-selector { + display: none; + } + + %right-col { + width: auto; + float: none; + } + + %right-col + %left-col { + margin-top: $main-padding; + } } //////////////////////////////////////////////////////////////////////////////// // CUSTOM CONTENT STYLES //////////////////////////////////////////////////////////////////////////////// .content { - a { - color: $link-color; - text-decoration: none; - - &:hover { - text-decoration: underline; - } - } + a { + color: $link-color; + text-decoration: none; + + &:hover { + text-decoration: underline; + } + } } /////////////////////////////////////////////////////////////////////////////////// // API ENDPOINT //////////////////////////////////////////////////////////////////////////////// .api-endpoint { - margin-right: $examples-width; - padding: 0 $main-padding; - @include box-sizing(border-box); - display: block; - @extend %left-col; - - .endpoint-data { - background-color: $code-bg; - color: #fff; - border-radius: 5px; - border-top: 1px solid #000; - border-bottom: 1px solid #404040; - @include text-shadow(0px 1px 2px rgba(0,0,0,0.4)); - margin: 15px 0; - height: 38px; - - i { - display: inline-block; - margin: 5px; - padding: 4px 12px; - line-height: 20px; - } - - h6 { - display: inline-block; - margin: 0; - @extend %code-font; - text-transform: lowercase; - font-weight: 400; - } - } + margin-right: $examples-width; + padding: 0 $main-padding; + @include box-sizing(border-box); + display: block; + @extend %left-col; + + .endpoint-data { + background-color: $code-bg; + color: #fff; + border-radius: 5px; + border-top: 1px solid #000; + border-bottom: 1px solid #404040; + @include text-shadow(0px 1px 2px rgba(0,0,0,0.4)); + margin: 15px 0; + height: 38px; + + i { + display: inline-block; + margin: 5px; + padding: 4px 12px; + line-height: 20px; + } + + h6 { + display: inline-block; + margin: 0; + @extend %code-font; + text-transform: lowercase; + font-weight: 400; + } + } } //////////////////////////////////////////////////////////////////////////////// // LABEL //////////////////////////////////////////////////////////////////////////////// .label { - border-radius: 2px; - text-transform: uppercase; - font-style: normal; - white-space: nowrap; + border-radius: 2px; + text-transform: uppercase; + font-style: normal; + white-space: nowrap; } .label-get { - background: #008000; + background: #008000; } .label-post, .label-put { - background: #4e92d7; + background: #4e92d7; } .label-delete { - background: #ca4949; + background: #ca4949; } .label-info { - background: #efefef; - color: #999; - float: right; - font-weight: 700; - font-size: 70%; - padding: 2px 4px; - margin-left: 5px; + background: #efefef; + color: #999; + float: right; + font-weight: 700; + font-size: 70%; + padding: 2px 4px; + margin-left: 5px; } //////////////////////////////////////////////////////////////////////////////// @@ -708,42 +661,39 @@ html, body { //////////////////////////////////////////////////////////////////////////////// body.has-warning { - margin-top: 30px; + margin-top: 33px; - .tocify-wrapper { - top: 30px; - } + .tocify-wrapper { + top: 33px; + } } #warning-top { - background-color: $aside-warning-bg; - @include text-shadow(0 1px 0 lighten($aside-warning-bg, 5%)); - position: fixed; - z-index: 99999; - top: 0; - left: 0; - right: 0; - text-align: center; - line-height: 2.5; - overflow: hidden; - box-shadow: 0 0 5px black; - font-weight: bold; - - a { - color: $link-color; - text-decoration: none; - - &:hover { - text-decoration: underline; - } - } - - .info:before { - @extend %icon-exclamation-sign; - vertical-align: middle; - padding-right: 0.5em; - font-size: 14px; - } + @include text-shadow(0 1px 0 lighten($aside-warning-bg, 5%)); + box-shadow: 0 0 5px black; + font-weight: bold; + left: 0; + line-height: 2.5; + overflow: hidden; + position: fixed; + right: 0; + text-align: center; + top: 0; + z-index: 99999; + background-color: $aside-warning-bg; + color: lighten($aside-notice-bg, 80%); + + a { + color: lighten($aside-notice-bg, 80%); + text-decoration: underline; + } + + .info:before { + @extend %icon-exclamation-sign; + font-size: 14px; + padding-right: 0.5em; + vertical-align: middle; + } } //////////////////////////////////////////////////////////////////////////////// @@ -751,10 +701,10 @@ body.has-warning { //////////////////////////////////////////////////////////////////////////////// .github-buttons { - padding-top: 10px; + padding-top: 10px; - iframe { - display: block; - margin-bottom: 5px; - } + iframe { + display: block; + margin-bottom: 5px; + } } diff --git a/source/v1.md b/source/v1.md index 37878335..a604b15c 100644 --- a/source/v1.md +++ b/source/v1.md @@ -5,7 +5,6 @@ language_tabs: - shell: cURL toc_footers: - - WC REST API Docs v2 - Contributing to WC REST API Docs - REST API Source on GitHub - REST API Issues @@ -16,7 +15,7 @@ toc_footers: includes: - v1/docs -search: true +search: false -warning: This documentation is for the v1 API which is now deprecated. Please use the v2 endpoint and read the v2 documentation. +warning: This documentation is for the WooCommerce API v1 which is now deprecated. Please use the latest REST API version. --- diff --git a/source/v2.md b/source/v2.md index d8a4ac76..34fa1427 100644 --- a/source/v2.md +++ b/source/v2.md @@ -26,5 +26,7 @@ includes: - v2/reports - v2/webhooks -search: true +search: false + +warning: This documentation is for the WooCommerce API v2 which is now deprecated. Please use the latest REST API version. --- diff --git a/source/v3.md b/source/v3.md new file mode 100644 index 00000000..fb4fe5cb --- /dev/null +++ b/source/v3.md @@ -0,0 +1,42 @@ +--- +title: WooCommerce REST API Documentation v3 + +language_tabs: + - shell: cURL + - javascript: Node.js + - php: PHP + - python: Python + - ruby: Ruby + +toc_footers: + - Contributing to WC REST API Docs + - REST API Source on GitHub + - REST API Issues + - WooCommerce Documentation + - WooCommerce Repository + - Documentation Powered by Slate + +includes: + - v3/introduction + - v3/index + - v3/coupons + - v3/customers + - v3/orders + - v3/order-notes + - v3/order-refunds + - v3/products + - v3/product-attributes + - v3/product-attribute-terms + - v3/product-categories + - v3/product-shipping-classes + - v3/product-tags + - v3/reports + - v3/taxes + - v3/tax-classes + - v3/webhooks + - v3/authentication-endpoint + +search: false + +warning: This documentation is for the WooCommerce API v3 API which is now deprecated. Please use the latest REST API version. +---