diff --git a/source/includes/v3/_authentication-endpoint.md b/source/includes/v3/_authentication-endpoint.md index ff9dd516..3ebf898d 100644 --- a/source/includes/v3/_authentication-endpoint.md +++ b/source/includes/v3/_authentication-endpoint.md @@ -1,47 +1,111 @@ # Authentication Endpoint # -Staring in WooCommerce 2.4 we introduced our Authentication Endpoint, where any app can easy allow users to generate API keys and send back automatically to the app. - -This makes integration with WooCommerce API much simpler, since the user only needs to access a URL, click in the "accept" button and will be redirected back to the app and the API keys are sent back in a POST request. +Starting in WooCommerce 2.4 we introduced an Authentication Endpoint, This can be used by any app to allow users to generate API keys. This makes integration with WooCommerce API simpler because the user only needs to access a URL and click "accept". After being redirected back to the app, the API keys will be sent in a POST request. The following image illustrates how it's done:  <aside class="warning"> - Note that this endpoint works exclusively for users to generate API keys and facilitate integration between the WooCommerce REST API and an application. In no way is this endpoint proposes to be used as login method for customers. + Note that this endpoint works exclusively for users to generate API keys and facilitate integration between the WooCommerce REST API and an application. In no way is this endpoint proposed to be used as login method for customers. </aside> ## URL parameters ## -| Paramenter | Type | Description | +| Parameter | Type | Description | | -------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `app_name` | string | Your app name <i class="label label-info">mandatory</i> | | `scope` | string | Level of access. Available: `read`, `write` and `read_write` <i class="label label-info">mandatory</i> | | `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 <i class="label label-info">mandatory</i> | -| `return_url` | string | URL that will be used for receive the user back in your app <i class="label label-info">mandatory</i> | -| `callback_url` | string | URL that will receive the generated API key. Important to note that this URL should be over **SSL** <i class="label label-info">mandatory</i> | +| `return_url` | string | URL the user will be redirected to after authentication <i class="label label-info">mandatory</i> | +| `callback_url` | string | URL that will receive the generated API key. Note: this URL should be over **HTTPS** <i class="label label-info">mandatory</i> | ## Creating Authentication Endpoint URL ## -You must use the `/wc-auth/v1/authorize` endpoint and pass the above parameters as query string. +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: -> Example of how do it in PHP: +```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 +<?php $store_url = 'http://example.com'; -$endpoint = '/wc-auth/v1/authorize'; -$params = array( - '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' -); -echo $store_url . $endpoint . '?' . http_build_query( $params ); +$endpoint = '/wc-auth/v1/authorize'; +$params = [ + 'app_name' => '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 the JSON posted with the API Keys +> Example of JSON posted with the API Keys ``` { @@ -53,14 +117,14 @@ echo $store_url . $endpoint . '?' . http_build_query( $params ); } ``` -Example of the screen that the user will access: +Example of the screen that the user will see:  ## Notes and Tips ## -- While redirecting the user using `return_url` 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 (`return_url`) to your app and also to save the API Keys in your `callback_url`. -- This 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');`. +- 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');`. - This authentication endpoint is used only to make easy integration with WooCommerce REST API. THIS NOT INTENDED TO BE USED AS A LOGIN ENDPOINT FOR CUSTOMERS! diff --git a/source/includes/v3/_coupons.md b/source/includes/v3/_coupons.md index 90ed849f..e642a5e0 100644 --- a/source/includes/v3/_coupons.md +++ b/source/includes/v3/_coupons.md @@ -1,6 +1,6 @@ # Coupons # -This section lists all API that can be used to create, edit or otherwise manipulate coupons. +This section lists all API endpoints that can be used to create, edit or otherwise manipulate coupons. ## Coupon Properties ## @@ -29,7 +29,7 @@ This section lists all API that can be used to create, edit or otherwise manipul | `customer_emails` | array | Array of email addresses that can use this coupon | | `description` | string | Coupon description | -## Create A Coupon ## +## Create a Coupon ## This API helps you to create a new coupon. @@ -50,7 +50,7 @@ curl -X POST https://example.com/wc-api/v3/coupons \ "coupon": { "code": "new-coupon", "type": "percent", - "amount": "10", + "amount": 10, "individual_use": true, "product_ids": [], "exclude_product_ids": [], @@ -75,7 +75,7 @@ var data = { coupon: { code: 'new-coupon', type: 'percent', - amount: '10', + amount: 10, individual_use: true, product_ids: [], exclude_product_ids: [], @@ -99,12 +99,41 @@ WooCommerce.post('coupons', data, function(err, data, res) { }); ``` +```php +<?php +$data = [ + 'coupon' => [ + 'code' => 'new-coupon', + 'type' => 'percent', + 'amount' => 10, + 'individual_use' => true, + 'product_ids' => [], + 'exclude_product_ids' => [], + 'usage_limit' => '', + 'usage_limit_per_user' => '', + 'limit_usage_to_x_items' => '', + 'expiry_date' => '', + 'enable_free_shipping' => false, + 'product_category_ids' => [], + 'exclude_product_category_ids' => [], + 'exclude_sale_items' => true, + 'minimum_amount' => '100.00', + 'maximum_amount' => '0.00', + 'customer_emails' => [], + 'description' => '' + ] +]; + +print_r($woocommerce->post('coupons', $data)); +?> +``` + ```python data = { "coupon": { "code": "new-coupon", "type": "percent", - "amount": "10", + "amount": 10, "individual_use": True, "product_ids": [], "exclude_product_ids": [], @@ -131,7 +160,7 @@ data = { coupon: { code: "new-coupon", type: "percent", - amount: "10", + amount: 10, individual_use: true, product_ids: [], exclude_product_ids: [], @@ -184,7 +213,7 @@ woocommerce.post("coupons", data).parsed_response } ``` -## View A Coupon ## +## View a Coupon ## This API lets you retrieve and view a specific coupon by ID or code. @@ -197,13 +226,6 @@ This API lets you retrieve and view a specific coupon by ID or code. </div> </div> -<div class="api-endpoint"> - <div class="endpoint-data"> - <i class="label label-get">GET</i> - <h6>/wc-api/v3/coupons/code/<code></h6> - </div> -</div> - ```shell curl https://example.com/wc-api/v3/coupons/529 \ -u consumer_key:consumer_secret @@ -215,6 +237,10 @@ WooCommerce.get('coupons/529', function(err, data, res) { }); ``` +```php +<?php print_r($woocommerce->get('coupons/529')); ?> +``` + ```python print(wcapi.get("coupons/529").json()) ``` @@ -254,7 +280,7 @@ woocommerce.get("coupons/529").parsed_response } ``` -## View List Of Coupons ## +## View List of Coupons ## This API helps you to view all the coupons. @@ -278,6 +304,10 @@ WooCommerce.get('coupons', function(err, data, res) { }); ``` +```php +<?php print_r($woocommerce->get('coupons')); ?> +``` + ```python print(wcapi.get("coupons").json()) ``` @@ -367,7 +397,7 @@ woocommerce.get("coupons").parsed_response } ``` -## Update A Coupon ## +## Update a Coupon ## This API lets you make changes to a coupon. @@ -386,7 +416,7 @@ curl -X PUT https://example.com/wc-api/v3/coupons/529 \ -H "Content-Type: application/json" \ -d '{ "coupon": { - "amount": "5" + "amount": 5 } }' ``` @@ -394,7 +424,7 @@ curl -X PUT https://example.com/wc-api/v3/coupons/529 \ ```javascript var data = { coupon: { - amount: '5' + amount: 5 } }; @@ -403,10 +433,22 @@ WooCommerce.put('coupons/529', data, function(err, data, res) { }); ``` +```php +<?php +$data = [ + 'coupon' => [ + 'amount' => 5 + ] +]; + +print_r($woocommerce->put('coupons/529', $data)); +?> +``` + ```python data = { "coupon": { - "amount": "5" + "amount": 5 } } @@ -416,7 +458,7 @@ print(wcapi.put("coupons/529", data).json()) ```ruby data = { coupon: { - amount: "5" + amount: 5 } } @@ -470,7 +512,7 @@ To update is necessary to send objects containing IDs and to create new not just </div> ```shell -curl -X PUT https://example.com/wc-api/v3/coupons/bulk \ +curl -X POST https://example.com/wc-api/v3/coupons/bulk \ -u consumer_key:consumer_secret \ -H "Content-Type: application/json" \ -d '{ @@ -496,24 +538,47 @@ var data = { coupons: [ { id: 529, - amount: "15.00" + amount: '15.00' }, { id: 527, - minimum_amount: "55.00" + minimum_amount: '55.00' }, { id: 526, - amount: "20.00" + amount: '20.00' } ] }; -WooCommerce.put('coupons/bulk', data, function(err, data, res) { +WooCommerce.post('coupons/bulk', data, function(err, data, res) { console.log(res); }); ``` +```php +<?php +$data = [ + 'coupons' => [ + [ + 'id' => 529, + 'amount' => '15.00' + ], + [ + 'id' => 527, + 'minimum_amount' => '55.00' + ], + [ + 'id' => 526, + 'amount': '20.00' + ] + ] +]; + +print_r($woocommerce->post('coupons/bulk', $data)); +?> +``` + ```python data = { "coupons": [ @@ -532,7 +597,7 @@ data = { ] } -print(wcapi.put("coupons/bulk", data).json()) +print(wcapi.post("coupons/bulk", data).json()) ``` ```ruby @@ -553,7 +618,7 @@ data = { ] } -woocommerce.put("coupons/bulk", data).parsed_response +woocommerce.post("coupons/bulk", data).parsed_response ``` > JSON response example: @@ -637,7 +702,7 @@ woocommerce.put("coupons/bulk", data).parsed_response } ``` -## Delete A Coupon ## +## Delete a Coupon ## This API helps you delete a coupon. @@ -661,12 +726,16 @@ WooCommerce.delete('coupons/529/?force=true', function(err, data, res) { }); ``` +```php +<?php print_r($woocommerce->delete('coupons/529', ['force' => true])); ?> +``` + ```python print(wcapi.delete("coupons/529?force=true").json()) ``` ```ruby -woocommerce.delete("coupons/529?force=true").parsed_response +woocommerce.delete("coupons/529", force: true).parsed_response ``` > JSON response example: @@ -707,6 +776,10 @@ WooCommerce.get('coupons/count', function(err, data, res) { }); ``` +```php +<?php print_r($woocommerce->get('coupons/count')); ?> +``` + ```python print(wcapi.get("coupons/count").json()) ``` diff --git a/source/includes/v3/_customers.md b/source/includes/v3/_customers.md index 1f143e8f..d09eea33 100644 --- a/source/includes/v3/_customers.md +++ b/source/includes/v3/_customers.md @@ -1,6 +1,6 @@ # Customers # -This section lists all API that can be used to create, edit or otherwise manipulate customers. +This section lists all API endpoints that can be used to create, edit or otherwise manipulate customers. ## Customers Properties ## @@ -51,7 +51,7 @@ This section lists all API that can be used to create, edit or otherwise manipul | `postcode` | string | Postal code | | `country` | string | ISO code of the country | -## Create A Customer ## +## Create a Customer ## This API helps you to create a new customer. @@ -141,6 +141,45 @@ WooCommerce.post('customers', data, function(err, data, res) { }); ``` +```php +<?php +$data = [ + 'customer' => [ + '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_r($woocommerce->post('customers', $data)); +?> +``` + ```python data = { "customer": { @@ -259,7 +298,7 @@ woocommerce.post("customers", data).parsed_response } ``` -## View A Customer ## +## View a Customer ## This API lets you retrieve and view a specific customer by ID or email. @@ -290,6 +329,10 @@ WooCommerce.get('customers/2', function(err, data, res) { }); ``` +```php +<?php print_r($woocommerce->get('customers/2')); ?> +``` + ```python print(wcapi.get("customers/2").json()) ``` @@ -342,7 +385,7 @@ woocommerce.get("customers/2").parsed_response } ``` -## View List Of Customers ## +## View List of Customers ## This API helps you to view all the customers. @@ -366,6 +409,10 @@ WooCommerce.get('customers', function(err, data, res) { }); ``` +```php +<?php print_r($woocommerce->get('customers')); ?> +``` + ```python print(wcapi.get("customers").json()) ``` @@ -463,7 +510,7 @@ woocommerce.get("customers").parsed_response | ------ | ------ | --------------------------------------------------- | | `role` | string | Customers by status. eg: `customer` or `subscriber` | -## Update A Customer ## +## Update a Customer ## This API lets you make changes to a customer. @@ -511,6 +558,24 @@ WooCommerce.put('customers/2', data, function(err, data, res) { }); ``` +```php +<?php +$data = [ + 'customer' => [ + 'first_name' => 'James', + 'billing_address' => [ + 'first_name' => 'James' + ], + 'shipping_address' => [ + 'first_name' => 'James' + ] + ] +]; + +print_r($woocommerce->put('customers/2', $data)); +?> +``` + ```python data = { "customer": { @@ -603,7 +668,7 @@ To update is necessary to send objects containing IDs and to create new not just </div> ```shell -curl -X PUT https://example.com/wc-api/v3/customers/bulk \ +curl -X POST https://example.com/wc-api/v3/customers/bulk \ -u consumer_key:consumer_secret \ -H "Content-Type: application/json" \ -d '{ @@ -676,33 +741,33 @@ curl -X PUT https://example.com/wc-api/v3/customers/bulk \ var data = { customers: [ { - email: "john.doe2@example.com", - first_name: "John", - last_name: "Doe", - username: "john.doe2", + 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" + 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" + first_name: 'John', + last_name: 'Doe', + company: '', + address_1: '969 Market', + address_2: '', + city: 'San Francisco', + state: 'CA', + postcode: '94103', + country: 'US' } }, { @@ -738,11 +803,82 @@ var data = { ] }; -WooCommerce.put('customers/bulk', data, function(err, data, res) { +WooCommerce.post('customers/bulk', data, function(err, data, res) { console.log(res); }); ``` +```php +<?php +$data = [ + 'customers': [ + [ + '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' + ] + ] + ] +]; + +print_r($woocommerce->post('customers/bulk', $data)); +?> +``` + ```python data = { "customers": [ @@ -809,7 +945,7 @@ data = { ] } -print(wcapi.put("customers/bulk", data).json()) +print(wcapi.post("customers/bulk", data).json()) ``` ```ruby @@ -878,7 +1014,7 @@ data = { ] } -woocommerce.put("customers/bulk", data).parsed_response +woocommerce.post("customers/bulk", data).parsed_response ``` > JSON response example: @@ -964,7 +1100,7 @@ woocommerce.put("customers/bulk", data).parsed_response } ``` -## Delete A Customer ## +## Delete a Customer ## This API helps you delete a customer. @@ -988,6 +1124,10 @@ WooCommerce.delete('customers/2', function(err, data, res) { }); ``` +```php +<?php print_r($woocommerce->delete('customers/2')); ?> +``` + ```python print(wcapi.delete("customers/2").json()) ``` @@ -1028,6 +1168,10 @@ WooCommerce.get('customers/2/orders', function(err, data, res) { }); ``` +```php +<?php print_r($woocommerce->get('customers/2/orders')); ?> +``` + ```python print(wcapi.get("customers/2/orders").json()) ``` @@ -1189,6 +1333,10 @@ WooCommerce.get('customers/2/downloads', function(err, data, res) { }); ``` +```php +<?php print_r($woocommerce->get('customers/2/downloads')); ?> +``` + ```python print(wcapi.get("customers/2/downloads").json()) ``` @@ -1258,6 +1406,10 @@ WooCommerce.get('customers/count', function(err, data, res) { }); ``` +```php +<?php print_r($woocommerce->get('customers/count')); ?> +``` + ```python print(wcapi.get("customers/count").json()) ``` diff --git a/source/includes/v3/_index.md b/source/includes/v3/_index.md index 907563d0..8e0ac176 100644 --- a/source/includes/v3/_index.md +++ b/source/includes/v3/_index.md @@ -23,27 +23,32 @@ The API index provides information about the endpoints available for the site, a | `description` | string | The site's description - `get_option( 'blogdescription' )` | | `URL` | string | The site's URL - `get_option( 'siteurl' )` | | `wc_version` | string | The active WooCommerce version | +| `version` | string | REST API version | | `routes` | array | A list of available endpoints for the site keyed by relative URL. Each endpoint specifies the HTTP methods supported as well as the canonical URL | | `meta` | array | A list of WooCommerce settings used in the API. See [Meta Properties](#meta-properties) | +<aside class="notice"> + <code>version</code> attribute is available starting from WooCommerce 2.5. +</aside> + ### Meta Properties ### | Attribute | Type | Description | | -------------------- | ------- | -------------------------------------------------------------------------------------------------------- | +| `timezone` | string | The site's timezone | | `currency` | string | Currency ISO Code, e.g. `GBP` | | `currency_format` | string | Currency symbol, HTML encoded, e.g. `£` | | `currency_position` | string | Currency position, available the following options: `right`, `left`, `right_space` and `left_space` | +| `thousand_separator` | string | The unit set for product weights. Valid units are `kg`, `g`, `lbs`, `oz` | | `decimal_separator` | string | Decimal separator, e.g `,` | -| `dimension_unit` | string | The unit set for product dimensions. Valid units are `cm`, `m`, `cm`, `mm`, `in`, and `yd` | -| `generate_password` | boolean | Shows if the API is able to auto generate passwords for new customers | -| `links` | array | API help links list | -| `permalinks_enabled` | boolean | Whether pretty permalinks are enabled on the site, if this is false, the API will not function correctly | | `price_num_decimals` | integer | Number of decimals | -| `ssl_enabled` | boolean | True if SSL is enabled for the site, false otherwise | | `tax_included` | boolean | True if prices include tax, false otherwise | -| `thousand_separator` | string | The unit set for product weights. Valid units are `kg`, `g`, `lbs`, `oz` | -| `timezone` | string | The site's timezone | | `weight_unit` | string | The unit set for product weights. Valid units are `kg`, `g`, `lbs`, `oz` | +| `dimension_unit` | string | The unit set for product dimensions. Valid units are `cm`, `m`, `cm`, `mm`, `in`, and `yd` | +| `ssl_enabled` | boolean | True if SSL is enabled for the site, false otherwise | +| `permalinks_enabled` | boolean | Whether pretty permalinks are enabled on the site, if this is false, the API will not function correctly | +| `generate_password` | boolean | Shows if the API is able to auto generate passwords for new customers | +| `links` | array | API help links list | ## View Index List ## @@ -69,6 +74,10 @@ WooCommerce.get('', function(err, data, res) { }); ``` +```php +<?php print_r($woocommerce->get('')); ?> +``` + ```python print(wcapi.get("").json()) ``` @@ -81,398 +90,536 @@ woocommerce.get("").parsed_response ```json { - "store": { - "URL": "https://example.com", - "description": "", + "store": { + "name": "WooCommerce Dev", + "description": "", + "URL": "http://example.com", + "wc_version": "2.5.0", + "version": "3.1.0", + "routes": { + "/": { + "supports": [ + "HEAD", + "GET" + ], + "meta": { + "self": "http://example.com/wc-api/v3/" + } + }, + "/coupons": { + "supports": [ + "HEAD", + "GET", + "POST" + ], + "meta": { + "self": "http://example.com/wc-api/v3/coupons" + }, + "accepts_data": true + }, + "/coupons/count": { + "supports": [ + "HEAD", + "GET" + ], + "meta": { + "self": "http://example.com/wc-api/v3/coupons/count" + } + }, + "/coupons/<id>": { + "supports": [ + "HEAD", + "GET", + "POST", + "PUT", + "PATCH", + "DELETE" + ], + "accepts_data": true + }, + "/coupons/code/<code>": { + "supports": [ + "HEAD", + "GET" + ] + }, + "/coupons/bulk": { + "accepts_data": true, + "meta": { + "self": "http://example.com/wc-api/v3/coupons/bulk" + }, + "supports": [ + "POST", + "PUT", + "PATCH" + ] + }, + "/customers": { + "supports": [ + "HEAD", + "GET", + "POST" + ], + "meta": { + "self": "http://example.com/wc-api/v3/customers" + }, + "accepts_data": true + }, + "/customers/count": { + "supports": [ + "HEAD", + "GET" + ], + "meta": { + "self": "http://example.com/wc-api/v3/customers/count" + } + }, + "/customers/<id>": { + "supports": [ + "HEAD", + "GET", + "POST", + "PUT", + "PATCH", + "DELETE" + ], + "accepts_data": true + }, + "/customers/email/<email>": { + "supports": [ + "HEAD", + "GET" + ] + }, + "/customers/<id>/orders": { + "supports": [ + "HEAD", + "GET" + ] + }, + "/customers/<id>/downloads": { + "supports": [ + "HEAD", + "GET" + ] + }, + "/customers/bulk": { + "accepts_data": true, + "meta": { + "self": "http://example.com/wc-api/v3/customers/bulk" + }, + "supports": [ + "POST", + "PUT", + "PATCH" + ] + }, + "/orders": { + "supports": [ + "HEAD", + "GET", + "POST" + ], + "meta": { + "self": "http://example.com/wc-api/v3/orders" + }, + "accepts_data": true + }, + "/orders/count": { + "supports": [ + "HEAD", + "GET" + ], + "meta": { + "self": "http://example.com/wc-api/v3/orders/count" + } + }, + "/orders/statuses": { + "supports": [ + "HEAD", + "GET" + ], + "meta": { + "self": "http://example.com/wc-api/v3/orders/statuses" + } + }, + "/orders/<id>": { + "supports": [ + "HEAD", + "GET", + "POST", + "PUT", + "PATCH", + "DELETE" + ], + "accepts_data": true + }, + "/orders/<order_id>/notes": { + "supports": [ + "HEAD", + "GET", + "POST" + ], + "accepts_data": true + }, + "/orders/<order_id>/notes/<id>": { + "supports": [ + "HEAD", + "GET", + "POST", + "PUT", + "PATCH", + "DELETE" + ], + "accepts_data": true + }, + "/orders/<order_id>/refunds": { + "supports": [ + "HEAD", + "GET", + "POST" + ], + "accepts_data": true + }, + "/orders/<order_id>/refunds/<id>": { + "supports": [ + "HEAD", + "GET", + "POST", + "PUT", + "PATCH", + "DELETE" + ], + "accepts_data": true + }, + "/orders/bulk": { + "accepts_data": true, + "meta": { + "self": "http://example.com/wc-api/v3/orders/bulk" + }, + "supports": [ + "POST", + "PUT", + "PATCH" + ] + }, + "/products": { + "supports": [ + "HEAD", + "GET", + "POST" + ], + "meta": { + "self": "http://example.com/wc-api/v3/products" + }, + "accepts_data": true + }, + "/products/count": { + "supports": [ + "HEAD", + "GET" + ], + "meta": { + "self": "http://example.com/wc-api/v3/products/count" + } + }, + "/products/<id>": { + "supports": [ + "HEAD", + "GET", + "POST", + "PUT", + "PATCH", + "DELETE" + ], + "accepts_data": true + }, + "/products/<id>/reviews": { + "supports": [ + "HEAD", + "GET" + ] + }, + "/products/<id>/orders": { + "supports": [ + "HEAD", + "GET" + ] + }, + "/products/categories": { + "supports": [ + "HEAD", + "GET", + "POST" + ], "meta": { - "currency": "USD", - "currency_format": "$", - "currency_position": "left_space", - "decimal_separator": ",", - "dimension_unit": "in", - "generate_password": false, - "links": { - "help": "http://woothemes.github.io/woocommerce-rest-api-docs/" - }, - "permalinks_enabled": true, - "price_num_decimals": 2, - "ssl_enabled": true, - "tax_included": true, - "thousand_separator": ".", - "timezone": "America/Los_Angeles", - "weight_unit": "lbs" + "self": "http://example.com/wc-api/v3/products/categories" }, - "name": "WooCommerce Dev", - "routes": { - "/": { - "meta": { - "self": "https://example.com/wc-api/v3/" - }, - "supports": [ - "HEAD", - "GET" - ] - }, - "/coupons": { - "accepts_data": true, - "meta": { - "self": "https://example.com/wc-api/v3/coupons" - }, - "supports": [ - "HEAD", - "GET", - "POST" - ] - }, - "/coupons/<id>": { - "accepts_data": true, - "supports": [ - "HEAD", - "GET", - "POST", - "PUT", - "PATCH", - "DELETE" - ] - }, - "/coupons/bulk": { - "accepts_data": true, - "meta": { - "self": "https://example.com/wc-api/v3/coupons/bulk" - }, - "supports": [ - "POST", - "PUT", - "PATCH" - ] - }, - "/coupons/code/<code>": { - "supports": [ - "HEAD", - "GET" - ] - }, - "/coupons/count": { - "meta": { - "self": "https://example.com/wc-api/v3/coupons/count" - }, - "supports": [ - "HEAD", - "GET" - ] - }, - "/customers": { - "accepts_data": true, - "meta": { - "self": "https://example.com/wc-api/v3/customers" - }, - "supports": [ - "HEAD", - "GET", - "POST" - ] - }, - "/customers/<id>": { - "accepts_data": true, - "supports": [ - "HEAD", - "GET", - "POST", - "PUT", - "PATCH", - "DELETE" - ] - }, - "/customers/<id>/downloads": { - "supports": [ - "HEAD", - "GET" - ] - }, - "/customers/<id>/orders": { - "supports": [ - "HEAD", - "GET" - ] - }, - "/customers/bulk": { - "accepts_data": true, - "meta": { - "self": "https://example.com/wc-api/v3/customers/bulk" - }, - "supports": [ - "POST", - "PUT", - "PATCH" - ] - }, - "/customers/count": { - "meta": { - "self": "https://example.com/wc-api/v3/customers/count" - }, - "supports": [ - "HEAD", - "GET" - ] - }, - "/customers/email/<email>": { - "supports": [ - "HEAD", - "GET" - ] - }, - "/orders": { - "accepts_data": true, - "meta": { - "self": "https://example.com/wc-api/v3/orders" - }, - "supports": [ - "HEAD", - "GET", - "POST" - ] - }, - "/orders/<id>": { - "accepts_data": true, - "supports": [ - "HEAD", - "GET", - "POST", - "PUT", - "PATCH", - "DELETE" - ] - }, - "/orders/<order_id>/notes": { - "accepts_data": true, - "supports": [ - "HEAD", - "GET", - "POST" - ] - }, - "/orders/<order_id>/notes/<id>": { - "accepts_data": true, - "supports": [ - "HEAD", - "GET", - "POST", - "PUT", - "PATCH", - "DELETE" - ] - }, - "/orders/<order_id>/refunds": { - "accepts_data": true, - "supports": [ - "HEAD", - "GET", - "POST" - ] - }, - "/orders/<order_id>/refunds/<id>": { - "accepts_data": true, - "supports": [ - "HEAD", - "GET", - "POST", - "PUT", - "PATCH", - "DELETE" - ] - }, - "/orders/bulk": { - "accepts_data": true, - "meta": { - "self": "https://example.com/wc-api/v3/orders/bulk" - }, - "supports": [ - "POST", - "PUT", - "PATCH" - ] - }, - "/orders/count": { - "meta": { - "self": "https://example.com/wc-api/v3/orders/count" - }, - "supports": [ - "HEAD", - "GET" - ] - }, - "/orders/statuses": { - "meta": { - "self": "https://example.com/wc-api/v3/orders/statuses" - }, - "supports": [ - "HEAD", - "GET" - ] - }, - "/products": { - "accepts_data": true, - "meta": { - "self": "https://example.com/wc-api/v3/products" - }, - "supports": [ - "HEAD", - "GET", - "POST" - ] - }, - "/products/<id>": { - "accepts_data": true, - "supports": [ - "HEAD", - "GET", - "POST", - "PUT", - "PATCH", - "DELETE" - ] - }, - "/products/<id>/orders": { - "supports": [ - "HEAD", - "GET" - ] - }, - "/products/<id>/reviews": { - "supports": [ - "HEAD", - "GET" - ] - }, - "/products/attributes": { - "accepts_data": true, - "meta": { - "self": "https://example.com/wc-api/v3/products/attributes" - }, - "supports": [ - "HEAD", - "GET", - "POST" - ] - }, - "/products/attributes/<id>": { - "accepts_data": true, - "supports": [ - "HEAD", - "GET", - "POST", - "PUT", - "PATCH", - "DELETE" - ] - }, - "/products/bulk": { - "accepts_data": true, - "meta": { - "self": "https://example.com/wc-api/v3/products/bulk" - }, - "supports": [ - "POST", - "PUT", - "PATCH" - ] - }, - "/products/categories": { - "meta": { - "self": "https://example.com/wc-api/v3/products/categories" - }, - "supports": [ - "HEAD", - "GET" - ] - }, - "/products/categories/<id>": { - "supports": [ - "HEAD", - "GET" - ] - }, - "/products/count": { - "meta": { - "self": "https://example.com/wc-api/v3/products/count" - }, - "supports": [ - "HEAD", - "GET" - ] - }, - "/reports": { - "meta": { - "self": "https://example.com/wc-api/v3/reports" - }, - "supports": [ - "HEAD", - "GET" - ] - }, - "/reports/sales": { - "meta": { - "self": "https://example.com/wc-api/v3/reports/sales" - }, - "supports": [ - "HEAD", - "GET" - ] - }, - "/reports/sales/top_sellers": { - "meta": { - "self": "https://example.com/wc-api/v3/reports/sales/top_sellers" - }, - "supports": [ - "HEAD", - "GET" - ] - }, - "/webhooks": { - "accepts_data": true, - "meta": { - "self": "https://example.com/wc-api/v3/webhooks" - }, - "supports": [ - "HEAD", - "GET", - "POST" - ] - }, - "/webhooks/<id>": { - "accepts_data": true, - "supports": [ - "HEAD", - "GET", - "POST", - "PUT", - "PATCH", - "DELETE" - ] - }, - "/webhooks/<webhook_id>/deliveries": { - "supports": [ - "HEAD", - "GET" - ] - }, - "/webhooks/<webhook_id>/deliveries/<id>": { - "supports": [ - "HEAD", - "GET" - ] - }, - "/webhooks/count": { - "meta": { - "self": "https://example.com/wc-api/v3/webhooks/count" - }, - "supports": [ - "HEAD", - "GET" - ] - } + "accepts_data": true + }, + "/products/categories/<id>": { + "supports": [ + "HEAD", + "GET", + "POST", + "PUT", + "PATCH", + "DELETE" + ], + "accepts_data": true + }, + "/products/tags": { + "supports": [ + "HEAD", + "GET", + "POST" + ], + "meta": { + "self": "http://example.com/wc-api/v3/products/tags" + }, + "accepts_data": true + }, + "/products/tags/<id>": { + "supports": [ + "HEAD", + "GET", + "POST", + "PUT", + "PATCH", + "DELETE" + ], + "accepts_data": true + }, + "/products/shipping_classes": { + "supports": [ + "HEAD", + "GET", + "POST" + ], + "meta": { + "self": "http://example.com/wc-api/v3/products/shipping_classes" + }, + "accepts_data": true + }, + "/products/shipping_classes/<id>": { + "supports": [ + "HEAD", + "GET", + "POST", + "PUT", + "PATCH", + "DELETE" + ], + "accepts_data": true + }, + "/products/attributes": { + "supports": [ + "HEAD", + "GET", + "POST" + ], + "meta": { + "self": "http://example.com/wc-api/v3/products/attributes" + }, + "accepts_data": true + }, + "/products/attributes/<id>": { + "supports": [ + "HEAD", + "GET", + "POST", + "PUT", + "PATCH", + "DELETE" + ], + "accepts_data": true + }, + "/products/attributes/<attribute_id>/terms": { + "supports": [ + "HEAD", + "GET", + "POST" + ], + "accepts_data": true + }, + "/products/attributes/<attribute_id>/terms/<id>": { + "supports": [ + "HEAD", + "GET", + "POST", + "PUT", + "PATCH", + "DELETE" + ], + "accepts_data": true + }, + "/products/bulk": { + "accepts_data": true, + "meta": { + "self": "http://example.com/wc-api/v3/products/bulk" }, - "wc_version": "2.4.0" + "supports": [ + "POST", + "PUT", + "PATCH" + ] + }, + "/reports": { + "supports": [ + "HEAD", + "GET" + ], + "meta": { + "self": "http://example.com/wc-api/v3/reports" + } + }, + "/reports/sales": { + "supports": [ + "HEAD", + "GET" + ], + "meta": { + "self": "http://example.com/wc-api/v3/reports/sales" + } + }, + "/reports/sales/top_sellers": { + "supports": [ + "HEAD", + "GET" + ], + "meta": { + "self": "http://example.com/wc-api/v3/reports/sales/top_sellers" + } + }, + "/taxes": { + "supports": [ + "HEAD", + "GET", + "POST" + ], + "meta": { + "self": "http://example.com/wc-api/v3/taxes" + }, + "accepts_data": true + }, + "/taxes/count": { + "supports": [ + "HEAD", + "GET" + ], + "meta": { + "self": "http://example.com/wc-api/v3/taxes/count" + } + }, + "/taxes/<id>": { + "supports": [ + "HEAD", + "GET", + "POST", + "PUT", + "PATCH", + "DELETE" + ], + "accepts_data": true + }, + "/taxes/classes": { + "supports": [ + "HEAD", + "GET", + "POST" + ], + "meta": { + "self": "http://example.com/wc-api/v3/taxes/classes" + }, + "accepts_data": true + }, + "/taxes/classes/count": { + "supports": [ + "HEAD", + "GET" + ], + "meta": { + "self": "http://example.com/wc-api/v3/taxes/classes/count" + } + }, + "/taxes/classes/<slug>": { + "supports": [ + "DELETE" + ] + }, + "/taxes/bulk": { + "accepts_data": true, + "meta": { + "self": "http://example.com/wc-api/v3/taxes/bulk" + }, + "supports": [ + "POST", + "PUT", + "PATCH" + ] + }, + "/webhooks": { + "supports": [ + "HEAD", + "GET", + "POST" + ], + "meta": { + "self": "http://example.com/wc-api/v3/webhooks" + }, + "accepts_data": true + }, + "/webhooks/count": { + "supports": [ + "HEAD", + "GET" + ], + "meta": { + "self": "http://example.com/wc-api/v3/webhooks/count" + } + }, + "/webhooks/<id>": { + "supports": [ + "HEAD", + "GET", + "POST", + "PUT", + "PATCH", + "DELETE" + ], + "accepts_data": true + }, + "/webhooks/<webhook_id>/deliveries": { + "supports": [ + "HEAD", + "GET" + ] + }, + "/webhooks/<webhook_id>/deliveries/<id>": { + "supports": [ + "HEAD", + "GET" + ] + } + }, + "meta": { + "timezone": "America/Los_Angeles", + "currency": "USD", + "currency_format": "$", + "currency_position": "left", + "thousand_separator": ".", + "decimal_separator": ",", + "price_num_decimals": 2, + "tax_included": false, + "weight_unit": "lbs", + "dimension_unit": "in", + "ssl_enabled": false, + "permalinks_enabled": true, + "generate_password": false, + "links": { + "help": "http://woothemes.github.io/woocommerce-rest-api-docs/" + } } + } } ``` diff --git a/source/includes/v3/_introduction.md b/source/includes/v3/_introduction.md index 81bbb491..19af2976 100644 --- a/source/includes/v3/_introduction.md +++ b/source/includes/v3/_introduction.md @@ -1,30 +1,28 @@ # Introduction # -Introduced in WooCommerce 2.1, the REST API allows store data to be created, read, updated, and deleted using the JSON format. +Introduced in WooCommerce 2.1, the REST API allows WooCommerce data to be created, read, updated, and deleted using JSON format. ## Requirements ## -You must be using WooCommerce 2.1 or newer and the REST API must be enabled under `WooCommerce > Settings`. You must enable pretty permalinks, as default permalinks will not work. +You must be using WooCommerce 2.1 or newer and the REST API must be enabled under `WooCommerce > Settings`. You must enable pretty permalinks in `Settings > Permalinks` (default permalinks will not work). <aside class="notice"> -Many endpoints were improving with new versions of WooCommerce, so we always recommend keeping your WooCommerce updated to work properly with this documentation. + Endpoints may be improved with each release of WooCommerce, so we always recommend keeping WooCommerce up to date to reflect this documentation. </aside> ## Version ## -The current API version is `v3` which takes a first-order position in endpoints. - -Check the API versions present in every version of WooCommerce: +The current API version is `v3` which takes a first-order position in endpoints. The following table shows API versions present in each major version of WooCommerce: | API Version | WooCommerce | | ----------- | ----------------------------- | | `v1` | 2.1.x, 2.2.x, 2.3.x and 2.4.x | | `v2` | 2.2.x, 2.3.x and 2.4.x | -| `v3` | 2.4.x | +| `v3` | 2.4.x, 2.5.x | -The `v1` and `v2` will be removed in future versions. +The `v1` and `v2` APIs will be removed in future versions. -### Differences between v1 and v2 versions ### +### Differences between v1 and v2 ### * v1 supports XML response format, v2 only supports JSON. * v1 does not support creating or updating (with the exception of order status) any resources, v2 supports full create/read/update/delete for all endpoints. @@ -35,22 +33,21 @@ The `v1` and `v2` will be removed in future versions. * v1 does not include any endpoints for getting valid order statuses, v2 includes an endpoint for listing valid order statuses (`GET /orders/statuses`). * v2 supports the core features added in WooCommerce 2.2, primarily order refunds (via the `/orders/refunds` endpoint) and Webhooks (via the `/webhooks`). -### Differences between v3 and old versions ### +### Differences between v3 and older versions ### -* v3 implement full basic authentication ([conforms to the Basic auth spec)](http://tools.ietf.org/html/rfc2617)). +* v3 implements full basic authentication ([conforms to the Basic auth spec)](http://tools.ietf.org/html/rfc2617)). * v3 fixes the OAuth implementation to be compliant with the [Oauth 1.0a specs](http://tools.ietf.org/html/rfc5849). -* v3 include a new endpoint to get all product orders. -* v3 have new endpoints to allow bulk actions as edition and creation of products, orders, customers and coupons. -* v3 introduce new product attribute endpoints (`GET`, `POST`, `PUT` and `DELETE`). +* v3 includes a new endpoint to get all product orders. +* v3 has new endpoints to allow bulk actions as edition and creation of products, orders, customers and coupons. +* v3 introduces new product attribute endpoints (`GET`, `POST`, `PUT` and `DELETE`). * v3 deprecated the product/sku/<id> endpoint (because a SKU can be generated with any character, besides that there is a filter callend `filter[sku]`). -* v3 include category thumbnails on the requests for `product/categories`. +* v3 includes category thumbnails on the requests for `product/categories`. * v3 uses our option to auto generate passwords for new customers. -### API Docs for each version ### +### API Docs for past versions ### * [WooCommerce REST API v1 docs](v1.html) * [WooCommerce REST API v2 docs](v2.html) -* [WooCommerce REST API v3 docs](index.html) ## Schema ## @@ -58,7 +55,7 @@ The API is accessible via this endpoint: `https://www.your-store.com/wc-api/v3` -You may access the API over either HTTP or HTTPS. HTTPS is recommended where possible, as authentication is simpler. The API index will declare if the site supports SSL or not. +*Pretty permalinks must be enabled*. You may access the API over either HTTP or HTTPS. *HTTPS is recommended where possible*, since authentication is simpler. The API index will declare if the site supports SSL or not. ## Requests/Responses ## @@ -70,15 +67,15 @@ Some general information about responses: * Resource IDs are returned as integers. -* Any decimal monetary amount, such as prices or totals, are returned as strings with two decimal places. The decimal separator (typically either `.` or `,`) is controlled by the site and is included in the API index. This is by design, in order to make localization of API data easier for the client. You may need to account for this in your implemetation if you will be doing calculations with the returned data (e.g. convert string amounts with commas as the decimal place before performing any calculations) +* Any decimal monetary amount, such as prices or totals, will be returned as strings with two decimal places. The decimal separator (typically either `.` or `,`) is controlled by the site and is included in the API index. This is by design in order to make localization of API data easier for the client. You may need to account for this in your implementation if you will be doing calculations with the returned data (e.g. converting string amounts with commas to decimal places before performing calculations). * Other amounts, such as item counts, are returned as integers. -* Blank fields are generally included as `null` instead of being blank strings or omitted. +* Blank fields are generally included as `null` instead of being returned as blank strings or omitted. ## Authentication ## -There are two aways to authenticate with the API, depending on whether the site supports SSL or not. Remember that the Index endpoint will indicate if the site supports SSL or not. +There are two ways to authenticate with the API, depending on whether the site supports SSL. Remember that the Index endpoint will indicate if the site supports SSL. ### Over HTTPS ### @@ -91,7 +88,7 @@ curl https://www.example.com/wc-api/v3/orders \ -u consumer_key:consumer_secret ``` -Occasionally some servers may not properly parse the Authorization header (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. +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. > Example for servers that not properly parse the Authorization header: @@ -101,7 +98,7 @@ curl https://www.example.com/wc-api/v3/orders?consumer_key=123&consumer_secret=a ### Over HTTP ### -You must use [OAuth 1.0a "one-legged" authentication](http://tools.ietf.org/html/rfc5849) to ensure API credentials cannot be intercepted. Typically you may use any standard OAuth 1.0a library in your language of choice to handle the authentication, or generate the necessary parameters by following these instructions. +You must use [OAuth 1.0a "one-legged" authentication](http://tools.ietf.org/html/rfc5849) to ensure API credentials cannot be intercepted. Typically you will use any standard OAuth 1.0a library in the language of choice to handle the authentication, or generate the necessary parameters by following the following instructions. #### Generating an OAuth signature #### @@ -135,18 +132,18 @@ when encoded: 8) Generate the signature using the string to key and your consumer secret key -If you are having trouble generating a correct signature, you'll want to review your string to sign for errors with encoding. The [authentication source](https://github.com/woothemes/woocommerce/blob/master/includes/api/class-wc-api-authentication.php#L177) can also be helpful in understanding how to properly generate the signature. +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-api-authentication.php#L177) 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 require parameters are: `oauth_consumer_key`, `oauth_timestamp`, `oauth_nonce`, `oauth_signature`, and `oauth_signature_method`. `oauth_version` is not required and must be omitted. +* The require parameters are: `oauth_consumer_key`, `oauth_timestamp`, `oauth_nonce`, `oauth_signature`, and `oauth_signature_method`. `oauth_version` is not required and should be omitted. * HMAC-SHA1 or HMAC-SHA256 are the only accepted hash algorithms. -* The OAuth nonce can be any randomly generated 32 character (recommended) string that is unique to the consumer key. Read more suggestions on [generating a nonce](https://dev.twitter.com/discussions/12445) on the Twitter API forums. -* The OAuth timestamp should be the unix timestamp at the time of the request. The API will deny any requests that include a timestamp that is outside of a 15 minute window to prevent replay attacks. +* 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 API forums](https://dev.twitter.com/discussions/12445). +* The OAuth timestamp should be the unix timestamp at the time of the request. The 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 a signature](https://dev.twitter.com/docs/auth/creating-signature) with OAuth 1.0a, but remember tokens are not used with this implementation. +* 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 filter fields in your request, it saves a lot of trouble if you can order your filter fields alphabetically before submitting. Many Oauth libraries won't order subquery fields properly, resulting in invalid signatures. @@ -182,7 +179,7 @@ Note that the following filters are supported for all endpoints except the `repo | `meta` | resource meta is excluded by default, but it can be included by setting `meta=true`, e.g. `GET /orders?filter[meta]=true`. Protected meta (meta whose key is prefixed with an underscore) is not included in the response | | `pagination` | explained below | -Note that Dates should be provided in [RFC3339](http://www.ietf.org/rfc/rfc3339.txt) format in UTC timezone: `YYYY-MM-DDTHH:MM:SSZ`. You may omit the time and timezone if desired. +Note that Dates should be provided in [RFC3339](http://www.ietf.org/rfc/rfc3339.txt) format in the UTC timezone: `YYYY-MM-DDTHH:MM:SSZ`. You may omit the time and timezone if desired. ### Fields Parameter ### @@ -204,7 +201,7 @@ Sub-fields can't be limited for resources that have multiple structs, like an or ## 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 specifed with the `?filter[limit]` parameter: +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 `?filter[limit]` parameter: `GET /orders?filter[limit]=15` @@ -216,7 +213,7 @@ You may also specify the offset from the first resource using the `?filter[offse `GET /orders?filter[offset]=5` -Page number is 1-based and ommiting the `?page` parameter will return the first page. +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-WC-Total` and `X-WC-TotalPages` HTTP headers. @@ -301,13 +298,13 @@ Occasionally you might encounter errors when accessing the API. There are four p } ``` -Errors return both an appropriate HTTP status code and response object which contains a `code` and `message` attribute. If an endpoint has any custom errors, they are documented with that endpoint. +Errors return both an appropriate HTTP status code and response object which contains a `code` and `message` attribute. If an endpoint has any custom errors, they are documented within that endpoint. ## HTTP Verbs ## The API uses the appropriate HTTP verb for each action: -| Verbe | Description | +| Verb | Description | |----------|-------------------------------------------------------------------------| | `HEAD` | Can be used for any endpoint to return just the HTTP header information | | `GET` | Used for retrieving resources | @@ -317,7 +314,7 @@ The API uses the appropriate HTTP verb for each action: ## JSONP Support ## -The API supports JSONP by default. JSONP responses uses 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: +The 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: <div class="api-endpoint"> <div class="endpoint-data"> @@ -366,7 +363,7 @@ curl https://example.com/wc-api/v3/orders/count?_jsonp=ordersCount \ ## Webhooks ## -Webhooks can be maneged by our interface or using the REST API endpoints. The `WC_Webhook` class manages all data storage/retrieval from the custom post type, as well as enqueuing a webhook's actions and processing/delivering/logging the webhook. On `woocommerce_init`, active webhooks are loaded and their associated hooks are added. +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 custom post type, as well as enqueuing webhook actions and processing/delivering/logging the webhook. On `woocommerce_init`, active webhooks are loaded and their associated hooks are added. Each webhook has: @@ -387,7 +384,7 @@ Core topics are: * `order.created, order.updated, order.deleted` * `product.created, product.updated, product.deleted` -Custom topics can also be used which map to a single hook name, so 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. +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 ### @@ -400,7 +397,7 @@ Delivery is done using `wp_remote_post()` (HTTP POST) and processed in the backg * `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. +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 ### @@ -432,6 +429,7 @@ You can find the Webhooks interface going to "WooCommerce" > "Settings" > "API" ## Official Libraries ## - [Node.js](https://www.npmjs.com/package/woocommerce-api) +- [PHP](https://packagist.org/packages/automattic/woocommerce) - [Python](https://pypi.python.org/pypi/WooCommerce) - [Ruby](https://rubygems.org/gems/woocommerce_api) @@ -450,6 +448,27 @@ var WooCommerce = new WooCommerceAPI({ }); ``` +```php +<?php +// Install: +// composer require automattic/woocommerce + +// Setup: +require __DIR__ . '/vendor/autoload.php'; + +use Automattic\WooCommerce\Client; + +$woocommerce = new Client( + 'http://example.com', // Your store URL + 'consumer_key', // Your consumer key + 'consumer_secret', // Your consumer secret + [ + 'version' => 'v3' // WooCommerce API version + ] +); +?> +``` + ```python # Install: # pip install woocommerce @@ -458,10 +477,10 @@ var WooCommerce = new WooCommerceAPI({ from woocommerce import API wcapi = API( - url="http://example.com", - consumer_key="consumer_key", - consumer_secret="consumer_secret", - version="v3" + url="http://example.com", # Your store URL + consumer_key="consumer_key", # Your consumer key + consumer_secret="consumer_secret", # Your consumer secret + version="v3" # WooCommerce API version ) ``` @@ -473,17 +492,17 @@ wcapi = API( require "woocommerce_api" woocommerce = WooCommerce::API.new( - "http://example.com", - "consumer_key", - "consumer_secret", + "http://example.com", # Your store URL + "consumer_key", # Your consumer key + "consumer_secret", # Your consumer secret { - version: "v3" + version: "v3" # WooCommerce API version } ) ``` <aside class="notice"> - Use the tabs at the top-right corner to see how to install and use each library. + Use the tabs in the top-right corner of this page to see how to install and use each library. </aside> ## Tools ## diff --git a/source/includes/v3/_order-notes.md b/source/includes/v3/_order-notes.md new file mode 100644 index 00000000..b1d1d834 --- /dev/null +++ b/source/includes/v3/_order-notes.md @@ -0,0 +1,336 @@ +# Order - Notes # + +This section lists all API endpoints that can be used to create, edit or otherwise manipulate order notes. + +## Order Notes Properties ## + +| Attribute | Type | Description | +| --------------- | ------- | ------------------------------------------------------------------------------------------------------------------ | +| `id` | integer | Order note ID <i class="label label-info">read-only</i> | +| `created_at` | string | UTC DateTime when the order note was created <i class="label label-info">read-only</i> | +| `note` | string | Order note <i class="label label-info">required</i> | +| `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 a Note For an Order ## + +This API helps you to create a new note for an order. + +### HTTP Request ### + +<div class="api-endpoint"> + <div class="endpoint-data"> + <i class="label label-post">POST</i> + <h6>/wc-api/v3/orders/<id>/notes</h6> + </div> +</div> + +```shell +curl -X POST https://example.com/wc-api/v3/orders/645/notes \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "order_note": { + "note": "Order ok!!!" + } +}' +``` + +```javascript +var data = { + order_note: { + note: 'Order ok!!!' + } +}; + +WooCommerce.post('orders/645/notes', data, function(err, data, res) { + console.log(res); +}); +``` + +```php +<?php +$data = [ + 'order_note' => [ + 'note' => 'Order ok!!!' + ] +]; + +print_r($woocommerce->post('orders/645/notes', $data)); +?> +``` + +```python +data = { + "order_note": { + "note": "Order ok!!!" + } +} + +print(wcapi.post("orders/645/notes", data).json()) +``` + +```ruby +data = { + order_note: { + note: "Order ok!!!" + } +} + +woocommerce.post("orders/645/notes", data).parsed_response +``` + +> JSON response example: + +```json +{ + "order_note": { + "id": "416", + "created_at": "2015-01-26T20:56:44Z", + "note": "Order ok!!!", + "customer_note": false + } +} +``` + +## View an Order Note ## + +This API lets you retrieve and view a specific note from an order. + +### HTTP Request ### + +<div class="api-endpoint"> + <div class="endpoint-data"> + <i class="label label-get">GET</i> + <h6>/wc-api/v3/orders/<id>/notes/<note_id></h6> + </div> +</div> + +```shell +curl https://example.com/wc-api/v3/orders/645/notes/416 \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('orders/645/notes/416', function(err, data, res) { + console.log(res); +}); +``` + +```php +<?php print_r($woocommerce->get('orders/645/notes/416')); ?> +``` + +```python +print(wcapi.get("orders/645/notes/416").json()) +``` + +```ruby +woocommerce.get("orders/645/notes/416").parsed_response +``` + +> JSON response example: + +```json +{ + "order_note": { + "id": "416", + "created_at": "2015-01-26T20:56:44Z", + "note": "Order ok!!!", + "customer_note": false + } +} +``` + +## View List of Notes From an Order ## + +This API helps you to view all the notes from an order. + +### HTTP Request ### + +<div class="api-endpoint"> + <div class="endpoint-data"> + <i class="label label-get">GET</i> + <h6>/wc-api/v3/orders/<id>/notes</h6> + </div> +</div> + +```shell +curl https://example.com/wc-api/v3/orders/645/notes \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('orders/645/notes', function(err, data, res) { + console.log(res); +}); +``` + +```php +<?php print_r($woocommerce->get('orders/645/notes')); ?> +``` + +```python +print(wcapi.get("orders/645/notes").json()) +``` + +```ruby +woocommerce.get("orders/645/notes").parsed_response +``` + +> JSON response example: + +```json +{ + "order_notes": [ + { + "id": "416", + "created_at": "2015-01-26T20:56:44Z", + "note": "Order ok!!!", + "customer_note": false + }, + { + "id": "415", + "created_at": "2015-01-26T20:16:14Z", + "note": "Order status changed from Processing to Completed.", + "customer_note": false + }, + { + "id": "412", + "created_at": "2015-01-26T20:00:21Z", + "note": "Order item stock reduced successfully.", + "customer_note": false + }, + { + "id": "411", + "created_at": "2015-01-26T20:00:09Z", + "note": "Order status changed from Pending Payment to Processing.", + "customer_note": false + } + ] +} +``` + +## Update an Order Note ## + +This API lets you make changes to an order note. + +### HTTP Request ### + +<div class="api-endpoint"> + <div class="endpoint-data"> + <i class="label label-put">PUT</i> + <h6>/wc-api/v3/orders/<id>/notes/<note_id></h6> + </div> +</div> + +```shell +curl -X PUT https://example.com/wc-api/v3/orders/645/notes/416 \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "order_note": { + "note": "Ok!" + } +}' +``` + +```javascript +var data = { + order_note: { + note: 'Ok!' + } +}; + +WooCommerce.put('orders/645/notes/416', data, function(err, data, res) { + console.log(res); +}); +``` + +```php +<?php +$data = [ + 'order_note' => [ + 'note' => 'Ok!' + ] +]; + +print_r($woocommerce->put('orders/645/notes/416', $data)); +?> +``` + +```python +data = { + "order_note": { + "note": "Ok!" + } +} + +print(wcapi.put("orders/645/notes/416", data).json()) +``` + +```ruby +data = { + order_note: { + note: "Ok!" + } +} + +woocommerce.put("orders/645/notes/416", data).parsed_response +``` + +> JSON response example: + +```json +{ + "order_note": { + "id": "416", + "created_at": "2015-01-26T20:56:44Z", + "note": "Ok!", + "customer_note": false + } +} +``` + +## Delete an Order Note ## + +This API helps you delete an order note. + +### HTTP Request ### + +<div class="api-endpoint"> + <div class="endpoint-data"> + <i class="label label-delete">DELETE</i> + <h6>/wc-api/v3/orders/<id>/notes/<note_id></h6> + </div> +</div> + +```shell +curl -X DELETE https://example.com/wc-api/v3/orders/645/notes/416 \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.delete('orders/645/notes/416', function(err, data, res) { + console.log(res); +}); +``` + +```php +<?php print_r($woocommerce->delete('orders/645/notes/416')); ?> +``` + +```python +print(wcapi.delete("orders/645/notes/416").json()) +``` + +```ruby +woocommerce.delete("orders/645/notes/416").parsed_response +``` + +> JSON response example: + +```json +{ + "message": "Permanently deleted order note" +} +``` diff --git a/source/includes/v3/_order-refunds.md b/source/includes/v3/_order-refunds.md new file mode 100644 index 00000000..402009e2 --- /dev/null +++ b/source/includes/v3/_order-refunds.md @@ -0,0 +1,359 @@ +# Order - Refunds # + +This section lists all API endpoints that can be used to create, edit or otherwise manipulate order refunds. + +## Order Refunds Properties ## + +| Attribute | Type | Description | +| ------------ | ------- | ---------------------------------------------------------------------------------------- | +| `id` | integer | Order note ID <i class="label label-info">read-only</i> | +| `created_at` | string | UTC DateTime when the order refund was created <i class="label label-info">read-only</i> | +| `amount` | float | Refund amount <i class="label label-info">required</i> | +| `reason` | string | Reason for refund | +| `line_items` | array | List of order items to refund. See [Line Items Properties](#line-items-properties) | + +## Create a Refund For an Order ## + +This API helps you to create a new refund for an order. + +### HTTP Request ### + +<div class="api-endpoint"> + <div class="endpoint-data"> + <i class="label label-post">POST</i> + <h6>/wc-api/v3/orders/<id>/refunds</h6> + </div> +</div> + +```shell +curl -X POST https://example.com/wc-api/v3/orders/645/refunds \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "order_refund": { + "amount": 10 + } +}' +``` + +```javascript +var data = { + order_refund: { + amount: 10 + } +}; + +WooCommerce.post('orders/645/refunds', data, function(err, data, res) { + console.log(res); +}); +``` + +```php +<?php +$data = [ + 'order_refund' => [ + 'amount' => 10 + ] +]; + +print_r($woocommerce->post('orders/645/refunds', $data)); +?> +``` + +```python +data = { + "order_refund": { + "amount": 10 + } +} + +print(wcapi.post("orders/645/refunds", data).json()) +``` + +```ruby +data = { + order_refund: { + amount: 10 + } +} + +woocommerce.post("orders/645/refunds", data).parsed_response +``` + +> JSON response example: + +```json +{ + "order_refund": { + "id": 649, + "created_at": "2015-01-26T19:29:32Z", + "amount": "10.00", + "reason": "", + "line_items": [] + } +} +``` + +## View an Order Refund ## + +This API lets you retrieve and view a specific refund from an order. + +### HTTP Request ### + +<div class="api-endpoint"> + <div class="endpoint-data"> + <i class="label label-get">GET</i> + <h6>/wc-api/v3/orders/<id>/refunds/<refund_id></h6> + </div> +</div> + +```shell +curl https://example.com/wc-api/v3/orders/645/refunds/649 \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('orders/645/refunds/649', function(err, data, res) { + console.log(res); +}); +``` + +```php +<?php print_r($woocommerce->get('orders/645/refunds/649')); ?> +``` + +```python +print(wcapi.get("orders/645/refunds/649").json()) +``` + +```ruby +woocommerce.get("orders/645/refunds/649").parsed_response +``` + +> JSON response example: + +```json +{ + "order_refund": { + "id": 649, + "created_at": "2015-01-26T19:29:32Z", + "amount": "10.00", + "reason": "", + "line_items": [] + } +} +``` + +## View List of Refunds From an Order ## + +This API helps you to view all the refunds from an order. + +### HTTP Request ### + +<div class="api-endpoint"> + <div class="endpoint-data"> + <i class="label label-get">GET</i> + <h6>/wc-api/v3/orders/<id>/refunds</h6> + </div> +</div> + +```shell +curl https://example.com/wc-api/v3/orders/645/refunds \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('orders/645/refunds', function(err, data, res) { + console.log(res); +}); +``` + +```php +<?php print_r($woocommerce->get('orders/645/refunds')); ?> +``` + +```python +print(wcapi.get("orders/645/refunds").json()) +``` + +```ruby +woocommerce.get("orders/645/refunds").parsed_response +``` + +> JSON response example: + +```json +{ + "order_refunds": [ + { + "id": 649, + "created_at": "2015-01-26T19:29:32Z", + "amount": "10.00", + "reason": "", + "line_items": [] + }, + { + "id": 647, + "created_at": "2015-01-26T19:19:06Z", + "amount": "21.99", + "reason": "", + "line_items": [ + { + "id": 514, + "subtotal": "-21.99", + "subtotal_tax": "0.00", + "total": "-21.99", + "total_tax": "0.00", + "price": "-21.99", + "quantity": 1, + "tax_class": "reduced-rate", + "name": "Premium Quality", + "product_id": 546, + "sku": "", + "meta": [] + }, + { + "id": 515, + "subtotal": "0.00", + "subtotal_tax": "0.00", + "total": "0.00", + "total_tax": "0.00", + "price": "0.00", + "quantity": 0, + "tax_class": null, + "name": "Ship Your Idea", + "product_id": 613, + "sku": "", + "meta": [] + } + ] + } + ] +} +``` + +## Update an Order Refund ## + +This API lets you make changes to an order refund. + +### HTTP Request ### + +<div class="api-endpoint"> + <div class="endpoint-data"> + <i class="label label-put">PUT</i> + <h6>/wc-api/v3/orders/<id>/refunds/<refund_id></h6> + </div> +</div> + +```shell +curl -X PUT https://example.com/wc-api/v3/orders/645/refunds/649 \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "order_refund": { + "reason": "Because was it necessary!" + } +}' +``` + +```javascript +var data = { + order_refund: { + reason: 'Because was it necessary!' + } +}; + +WooCommerce.put('orders/645/refunds/649', data, function(err, data, res) { + console.log(res); +}); +``` + +```php +<?php +$data = [ + 'order_refund' => [ + 'reason' => 'Because was it necessary!' + ] +]; + +print_r($woocommerce->put('orders/645/refunds/649', $data)); +?> +``` + +```python +data = { + "order_refund": { + "reason": "Because was it necessary!" + } +} + +print(wcapi.put("orders/645/refunds/649", data).json()) +``` + +```ruby +data = { + order_refund: { + reason: "Because was it necessary!" + } +} + +woocommerce.put("orders/645/refunds/649", data).parsed_response +``` + +> JSON response example: + +```json +{ + "order_refund": { + "id": 649, + "created_at": "2015-01-26T19:29:32Z", + "amount": "10.00", + "reason": "Because was it necessary!", + "line_items": [] + } +} +``` + +## Delete an Order Refund ## + +This API helps you delete an order refund. + +### HTTP Request ### + +<div class="api-endpoint"> + <div class="endpoint-data"> + <i class="label label-delete">DELETE</i> + <h6>/wc-api/v3/orders/<id>/refunds/<refund_id></h6> + </div> +</div> + +```shell +curl -X DELETE https://example.com/wc-api/v3/orders/645/refunds/649 \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.delete('orders/645/refunds/649', function(err, data, res) { + console.log(res); +}); +``` + +```php +<?php print_r($woocommerce->delete('orders/645/refunds/649')); ?> +``` + +```python +print(wcapi.delete("orders/645/refunds/649").json()) +``` + +```ruby +woocommerce.delete("orders/645/refunds/649").parsed_response +``` + +> JSON response example: + +```json +{ + "message": "Permanently deleted refund" +} +``` diff --git a/source/includes/v3/_orders.md b/source/includes/v3/_orders.md index 837fa1ca..c36d43f4 100644 --- a/source/includes/v3/_orders.md +++ b/source/includes/v3/_orders.md @@ -1,6 +1,6 @@ # Orders # -This section lists all API that can be used to create, edit or otherwise manipulate orders. +This section lists all API endpoints that can be used to create, edit or otherwise manipulate orders. ## Orders Properties ## @@ -111,7 +111,7 @@ This section lists all API that can be used to create, edit or otherwise manipul | `code` | string | Coupon code <i class="label label-info">required</i> | | `amount` | float | Total amount <i class="label label-info">required</i> | -## Create An Order ## +## Create an Order ## This API helps you to create a new order. @@ -243,6 +243,65 @@ WooCommerce.post('orders', data, function(err, data, res) { }); ``` +```php +<?php +$data = [ + 'order' => [ + 'payment_details' => [ + 'method_id' => 'bacs', + 'method_title' => 'Direct Bank Transfer', + 'paid' => true + ], + 'billing_address' => [ + '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_address' => [ + 'first_name' => 'John', + 'last_name' => 'Doe', + 'address_1' => '969 Market', + 'address_2' => '', + 'city' => 'San Francisco', + 'state' => 'CA', + 'postcode' => '94103', + 'country' => 'US' + ], + 'customer_id' => 2, + 'line_items' => [ + [ + 'product_id' => 546, + 'quantity' => 2 + ], + [ + 'product_id' => 613, + 'quantity' => 1, + 'variations' => [ + 'pa_color' => 'Black' + ] + ] + ], + 'shipping_lines' => [ + [ + 'method_id' => 'flat_rate', + 'method_title' => 'Flat Rate', + 'total' => 10 + ] + ] + ] +]; + +print_r($woocommerce->post('orders', $data)); +?> +``` + ```python data = { "order": { @@ -517,7 +576,7 @@ woocommerce.post("orders", data).parsed_response } ``` -## View An Order ## +## View an Order ## This API lets you retrieve and view a specific order. @@ -541,6 +600,10 @@ WooCommerce.get('orders/645', function(err, data, res) { }); ``` +```php +<?php print_r($woocommerce->get('orders/645')); ?> +``` + ```python print(wcapi.get("orders/645").json()) ``` @@ -709,7 +772,17 @@ woocommerce.get("orders/645").parsed_response } ``` -## View List Of Orders ## +#### Available Filters #### + +| Filter | Type | Description | +| -------- | ------ | --------------------------------------------------------------------------------------------- | +| `expand` | string | Expand `coupons`, `products` and `taxes` objects, eg: `filter[expand]=coupons,products,taxes` | + +<aside class="notice"> + <code>expand</code> filter is available starting from WooCommerce 2.5. +</aside> + +## View List of Orders ## This API helps you to view all the orders. @@ -733,6 +806,10 @@ WooCommerce.get('orders', function(err, data, res) { }); ``` +```php +<?php print_r($woocommerce->get('orders')); ?> +``` + ```python print(wcapi.get("orders").json()) ``` @@ -1052,11 +1129,16 @@ woocommerce.get("orders").parsed_response #### Available Filters #### -| Filter | Type | Description | -| -------- | ------ | ------------------------------------------------- | -| `status` | string | Orders by status. eg: `processing` or `cancelled` | +| Filter | Type | Description | +| -------- | ------ | --------------------------------------------------------------------------------------------- | +| `status` | string | Orders by status. eg: `processing` or `cancelled` | +| `expand` | string | Expand `coupons`, `products` and `taxes` objects, eg: `filter[expand]=coupons,products,taxes` | -## Update An Order ## +<aside class="notice"> + <code>expand</code> filter is available starting from WooCommerce 2.5. +</aside> + +## Update an Order ## This API lets you make changes to an order. @@ -1092,6 +1174,18 @@ WooCommerce.put('orders/645', data, function(err, data, res) { }); ``` +```php +<?php +$data = [ + 'order' => [ + 'status' => 'completed' + ] +]; + +print_r($woocommerce->put('orders/645', $data)); +?> +``` + ```python data = { "order": { @@ -1288,7 +1382,7 @@ To update is necessary to send objects containing IDs and to create new not just </div> ```shell -curl -X PUT https://example.com/wc-api/v3/orders/bulk \ +curl -X POST https://example.com/wc-api/v3/orders/bulk \ -u consumer_key:consumer_secret \ -H "Content-Type: application/json" \ -d '{ @@ -1310,20 +1404,39 @@ var data = { orders: [ { id: 645, - shipping_methods: "Local Delivery" + shipping_methods: 'Local Delivery' }, { id: 644, - shipping_methods: "Local Delivery" + shipping_methods: 'Local Delivery' } ] }; -WooCommerce.put('orders/bulk', data, function(err, data, res) { +WooCommerce.post('orders/bulk', data, function(err, data, res) { console.log(res); }); ``` +```php +<?php +$data = [ + 'orders' => [ + [ + 'id' => 645, + 'shipping_methods' => 'Local Delivery' + ], + [ + 'id' => 644, + 'shipping_methods' => 'Local Delivery' + ] + ] +]; + +print_r($woocommerce->post('orders/bulk', $data)); +?> +``` + ```python data = { "orders": [ @@ -1338,7 +1451,7 @@ data = { ] } -print(wcapi.put("orders/bulk", data).json()) +print(wcapi.post("orders/bulk", data).json()) ``` ```ruby @@ -1355,7 +1468,7 @@ data = { ] } -woocommerce.put("orders/bulk", data).parsed_response +woocommerce.post("orders/bulk", data).parsed_response ``` > JSON response example: @@ -1667,7 +1780,7 @@ woocommerce.put("orders/bulk", data).parsed_response } ``` -## Delete An Order ## +## Delete an Order ## This API helps you delete an order. @@ -1691,13 +1804,17 @@ WooCommerce.delete('orders/645/?force=true', function(err, data, res) { }); ``` +```php +<?php print_r($woocommerce->delete('orders/645', ['force' => true])); ?> +``` + ```python print(wcapi.delete("orders/645/?force=true").json()) ``` ```ruby -woocommerce.delete("orders/645/?force=true").parsed_response +woocommerce.delete("orders/645/", force: true).parsed_response ``` > JSON response example: @@ -1738,6 +1855,10 @@ WooCommerce.get('orders/count', function(err, data, res) { }); ``` +```php +<?php print_r($woocommerce->get('orders/count')); ?> +``` + ```python print(wcapi.get("orders/count").json()) ``` @@ -1760,7 +1881,7 @@ woocommerce.get("orders/count").parsed_response | -------- | ------ | ------------------------------------------------- | | `status` | string | Orders by status. eg: `processing` or `cancelled` | -## View List Of Order Statuses ## +## View List of Order Statuses ## This API lets you retrieve a list of orders statuses available. @@ -1784,6 +1905,10 @@ WooCommerce.get('orders/statuses', function(err, data, res) { }); ``` +```php +<?php print_r($woocommerce->get('orders/statuses')); ?> +``` + ```python print(wcapi.get("orders/statuses").json()) ``` @@ -1807,644 +1932,3 @@ woocommerce.get("orders/statuses").parsed_response } } ``` - -## Create A Note For An Order ## - -This API helps you to create a new note for an order. - -### HTTP Request ### - -<div class="api-endpoint"> - <div class="endpoint-data"> - <i class="label label-post">POST</i> - <h6>/wc-api/v3/orders/<id>/notes</h6> - </div> -</div> - -```shell -curl -X POST https://example.com/wc-api/v3/orders/645/notes \ - -u consumer_key:consumer_secret \ - -H "Content-Type: application/json" \ - -d '{ - "order_note": { - "note": "Order ok!!!" - } -}' -``` - -```javascript -var data = { - order_note: { - note: 'Order ok!!!' - } -}; - -WooCommerce.post('orders/645/notes', data, function(err, data, res) { - console.log(res); -}); -``` - -```python -data = { - "order_note": { - "note": "Order ok!!!" - } -} - -print(wcapi.post("orders/645/notes", data).json()) -``` - -```ruby -data = { - order_note: { - note: "Order ok!!!" - } -} - -woocommerce.post("orders/645/notes", data).parsed_response -``` - -> JSON response example: - -```json -{ - "order_note": { - "id": "416", - "created_at": "2015-01-26T20:56:44Z", - "note": "Order ok!!!", - "customer_note": false - } -} -``` - -### Order Notes Properties ### - -| Attribute | Type | Description | -| --------------- | ------- | ------------------------------------------------------------------------------------------------------------------ | -| `id` | integer | Order note ID <i class="label label-info">read-only</i> | -| `created_at` | string | UTC DateTime when the order note was created <i class="label label-info">read-only</i> | -| `note` | string | Order note <i class="label label-info">required</i> | -| `customer_note` | boolean | Shows/define if the note is only for reference or for the customer (the user will be notified). Default is `false` | - -## View An Order Note ## - -This API lets you retrieve and view a specific note from an order. - -### HTTP Request ### - -<div class="api-endpoint"> - <div class="endpoint-data"> - <i class="label label-get">GET</i> - <h6>/wc-api/v3/orders/<id>/notes/<note_id></h6> - </div> -</div> - -```shell -curl https://example.com/wc-api/v3/orders/645/notes/416 \ - -u consumer_key:consumer_secret -``` - -```javascript -WooCommerce.get('orders/645/notes/416', function(err, data, res) { - console.log(res); -}); -``` - -```python -print(wcapi.get("orders/645/notes/416").json()) -``` - -```ruby -woocommerce.get("orders/645/notes/416").parsed_response -``` - -> JSON response example: - -```json -{ - "order_note": { - "id": "416", - "created_at": "2015-01-26T20:56:44Z", - "note": "Order ok!!!", - "customer_note": false - } -} -``` - -<aside class="notice"> - View the <a href="#order-notes-properties">Order Notes Properties</a> for more details on this response. -</aside> - -## View List Of Notes From An Order ## - -This API helps you to view all the notes from an order. - -### HTTP Request ### - -<div class="api-endpoint"> - <div class="endpoint-data"> - <i class="label label-get">GET</i> - <h6>/wc-api/v3/orders/<id>/notes</h6> - </div> -</div> - -```shell -curl https://example.com/wc-api/v3/orders/645/notes \ - -u consumer_key:consumer_secret -``` - -```javascript -WooCommerce.get('orders/645/notes', function(err, data, res) { - console.log(res); -}); -``` - -```python -print(wcapi.get("orders/645/notes").json()) -``` - -```ruby -woocommerce.get("orders/645/notes").parsed_response -``` - -> JSON response example: - -```json -{ - "order_notes": [ - { - "id": "416", - "created_at": "2015-01-26T20:56:44Z", - "note": "Order ok!!!", - "customer_note": false - }, - { - "id": "415", - "created_at": "2015-01-26T20:16:14Z", - "note": "Order status changed from Processing to Completed.", - "customer_note": false - }, - { - "id": "412", - "created_at": "2015-01-26T20:00:21Z", - "note": "Order item stock reduced successfully.", - "customer_note": false - }, - { - "id": "411", - "created_at": "2015-01-26T20:00:09Z", - "note": "Order status changed from Pending Payment to Processing.", - "customer_note": false - } - ] -} -``` - -<aside class="notice"> - View the <a href="#order-notes-properties">Order Notes Properties</a> for more details on this response. -</aside> - -## Update An Order Note ## - -This API lets you make changes to an order note. - -### HTTP Request ### - -<div class="api-endpoint"> - <div class="endpoint-data"> - <i class="label label-put">PUT</i> - <h6>/wc-api/v3/orders/<id>/notes/<note_id></h6> - </div> -</div> - -```shell -curl -X PUT https://example.com/wc-api/v3/orders/645/notes/416 \ - -u consumer_key:consumer_secret \ - -H "Content-Type: application/json" \ - -d '{ - "order_note": { - "note": "Ok!" - } -}' -``` - -```javascript -var data = { - order_note: { - note: 'Ok!' - } -}; - -WooCommerce.put('orders/645/notes/416', data, function(err, data, res) { - console.log(res); -}); -``` - -```python -data = { - "order_note": { - "note": "Ok!" - } -} - -print(wcapi.put("orders/645/notes/416", data).json()) -``` - -```ruby -data = { - order_note: { - note: "Ok!" - } -} - -woocommerce.put("orders/645/notes/416", data).parsed_response -``` - -> JSON response example: - -```json -{ - "order_note": { - "id": "416", - "created_at": "2015-01-26T20:56:44Z", - "note": "Ok!", - "customer_note": false - } -} -``` - -<aside class="notice"> - View the <a href="#order-notes-properties">Order Notes Properties</a> for more details on this response. -</aside> - -## Delete An Order Note ## - -This API helps you delete an order note. - -### HTTP Request ### - -<div class="api-endpoint"> - <div class="endpoint-data"> - <i class="label label-delete">DELETE</i> - <h6>/wc-api/v3/orders/<id>/notes/<note_id></h6> - </div> -</div> - -```shell -curl -X DELETE https://example.com/wc-api/v3/orders/645/notes/416 \ - -u consumer_key:consumer_secret -``` - -```javascript -WooCommerce.delete('orders/645/notes/416', function(err, data, res) { - console.log(res); -}); -``` - -```python -print(wcapi.delete("orders/645/notes/416").json()) -``` - -```ruby -woocommerce.delete("orders/645/notes/416").parsed_response -``` - -> JSON response example: - -```json -{ - "message": "Permanently deleted order note" -} -``` - -## Create A Refund For An Order ## - -This API helps you to create a new refund for an order. - -### HTTP Request ### - -<div class="api-endpoint"> - <div class="endpoint-data"> - <i class="label label-post">POST</i> - <h6>/wc-api/v3/orders/<id>/refunds</h6> - </div> -</div> - -```shell -curl -X POST https://example.com/wc-api/v3/orders/645/refunds \ - -u consumer_key:consumer_secret \ - -H "Content-Type: application/json" \ - -d '{ - "order_refund": { - "amount": 10 - } -}' -``` - -```javascript -var data = { - order_refund: { - amount: 10 - } -}; - -WooCommerce.post('orders/645/refunds', data, function(err, data, res) { - console.log(res); -}); -``` - -```python -data = { - "order_refund": { - "amount": 10 - } -} - -print(wcapi.post("orders/645/refunds", data).json()) -``` - -```ruby -data = { - order_refund: { - amount: 10 - } -} - -woocommerce.post("orders/645/refunds", data).parsed_response -``` - -> JSON response example: - -```json -{ - "order_refund": { - "id": 649, - "created_at": "2015-01-26T19:29:32Z", - "amount": "10.00", - "reason": "", - "line_items": [] - } -} -``` - -### Order Refunds Properties ### - -| Attribute | Type | Description | -| ------------ | ------- | ---------------------------------------------------------------------------------------- | -| `id` | integer | Order note ID <i class="label label-info">read-only</i> | -| `created_at` | string | UTC DateTime when the order refund was created <i class="label label-info">read-only</i> | -| `amount` | float | Refund amount <i class="label label-info">required</i> | -| `reason` | string | Reason for refund | -| `line_items` | array | List of order items to refund. See [Line Items Properties](line-items-properties) | - -## View An Order Refund ## - -This API lets you retrieve and view a specific refund from an order. - -### HTTP Request ### - -<div class="api-endpoint"> - <div class="endpoint-data"> - <i class="label label-get">GET</i> - <h6>/wc-api/v3/orders/<id>/refunds/<refund_id></h6> - </div> -</div> - -```shell -curl https://example.com/wc-api/v3/orders/645/refunds/649 \ - -u consumer_key:consumer_secret -``` - -```javascript -WooCommerce.get('orders/645/refunds/649', function(err, data, res) { - console.log(res); -}); -``` - -```python -print(wcapi.get("orders/645/refunds/649").json()) -``` - -```ruby -woocommerce.get("orders/645/refunds/649").parsed_response -``` - -> JSON response example: - -```json -{ - "order_refund": { - "id": 649, - "created_at": "2015-01-26T19:29:32Z", - "amount": "10.00", - "reason": "", - "line_items": [] - } -} -``` - -<aside class="notice"> - View the <a href="#order-refunds-properties">Order Refunds Properties</a> for more details on this response. -</aside> - -## View List Of Refunds From An Order ## - -This API helps you to view all the refunds from an order. - -### HTTP Request ### - -<div class="api-endpoint"> - <div class="endpoint-data"> - <i class="label label-get">GET</i> - <h6>/wc-api/v3/orders/<id>/refunds</h6> - </div> -</div> - -```shell -curl https://example.com/wc-api/v3/orders/645/refunds \ - -u consumer_key:consumer_secret -``` - -```javascript -WooCommerce.get('orders/645/refunds', function(err, data, res) { - console.log(res); -}); -``` - -```python -print(wcapi.get("orders/645/refunds").json()) -``` - -```ruby -woocommerce.get("orders/645/refunds").parsed_response -``` - -> JSON response example: - -```json -{ - "order_refunds": [ - { - "id": 649, - "created_at": "2015-01-26T19:29:32Z", - "amount": "10.00", - "reason": "", - "line_items": [] - }, - { - "id": 647, - "created_at": "2015-01-26T19:19:06Z", - "amount": "21.99", - "reason": "", - "line_items": [ - { - "id": 514, - "subtotal": "-21.99", - "subtotal_tax": "0.00", - "total": "-21.99", - "total_tax": "0.00", - "price": "-21.99", - "quantity": 1, - "tax_class": "reduced-rate", - "name": "Premium Quality", - "product_id": 546, - "sku": "", - "meta": [] - }, - { - "id": 515, - "subtotal": "0.00", - "subtotal_tax": "0.00", - "total": "0.00", - "total_tax": "0.00", - "price": "0.00", - "quantity": 0, - "tax_class": null, - "name": "Ship Your Idea", - "product_id": 613, - "sku": "", - "meta": [] - } - ] - } - ] -} -``` - -<aside class="notice"> - View the <a href="#order-refunds-properties">Order Refunds Properties</a> for more details on this response. -</aside> - -## Update An Order Refund ## - -This API lets you make changes to an order refund. - -### HTTP Request ### - -<div class="api-endpoint"> - <div class="endpoint-data"> - <i class="label label-put">PUT</i> - <h6>/wc-api/v3/orders/<id>/refunds/<refund_id></h6> - </div> -</div> - -```shell -curl -X PUT https://example.com/wc-api/v3/orders/645/refunds/649 \ - -u consumer_key:consumer_secret \ - -H "Content-Type: application/json" \ - -d '{ - "order_refund": { - "reason": "Because was it necessary!" - } -}' -``` - -```javascript -var data = { - order_refund: { - reason: 'Because was it necessary!' - } -}; - -WooCommerce.put('orders/645/refunds/649', data, function(err, data, res) { - console.log(res); -}); -``` - -```python -data = { - "order_refund": { - "reason": "Because was it necessary!" - } -} - -print(wcapi.put("orders/645/refunds/649", data).json()) -``` - -```ruby -data = { - order_refund: { - reason: "Because was it necessary!" - } -} - -woocommerce.put("orders/645/refunds/649", data).parsed_response -``` - -> JSON response example: - -```json -{ - "order_refund": { - "id": 649, - "created_at": "2015-01-26T19:29:32Z", - "amount": "10.00", - "reason": "Because was it necessary!", - "line_items": [] - } -} -``` - -<aside class="notice"> - View the <a href="#order-refunds-properties">Order Refunds Properties</a> for more details on this response. -</aside> - -## Delete An Order Refund ## - -This API helps you delete an order refund. - -### HTTP Request ### - -<div class="api-endpoint"> - <div class="endpoint-data"> - <i class="label label-delete">DELETE</i> - <h6>/wc-api/v3/orders/<id>/refunds/<refund_id></h6> - </div> -</div> - -```shell -curl -X DELETE https://example.com/wc-api/v3/orders/645/refunds/649 \ - -u consumer_key:consumer_secret -``` - -```javascript -WooCommerce.delete('orders/645/refunds/649', function(err, data, res) { - console.log(res); -}); -``` - -```python -print(wcapi.delete("orders/645/refunds/649").json()) -``` - -```ruby -woocommerce.delete("orders/645/refunds/649").parsed_response -``` - -> JSON response example: - -```json -{ - "message": "Permanently deleted refund" -} -``` diff --git a/source/includes/v3/_product-attribute-terms.md b/source/includes/v3/_product-attribute-terms.md new file mode 100644 index 00000000..6a6875ec --- /dev/null +++ b/source/includes/v3/_product-attribute-terms.md @@ -0,0 +1,370 @@ +# Product - Attribute Terms # + +This section lists all API endpoints that can be used to create, edit or otherwise manipulate product attribute terms. + +## Product Attribute Properties ## + +| Attribute | Type | Description | +| --------- | ------- | ------------------------------------------------------------------------------------- | +| `id` | integer | Term ID (term ID) <i class="label label-info">read-only</i> | +| `name` | string | Term name <i class="label label-info">required</i> | +| `slug` | string | Term slug | +| `count` | boolean | Shows the quantity of products in this term <i class="label label-info">read-only</i> | + +## Create a Product Attribute Term ## + +This API helps you to create a new product attribute term. + +### HTTP Request ### + +<div class="api-endpoint"> + <div class="endpoint-data"> + <i class="label label-post">POST</i> + <h6>/wc-api/v3/products/attributes/<attribute_id>/terms</h6> + </div> +</div> + +```shell +curl -X POST https://example.com/wc-api/v3/products/attributes/1/terms \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "product_attribute_term": { + "name": "Black" + } +}' +``` + +```javascript +var data = { + product_attribute_term: { + name: 'Black' + } +}; + +WooCommerce.post('products/attributes/1/terms', data, function(err, data, res) { + console.log(res); +}); +``` + +```php +<?php +$data = [ + 'product_attribute_term' => [ + 'name' => 'Black' + ] +]; + +print_r($woocommerce->post('products/attributes/1/terms', $data)); +?> +``` + +```python +data = { + "product_attribute_term": { + "name": "Black" + } +} + +print(wcapi.post("products/attributes/1/terms", data).json()) +``` + +```ruby +data = { + product_attribute_term: { + name: "Black" + } +} + +woocommerce.post("products/attributes/1/terms", data).parsed_response +``` + +> JSON response example: + +```json +{ + "product_attribute_term": { + "id": 18, + "name": "Black", + "slug": "black", + "count": 0 + } +} +``` + +<aside class="notice"> + Endpoint introduced since WooCommerce 2.5. +</aside> + +## View a Product Attribute Term ## + +This API lets you retrieve a product attribute term by ID. + +<div class="api-endpoint"> + <div class="endpoint-data"> + <i class="label label-get">GET</i> + <h6>/wc-api/v3/products/attributes/<attribute_id>/terms/<id></h6> + </div> +</div> + +```shell +curl https://example.com/wc-api/v3/products/attributes/1/terms/18 \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('products/attributes/1/terms/18', function(err, data, res) { + console.log(res); +}); +``` + +```php +<?php print_r($woocommerce->get('products/attributes/1/terms/18')); ?> +``` + +```python +print(wcapi.get("products/attributes/1/terms/18").json()) +``` + +```ruby +woocommerce.get("products/attributes/1/terms/18").parsed_response +``` + +> JSON response example: + +```json +{ + "product_attribute_term": { + "id": 18, + "name": "Black", + "slug": "black", + "count": 5 + } +} +``` + +<aside class="notice"> + Endpoint introduced since WooCommerce 2.5. +</aside> + +## View List of Product Attribute Terms ## + +This API lets you retrieve all terms from a product attribute. + +<div class="api-endpoint"> + <div class="endpoint-data"> + <i class="label label-get">GET</i> + <h6>/wc-api/v3/products/attributes/<attribute_id>/terms</h6> + </div> +</div> + +```shell +curl https://example.com/wc-api/v3/products/attributes/1/terms \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('products/attributes/1/terms', function(err, data, res) { + console.log(res); +}); +``` + +```php +<?php print_r($woocommerce->get('products/attributes/1/terms')); ?> +``` + +```python +print(wcapi.get("products/attributes/1/terms").json()) +``` + +```ruby +woocommerce.get("products/attributes/1/terms").parsed_response +``` + +> JSON response example: + +```json +{ + "product_attribute_terms": [ + { + "id": 18, + "slug": "black", + "name": "Black", + "count": 5 + }, + { + "id": 20, + "slug": "blue", + "name": "Blue", + "count": 4 + }, + { + "id": 19, + "slug": "green", + "name": "Green", + "count": 4 + }, + { + "id": 24, + "slug": "pink", + "name": "Pink", + "count": 3 + }, + { + "id": 22, + "slug": "red", + "name": "Red", + "count": 3 + }, + { + "id": 21, + "slug": "white", + "name": "White", + "count": 3 + }, + { + "id": 23, + "slug": "yellow", + "name": "Yellow", + "count": 3 + } + ] +} +``` + +<aside class="notice"> + Endpoint introduced since WooCommerce 2.5. +</aside> + +## Update a Product Attribute Term ## + +This API lets you make changes to a product attribute term. + +### HTTP Request ### + +<div class="api-endpoint"> + <div class="endpoint-data"> + <i class="label label-put">PUT</i> + <h6>/wc-api/v3/products/attributes/<attribute_id>/terms/<id></h6> + </div> +</div> + +```shell +curl -X PUT https://example.com/wc-api/v3/products/attributes/1/terms/18 \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "product_attribute_term": { + "name": "BLACK" + } +}' +``` + +```javascript +var data = { + product_attribute_term: { + name: 'BLACK' + } +}; + +WooCommerce.put('products/attributes/1/terms/18', data, function(err, data, res) { + console.log(res); +}); +``` + +```php +<?php +$data = [ + 'product_attribute_term' => [ + 'name' => 'BLACK' + ] +]; + +print_r($woocommerce->put('products/attributes/1/terms/18', $data)); +?> +``` + +```python +data = { + "product_attribute_term": { + "name": "BLACK" + } +} + +print(wcapi.put("products/attributes/1/terms/18", data).json()) +``` + +```ruby +data = { + product_attribute_term: { + name: "BLACK" + } +} + +woocommerce.put("products/attributes/1/terms/18", data).parsed_response +``` + +> JSON response example: + +```json +{ + "product_attribute_term": { + "id": 18, + "name": "BLACK", + "slug": "black", + "count": 5 + } +} +``` + +<aside class="notice"> + Endpoint introduced since WooCommerce 2.5. +</aside> + +## Delete a Product Attribute Term ## + +This API helps you delete a product attribute term. + +### HTTP Request ### + +<div class="api-endpoint"> + <div class="endpoint-data"> + <i class="label label-delete">DELETE</i> + <h6>/wc-api/v3/products/attributes/<attribute_id>/terms/<id></h6> + </div> +</div> + +```shell +curl -X DELETE https://example.com/wc-api/v3/products/attributes/1/terms/18 \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.delete('products/attributes/1/terms/18', function(err, data, res) { + console.log(res); +}); +``` + +```php +<?php print_r($woocommerce->delete('products/attributes/1/terms/18')); ?> +``` + +```python +print(wcapi.delete("products/attributes/1/terms/18").json()) +``` + +```ruby +woocommerce.delete("products/attributes/1/terms/18").parsed_response +``` + +> JSON response example: + +```json +{ + "message": "Deleted product_attribute_term" +} +``` + +<aside class="notice"> + Endpoint introduced since WooCommerce 2.5. +</aside> diff --git a/source/includes/v3/_product-attributes.md b/source/includes/v3/_product-attributes.md new file mode 100644 index 00000000..112668d1 --- /dev/null +++ b/source/includes/v3/_product-attributes.md @@ -0,0 +1,354 @@ +# Product - Attributes # + +This section lists all API endpoints that can be used to create, edit or otherwise manipulate product attributes. + +## Product Attribute Properties ## + +| Attribute | Type | Description | +| -------------- | ------- | -------------------------------------------------------------------------------------------------------------------- | +| `id` | integer | Attribute ID <i class="label label-info">read-only</i> | +| `name` | string | Attribute name | +| `slug` | string | Attribute slug | +| `type` | string | Attribute type, the types available include by default are: `select` and `text` (some plugins can include new types) | +| `order_by` | string | Default sort order. Available: `menu_order`, `name`, `name_num` and `id` | +| `has_archives` | boolean | Enable/Disable attribute archives | + +## Create a Product Attribute ## + +This API helps you to create a new product attribute. + +### HTTP Request ### + +<div class="api-endpoint"> + <div class="endpoint-data"> + <i class="label label-post">POST</i> + <h6>/wc-api/v3/products/attributes</h6> + </div> +</div> + +```shell +curl -X POST https://example.com/wc-api/v3/products/attributes \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "product_attribute": { + "name": "Color", + "slug": "pa_color", + "type": "select", + "order_by": "menu_order", + "has_archives": true + } +}' +``` + +```javascript +var data = { + product_attribute: { + 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 +<?php +$data = [ + 'product_attribute' => [ + 'name' => 'Color', + 'slug' => 'pa_color', + 'type' => 'select', + 'order_by' => 'menu_order', + 'has_archives' => true + ] +]; + +print_r($woocommerce->post('products/attributes', $data)); +?> +``` + +```python +data = { + "product_attribute": { + "name": "Color", + "slug": "pa_color", + "type": "select", + "order_by": "menu_order", + "has_archives": True + } +} + +print(wcapi.post("products/attributes", data).json()) +``` + +```ruby +data = { + product_attribute: { + 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 +{ + "product_attribute": { + "id": 1, + "name": "Color", + "slug": "pa_color", + "type": "select", + "order_by": "menu_order", + "has_archives": true + } +} +``` + +## View a Product Attribute ## + +This API lets you retrieve and view a specific product attribute by ID. + +<div class="api-endpoint"> + <div class="endpoint-data"> + <i class="label label-get">GET</i> + <h6>/wc-api/v3/products/attributes/<id></h6> + </div> +</div> + +```shell +curl https://example.com/wc-api/v3/products/attributes/1 \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('products/attributes/1', function(err, data, res) { + console.log(res); +}); +``` + +```php +<?php print_r($woocommerce->get('products/attributes/1')); ?> +``` + +```python +print(wcapi.get("products/attributes/1").json()) +``` + +```ruby +woocommerce.get("products/attributes/1").parsed_response +``` + +> JSON response example: + +```json +{ + "product_attribute": { + "id": 1, + "name": "Color", + "slug": "pa_color", + "type": "select", + "order_by": "menu_order", + "has_archives": true + } +} +``` + +## View List of Product Attributes ## + +This API helps you to view all the product attributes. + +### HTTP Request ### + +<div class="api-endpoint"> + <div class="endpoint-data"> + <i class="label label-get">GET</i> + <h6>/wc-api/v3/products/attributes</h6> + </div> +</div> + +```shell +curl https://example.com/wc-api/v3/products/attributes \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('products/attributes', function(err, data, res) { + console.log(res); +}); +``` + +```php +<?php print_r($woocommerce->get('products/attributes')); ?> +``` + +```python +print(wcapi.get("products/attributes").json()) +``` + +```ruby +woocommerce.get("products/attributes").parsed_response +``` + +> JSON response example: + +```json +{ + "product_attributes": [ + { + "id": 1, + "name": "Color", + "slug": "pa_color", + "type": "select", + "order_by": "menu_order", + "has_archives": true + }, + { + "id": 2, + "name": "Size", + "slug": "pa_size", + "type": "select", + "order_by": "menu_order", + "has_archives": false + } + ] +} +``` + +## Update a Product Attribute ## + +This API lets you make changes to a product attribute. + +### HTTP Request ### + +<div class="api-endpoint"> + <div class="endpoint-data"> + <i class="label label-put">PUT</i> + <h6>/wc-api/v3/products/attributes/<id></h6> + </div> +</div> + +```shell +curl -X PUT https://example.com/wc-api/v3/products/attributes/1 \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "product_attribute": { + "order_by": "name" + } +}' +``` + +```javascript +var data = { + product_attribute: { + order_by: 'name' + } +}; + +WooCommerce.put('products/attributes/1', data, function(err, data, res) { + console.log(res); +}); +``` + +```php +<?php +$data = [ + 'product_attribute' => [ + 'order_by' => 'name' + ] +]; + +print_r($woocommerce->put('products/attributes/1', $data)); +?> +``` + +```python +data = { + "product_attribute": { + "order_by": "name" + } +} + +print(wcapi.put("products/attributes/1", data).json()) +``` + +```ruby +data = { + product_attribute: { + order_by: "name" + } +} + +woocommerce.put("products/attributes/1", data).parsed_response +``` + +> JSON response example: + +```json +{ + "product_attribute": { + "id": 1, + "name": "Color", + "slug": "pa_color", + "type": "select", + "order_by": "name", + "has_archives": true + } +} +``` + +## Delete a Product Attribute ## + +This API helps you delete a product attribute. + +### HTTP Request ### + +<div class="api-endpoint"> + <div class="endpoint-data"> + <i class="label label-delete">DELETE</i> + <h6>/wc-api/v3/products/attributes/<id></h6> + </div> +</div> + +```shell +curl -X DELETE https://example.com/wc-api/v3/products/attributes/1 \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.delete('products/attributes/1', function(err, data, res) { + console.log(res); +}); +``` + +```php +<?php print_r($woocommerce->delete('products/attributes/1')); ?> +``` + +```python +print(wcapi.delete("products/attributes/1").json()) +``` + +```ruby +woocommerce.delete("products/attributes/1").parsed_response +``` + +> JSON response example: + +```json +{ + "message": "Deleted product_attribute" +} +``` diff --git a/source/includes/v3/_product-categories.md b/source/includes/v3/_product-categories.md new file mode 100644 index 00000000..3ad89505 --- /dev/null +++ b/source/includes/v3/_product-categories.md @@ -0,0 +1,408 @@ +# Product - Categories # + +This section lists all API endpoints that can be used to create, edit or otherwise manipulate product categories. + +## Product Category Properties ## + +| Attribute | Type | Description | +| ------------- | ------- | ------------------------------------------------------------------------------------------------------------- | +| `id` | integer | Category ID (term ID) <i class="label label-info">read-only</i> | +| `name` | string | Category name <i class="label label-info">required</i> | +| `slug` | string | Category slug | +| `parent` | integer | Category parent | +| `description` | string | Category description | +| `display` | string | Category archive display type, the types available include: `default`, `products`, `subcategories` and `both` | +| `image` | string | Category image URL | +| `count` | boolean | Shows the quantity of products in this category <i class="label label-info">read-only</i> | + +## Create a Product Category ## + +This API helps you to create a new product category. + +### HTTP Request ### + +<div class="api-endpoint"> + <div class="endpoint-data"> + <i class="label label-post">POST</i> + <h6>/wc-api/v3/products/categories</h6> + </div> +</div> + +> Example of how to create a product category: + +```shell +curl -X POST https://example.com/wc-api/v3/products/categories \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "product_category": { + "name": "Clothing" + } +}' +``` + +```javascript +var data = { + product_category: { + name: 'Clothing' + } +}; + +WooCommerce.post('products/categories', data, function(err, data, res) { + console.log(res); +}); +``` + +```php +<?php +$data = [ + 'product_category' => [ + 'name' => 'Clothing' + ] +]; + +print_r($woocommerce->post('products/categories', $data)); +?> +``` + +```python +data = { + "product_category": { + "name": "Clothing" + } +} + +print(wcapi.post("products/categories", data).json()) +``` + +```ruby +data = { + product_category: { + name: "Clothing" + } +} + +woocommerce.post("products/categories", data).parsed_response +``` + +> JSON response example: + +```json +{ + "product_category": { + "id": 9, + "name": "Clothing", + "slug": "clothing", + "parent": 0, + "description": "", + "display": "default", + "image": "", + "count": 0 + } +} +``` + +<aside class="notice"> + Endpoint introduced since WooCommerce 2.5. +</aside> + +## View a Product Category ## + +This API lets you retrieve a product category by ID. + +<div class="api-endpoint"> + <div class="endpoint-data"> + <i class="label label-get">GET</i> + <h6>/wc-api/v3/products/categories/<id></h6> + </div> +</div> + +```shell +curl https://example.com/wc-api/v3/products/categories/9 \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('products/categories/9', function(err, data, res) { + console.log(res); +}); +``` + +```php +<?php print_r($woocommerce->get('products/categories/9')); ?> +``` + +```python +print(wcapi.get("products/categories/9").json()) +``` + +```ruby +woocommerce.get("products/categories/9").parsed_response +``` + +> JSON response example: + +```json +{ + "product_category": { + "id": 9, + "name": "Clothing", + "slug": "clothing", + "parent": 0, + "description": "", + "display": "default", + "image": "", + "count": 23 + } +} +``` + +## View List of Product Categories ## + +This API lets you retrieve all product categories. + +<div class="api-endpoint"> + <div class="endpoint-data"> + <i class="label label-get">GET</i> + <h6>/wc-api/v3/products/categories</h6> + </div> +</div> + +```shell +curl https://example.com/wc-api/v3/products/categories \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('products/categories', function(err, data, res) { + console.log(res); +}); +``` + +```php +<?php print_r($woocommerce->get('products/categories')); ?> +``` + +```python +print(wcapi.get("products/categories").json()) +``` + +```ruby +woocommerce.get("products/categories").parsed_response +``` + +> JSON response example: + +```json +{ + "product_categories": [ + { + "id": 15, + "name": "Albums", + "slug": "albums", + "parent": 11, + "description": "", + "display": "default", + "image": "", + "count": 4 + }, + { + "id": 9, + "name": "Clothing", + "slug": "clothing", + "parent": 0, + "description": "", + "display": "default", + "image": "", + "count": 23 + }, + { + "id": 10, + "name": "Hoodies", + "slug": "hoodies", + "parent": 9, + "description": "", + "display": "default", + "image": "", + "count": 6 + }, + { + "id": 11, + "name": "Music", + "slug": "music", + "parent": 0, + "description": "", + "display": "default", + "image": "", + "count": 6 + }, + { + "id": 12, + "name": "Posters", + "slug": "posters", + "parent": 0, + "description": "", + "display": "default", + "image": "", + "count": 5 + }, + { + "id": 13, + "name": "Singles", + "slug": "singles", + "parent": 11, + "description": "", + "display": "default", + "image": "", + "count": 2 + }, + { + "id": 14, + "name": "T-shirts", + "slug": "t-shirts", + "parent": 9, + "description": "", + "display": "default", + "image": "", + "count": 17 + } + ] +} +``` + +## Update a Product Category ## + +This API lets you make changes to a product category. + +### HTTP Request ### + +<div class="api-endpoint"> + <div class="endpoint-data"> + <i class="label label-put">PUT</i> + <h6>/wc-api/v3/products/categories/<id></h6> + </div> +</div> + +```shell +curl -X PUT https://example.com/wc-api/v3/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 +<?php +$data = [ + 'product_category' => [ + '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 +{ + "product_category": { + "id": 9, + "name": "Clothing", + "slug": "clothing", + "parent": 0, + "description": "All kinds of clothes.", + "display": "default", + "image": "", + "count": 23 + } +} +``` + +<aside class="notice"> + Endpoint introduced since WooCommerce 2.5. +</aside> + +## Delete a Product Category ## + +This API helps you delete a product category. + +### HTTP Request ### + +<div class="api-endpoint"> + <div class="endpoint-data"> + <i class="label label-delete">DELETE</i> + <h6>/wc-api/v3/products/categories/<id></h6> + </div> +</div> + +```shell +curl -X DELETE https://example.com/wc-api/v3/products/categories/9 \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.delete('products/categories/9', function(err, data, res) { + console.log(res); +}); +``` + +```php +<?php print_r($woocommerce->delete('products/categories/9')); ?> +``` + +```python +print(wcapi.delete("products/categories/9").json()) +``` + +```ruby +woocommerce.delete("products/categories/9").parsed_response +``` + +> JSON response example: + +```json +{ + "message": "Deleted product_category" +} +``` + +<aside class="notice"> + Endpoint introduced since WooCommerce 2.5. +</aside> diff --git a/source/includes/v3/_product-shipping-classes.md b/source/includes/v3/_product-shipping-classes.md new file mode 100644 index 00000000..7117d784 --- /dev/null +++ b/source/includes/v3/_product-shipping-classes.md @@ -0,0 +1,354 @@ +# Product - Shipping Classes # + +This section lists all API endpoints that can be used to create, edit or otherwise manipulate product shipping classes. + +## Product Shipping Class Properties ## + +| Attribute | Type | Description | +| ------------- | ------- | ----------------------------------------------------------------------------------------------- | +| `id` | integer | Shipping Class ID (term ID) <i class="label label-info">read-only</i> | +| `name` | string | Shipping Class name <i class="label label-info">required</i> | +| `slug` | string | Shipping Class slug | +| `parent` | integer | Shipping Class parent | +| `description` | string | Shipping Class description | +| `count` | boolean | Shows the quantity of products in this shipping class <i class="label label-info">read-only</i> | + +## Create a Product Shipping Class ## + +This API helps you to create a new product shipping class. + +### HTTP Request ### + +<div class="api-endpoint"> + <div class="endpoint-data"> + <i class="label label-post">POST</i> + <h6>/wc-api/v3/products/shipping_classes</h6> + </div> +</div> + +> Example of how to create a product shipping class: + +```shell +curl -X POST https://example.com/wc-api/v3/products/shipping_classes \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "product_shipping_class": { + "name": "Priority" + } +}' +``` + +```javascript +var data = { + product_shipping_class: { + name: 'Priority' + } +}; + +WooCommerce.post('products/shipping_classes', data, function(err, data, res) { + console.log(res); +}); +``` + +```php +<?php +$data = [ + 'product_shipping_class' => [ + 'name' => 'Priority' + ] +]; + +print_r($woocommerce->post('products/shipping_classes', $data)); +?> +``` + +```python +data = { + "product_shipping_class": { + "name": "Priority" + } +} + +print(wcapi.post("products/shipping_classes", data).json()) +``` + +```ruby +data = { + product_shipping_class: { + name: "Priority" + } +} + +woocommerce.post("products/shipping_classes", data).parsed_response +``` + +> JSON response example: + +```json +{ + "product_shipping_class": { + "id": 35, + "name": "Priority", + "slug": "priority", + "parent": 0, + "description": "", + "count": 0 + } +} +``` + +<aside class="notice"> + Endpoint introduced since WooCommerce 2.5. +</aside> + +## View a Product Shipping Class ## + +This API lets you retrieve a product shipping class by ID. + +<div class="api-endpoint"> + <div class="endpoint-data"> + <i class="label label-get">GET</i> + <h6>/wc-api/v3/products/shipping_classes/<id></h6> + </div> +</div> + +```shell +curl https://example.com/wc-api/v3/products/shipping_classes/35 \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('products/shipping_classes/35', function(err, data, res) { + console.log(res); +}); +``` + +```php +<?php print_r($woocommerce->get('products/shipping_classes/35')); ?> +``` + +```python +print(wcapi.get("products/shipping_classes/35").json()) +``` + +```ruby +woocommerce.get("products/shipping_classes/35").parsed_response +``` + +> JSON response example: + +```json +{ + "product_shipping_class": { + "id": 35, + "name": "Priority", + "slug": "priority", + "parent": 0, + "description": "", + "count": 0 + } +} +``` + +<aside class="notice"> + Endpoint introduced since WooCommerce 2.5. +</aside> + +## View List of Product Shipping Classes ## + +This API lets you retrieve all product shipping classes. + +<div class="api-endpoint"> + <div class="endpoint-data"> + <i class="label label-get">GET</i> + <h6>/wc-api/v3/products/shipping_classes</h6> + </div> +</div> + +```shell +curl https://example.com/wc-api/v3/products/shipping_classes \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('products/shipping_classes', function(err, data, res) { + console.log(res); +}); +``` + +```php +<?php print_r($woocommerce->get('products/shipping_classes')); ?> +``` + +```python +print(wcapi.get("products/shipping_classes").json()) +``` + +```ruby +woocommerce.get("products/shipping_classes").parsed_response +``` + +> JSON response example: + +```json +{ + "product_shipping_classes": [ + { + "id": 30, + "name": "Express", + "slug": "express", + "parent": 0, + "description": "", + "count": 1 + }, + { + "id": 35, + "name": "Priority", + "slug": "priority", + "parent": 0, + "description": "", + "count": 0 + } + ] +} +``` + +<aside class="notice"> + Endpoint introduced since WooCommerce 2.5. +</aside> + +## Update a Product Shipping Class ## + +This API lets you make changes to a product shipping class. + +### HTTP Request ### + +<div class="api-endpoint"> + <div class="endpoint-data"> + <i class="label label-put">PUT</i> + <h6>/wc-api/v3/products/shipping_classes/<id></h6> + </div> +</div> + +```shell +curl -X PUT https://example.com/wc-api/v3/products/shipping_classes/35 \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "product_shipping_class": { + "description": "Priority mail." + } +}' +``` + +```javascript +var data = { + product_shipping_class: { + description: 'Priority mail.' + } +}; + +WooCommerce.put('products/shipping_classes/35', data, function(err, data, res) { + console.log(res); +}); +``` + +```php +<?php +$data = [ + 'product_shipping_class' => [ + 'description' => 'Priority mail.' + ] +]; + +print_r($woocommerce->put('products/shipping_classes/35', $data)); +?> +``` + +```python +data = { + "product_shipping_class": { + "description": "Priority mail." + } +} + +print(wcapi.put("products/shipping_classes/35", data).json()) +``` + +```ruby +data = { + product_shipping_class: { + description: "Priority mail." + } +} + +woocommerce.put("products/shipping_classes/35", data).parsed_response +``` + +> JSON response example: + +```json +{ + "product_shipping_class": { + "id": 35, + "name": "Priority", + "slug": "priority", + "parent": 0, + "description": "Priority mail.", + "count": 0 + } +} +``` + +<aside class="notice"> + Endpoint introduced since WooCommerce 2.5. +</aside> + +## Delete a Product Shipping Class ## + +This API helps you delete a product shipping class. + +### HTTP Request ### + +<div class="api-endpoint"> + <div class="endpoint-data"> + <i class="label label-delete">DELETE</i> + <h6>/wc-api/v3/products/shipping_class/<id></h6> + </div> +</div> + +```shell +curl -X DELETE https://example.com/wc-api/v3/products/shipping_class/35 \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.delete('products/shipping_class/35', function(err, data, res) { + console.log(res); +}); +``` + +```php +<?php print_r($woocommerce->delete('products/shipping_classes/35')); ?> +``` + +```python +print(wcapi.delete("products/shipping_class/35").json()) +``` + +```ruby +woocommerce.delete("products/shipping_class/35").parsed_response +``` + +> JSON response example: + +```json +{ + "message": "Deleted product_shipping_class" +} +``` + +<aside class="notice"> + Endpoint introduced since WooCommerce 2.5. +</aside> diff --git a/source/includes/v3/_product-tags.md b/source/includes/v3/_product-tags.md new file mode 100644 index 00000000..b7e0c520 --- /dev/null +++ b/source/includes/v3/_product-tags.md @@ -0,0 +1,348 @@ +# Product - Tags # + +This section lists all API endpoints that can be used to create, edit or otherwise manipulate product tags. + +## Product Tag Properties ## + +| Attribute | Type | Description | +| ------------- | ------- | ------------------------------------------------------------------------------------ | +| `id` | integer | Tag ID (term ID) <i class="label label-info">read-only</i> | +| `name` | string | Tag name <i class="label label-info">required</i> | +| `slug` | string | Tag slug | +| `description` | string | Tag description | +| `count` | boolean | Shows the quantity of products in this tag <i class="label label-info">read-only</i> | + +## Create a Product Tag ## + +This API helps you to create a new product tag. + +### HTTP Request ### + +<div class="api-endpoint"> + <div class="endpoint-data"> + <i class="label label-post">POST</i> + <h6>/wc-api/v3/products/tags</h6> + </div> +</div> + +> Example of how to create a product tag: + +```shell +curl -X POST https://example.com/wc-api/v3/products/tags \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "product_tag": { + "name": "Leather Shoes" + } +}' +``` + +```javascript +var data = { + product_tag: { + name: 'Leather Shoes' + } +}; + +WooCommerce.post('products/tags', data, function(err, data, res) { + console.log(res); +}); +``` + +```php +<?php +$data = [ + 'product_tag': [ + 'name': 'Leather Shoes' + ] +]; + +print_r($woocommerce->post('products/tags', $data)); +?> +``` + +```python +data = { + "product_tag": { + "name": "Leather Shoes" + } +} + +print(wcapi.post("products/tags", data).json()) +``` + +```ruby +data = { + product_tag: { + name: "Leather Shoes" + } +} + +woocommerce.post("products/tags", data).parsed_response +``` + +> JSON response example: + +```json +{ + "product_tag": { + "id": 37, + "name": "Leather Shoes", + "slug": "leather-shoes", + "description": "", + "count": 0 + } +} +``` + +<aside class="notice"> + Endpoint introduced since WooCommerce 2.5. +</aside> + +## View a Product Tag ## + +This API lets you retrieve a product tag by ID. + +<div class="api-endpoint"> + <div class="endpoint-data"> + <i class="label label-get">GET</i> + <h6>/wc-api/v3/products/tags/<id></h6> + </div> +</div> + +```shell +curl https://example.com/wc-api/v3/products/tags/37 \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('products/tags/37', function(err, data, res) { + console.log(res); +}); +``` + +```php +<?php print_r($woocommerce->get('products/tags/37')); ?> +``` + +```python +print(wcapi.get("products/tags/37").json()) +``` + +```ruby +woocommerce.get("products/tags/37").parsed_response +``` + +> JSON response example: + +```json +{ + "product_tag": { + "id": 37, + "name": "Leather Shoes", + "slug": "leather-shoes", + "description": "", + "count": 0 + } +} +``` + +<aside class="notice"> + Endpoint introduced since WooCommerce 2.5. +</aside> + +## View List of Product Tags ## + +This API lets you retrieve all product tag. + +<div class="api-endpoint"> + <div class="endpoint-data"> + <i class="label label-get">GET</i> + <h6>/wc-api/v3/products/tags</h6> + </div> +</div> + +```shell +curl https://example.com/wc-api/v3/products/tags \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('products/tags', function(err, data, res) { + console.log(res); +}); +``` + +```php +<?php print_r($woocommerce->get('products/tags')); ?> +``` + +```python +print(wcapi.get("products/tags").json()) +``` + +```ruby +woocommerce.get("products/tags").parsed_response +``` + +> JSON response example: + +```json +{ + "product_tags": [ + { + "id": 37, + "name": "Leather Shoes", + "slug": "leather-shoes", + "description": "", + "count": 0 + }, + { + "id": 38, + "name": "Oxford Shoes", + "slug": "oxford-shoes", + "description": "", + "count": 0 + } + ] +} +``` + +<aside class="notice"> + Endpoint introduced since WooCommerce 2.5. +</aside> + +## Update a Product Tag ## + +This API lets you make changes to a product tag. + +### HTTP Request ### + +<div class="api-endpoint"> + <div class="endpoint-data"> + <i class="label label-put">PUT</i> + <h6>/wc-api/v3/products/tags/<id></h6> + </div> +</div> + +```shell +curl -X PUT https://example.com/wc-api/v3/products/tags/37 \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "product_tag": { + "description": "Genuine leather." + } +}' +``` + +```javascript +var data = { + product_tag: { + description: 'Genuine leather.' + } +}; + +WooCommerce.put('products/tags/37', data, function(err, data, res) { + console.log(res); +}); +``` + +```php +<?php +$data = [ + 'product_tag': [ + 'description': 'Genuine leather.' + ] +]; + +print_r($woocommerce->put('products/tags/37', $data)); +?> +``` + +```python +data = { + "product_tag": { + "description": "Genuine leather." + } +} + +print(wcapi.put("products/tags/37", data).json()) +``` + +```ruby +data = { + product_tag: { + description: "Genuine leather." + } +} + +woocommerce.put("products/tags/37", data).parsed_response +``` + +> JSON response example: + +```json +{ + "product_tag": { + "id": 37, + "name": "Leather Shoes", + "slug": "leather-shoes", + "description": "Genuine leather.", + "count": 0 + } +} +``` + +<aside class="notice"> + Endpoint introduced since WooCommerce 2.5. +</aside> + +## Delete a Product Tag ## + +This API helps you delete a product tag. + +### HTTP Request ### + +<div class="api-endpoint"> + <div class="endpoint-data"> + <i class="label label-delete">DELETE</i> + <h6>/wc-api/v3/products/tag/<id></h6> + </div> +</div> + +```shell +curl -X DELETE https://example.com/wc-api/v3/products/tag/37 \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.delete('products/tag/37', function(err, data, res) { + console.log(res); +}); +``` + +```php +<?php print_r($woocommerce->delete('products/tags/37')); ?> +``` + +```python +print(wcapi.delete("products/tag/37").json()) +``` + +```ruby +woocommerce.delete("products/tag/37").parsed_response +``` + +> JSON response example: + +```json +{ + "message": "Deleted product_tag" +} +``` + +<aside class="notice"> + Endpoint introduced since WooCommerce 2.5. +</aside> diff --git a/source/includes/v3/_products.md b/source/includes/v3/_products.md index cd5f6cc9..8424efae 100644 --- a/source/includes/v3/_products.md +++ b/source/includes/v3/_products.md @@ -1,6 +1,6 @@ # Products # -This section lists all API that can be used to create, edit or otherwise manipulate products. +This section lists all API endpoints that can be used to create, edit or otherwise manipulate products. ## Products Properties ## @@ -70,6 +70,11 @@ This section lists all API that can be used to create, edit or otherwise manipul | `parent` | array | List the product parent data when query for a variation <i class="label label-info">read-only</i> | | `product_url` | string | Product external URL. Only for `external` products <i class="label label-info">write-only</i> | | `button_text` | string | Product external button text. Only for `external` products <i class="label label-info">write-only</i> | +| `menu_order` | integer | Menu order, used to custom sort products | + +<aside class="notice"> + <code>menu_order</code> attribute is available starting from WooCommerce 2.5. +</aside> ### Dimensions Properties ### @@ -88,10 +93,14 @@ This section lists all API that can be used to create, edit or otherwise manipul | `created_at` | string | UTC DateTime when the image was created <i class="label label-info">read-only</i> | | `updated_at` | string | UTC DateTime when the image was last updated <i class="label label-info">read-only</i> | | `src` | string | Image URL. In write-mode you can use to send new images | -| `title` | string | Image title (attachment title) <i class="label label-info">read-only</i> | -| `alt` | string | Image alt text (attachment image alt text) <i class="label label-info">read-only</i> | +| `title` | string | Image title (attachment title) | +| `alt` | string | Image alt text (attachment image alt text) | | `position` | integer | Image position. `0` means that the image is featured | +<aside class="notice"> + <code>alt</code> and <code>title</code> attributes are writable starting from WooCommerce 2.5. +</aside> + ### Attributes Properties ### | Attribute | Type | Description | @@ -155,7 +164,7 @@ This section lists all API that can be used to create, edit or otherwise manipul | `download_limit` | integer | Amount of times the variation can be downloaded. In write-mode you can sent a blank string for unlimited re-downloads. e.g `''` | | `download_expiry` | integer | Number of days that the customer has up to be able to download the varition. In write-mode you can sent a blank string for never expiry. e.g `''` | -## Create A Product ## +## Create a Product ## This API helps you to create a new product. @@ -229,6 +238,36 @@ WooCommerce.post('products', data, function(err, data, res) { }); ``` +```php +<?php +$data = [ + 'product' => [ + 'title' => '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' => [ + 9, + 14 + ], + 'images' => [ + [ + 'src' => 'http://example.com/wp-content/uploads/2015/01/premium-quality-front.jpg', + 'position' => 0 + ], + [ + 'src' => 'http://example.com/wp-content/uploads/2015/01/premium-quality-back.jpg', + 'position' => 1 + ] + ] + ] +]; + +print_r($woocommerce->post('products', $data)); +?> +``` + ```python data = { "product": { @@ -378,7 +417,9 @@ woocommerce.post("products", data).parsed_response "purchase_note": "", "total_sales": 0, "variations": [], - "parent": [] + "parent": [], + "grouped_products": [], + "menu_order": 0 } } ``` @@ -566,6 +607,97 @@ WooCommerce.post('products', data, function(err, data, res) { }); ``` +```php +<?php +$data = [ + 'product' => [ + 'title' => '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' => [ + 9, + 14 + ], + 'images' => [ + [ + 'src' => 'http://example.com/wp-content/uploads/2015/01/ship-your-idea-black-front.jpg', + 'position' => 0 + ], + [ + 'src' => 'http://example.com/wp-content/uploads/2015/01/ship-your-idea-black-back.jpg', + 'position' => 1 + ], + [ + 'src' => 'http://example.com/wp-content/uploads/2015/01/ship-your-idea-green-front.jpg', + 'position' => 2 + ], + [ + 'src' => 'http://example.com/wp-content/uploads/2015/01/ship-your-idea-green-back.jpg', + 'position' => 3 + ] + ], + 'attributes' => [ + [ + 'name' => 'Color', + 'slug' => 'color', + 'position' => '0', + 'visible' => false, + 'variation' => true, + 'options' => [ + 'Black', + 'Green' + ] + ] + ], + 'default_attributes' => [ + [ + 'name' => 'Color', + 'slug' => 'color', + 'option' => 'Black' + ] + ], + 'variations' => [ + [ + 'regular_price' => '19.99', + 'image' => [ + [ + 'src' => 'http://example.com/wp-content/uploads/2015/01/ship-your-idea-black-front.jpg', + 'position' => 0 + ] + ], + 'attributes' => [ + [ + 'name' => 'Color', + 'slug' => 'color', + 'option' => 'black' + ] + ] + ], + [ + 'regular_price' => '19.99', + 'image' => [ + [ + 'src' => 'http://example.com/wp-content/uploads/2015/01/ship-your-idea-green-front.jpg', + 'position' => 0 + ] + ], + 'attributes' => [ + [ + 'name' => 'Color', + 'slug' => 'color', + 'option' => 'green' + ] + ] + ] + ] + ] +]; + +print_r($woocommerce->post('products', $data)); +?> +``` + ```python data = { "product": { @@ -972,12 +1104,14 @@ woocommerce.post("products", data).parsed_response "download_expiry": 0 } ], - "parent": [] + "parent": [], + "grouped_products": [], + "menu_order": 0 } } ``` -## View A Product ## +## View a Product ## This API lets you retrieve and view a specific product by ID. @@ -1001,6 +1135,10 @@ WooCommerce.get('products/546', function(err, data, res) { }); ``` +```php +<?php print_r($woocommerce->get('products/546')); ?> +``` + ```python print(wcapi.get("products/546").json()) ``` @@ -1102,12 +1240,14 @@ woocommerce.get("products/546").parsed_response "purchase_note": "", "total_sales": 0, "variations": [], - "parent": [] + "parent": [], + "grouped_products": [], + "menu_order": 0 } } ``` -## View List Of Products ## +## View List of Products ## This API helps you to view all the products. @@ -1131,6 +1271,10 @@ WooCommerce.get('products', function(err, data, res) { }); ``` +```php +<?php print_r($woocommerce->get('products')); ?> +``` + ```python print(wcapi.get("products").json()) ``` @@ -1233,7 +1377,9 @@ woocommerce.get("products").parsed_response "purchase_note": "", "total_sales": 0, "variations": [], - "parent": [] + "parent": [], + "grouped_products": [], + "menu_order": 0 }, { "title": "Ship Your Idea", @@ -1459,7 +1605,9 @@ woocommerce.get("products").parsed_response "download_expiry": 0 } ], - "parent": [] + "parent": [], + "grouped_products": [], + "menu_order": 0 } ] } @@ -1467,13 +1615,20 @@ woocommerce.get("products").parsed_response #### Available Filters #### -| Filter | Type | Description | -| ---------- | ------ | -------------------------------------------- | -| `type` | string | Products by type. eg: `simple` or `variable` | -| `category` | string | Products by category. | -| `sku` | string | Filter a product by SKU. | +| Filter | Type | Description | +| ---------------- | ------ | ---------------------------------------------------- | +| `type` | string | Products by type. eg: `simple` or `variable`. | +| `category` | string | Products by category. | +| `tag` | string | Products by tag. | +| `shipping_class` | string | Products by shipping class. | +| `pa_*` | string | Products by attributes. eg: `filter[pa_color]=black` | +| `sku` | string | Filter a product by SKU. | -## Update A Product ## +<aside class="notice"> + <code>tag</code>, <code>shipping_class</code> and <code>pa_*</code> filters are available starting from WooCommerce 2.5. +</aside> + +## Update a Product ## This API lets you make changes to a product. @@ -1509,6 +1664,18 @@ WooCommerce.put('products/546', data, function(err, data, res) { }); ``` +```php +<?php +$data = [ + 'product' => [ + 'regular_price' => '24.54' + ] +]; + +print_r($woocommerce->put('products/546', $data)); +?> +``` + ```python data = { "product": { @@ -1622,7 +1789,9 @@ woocommerce.put("products/546", data).parsed_response "purchase_note": "", "total_sales": 0, "variations": [], - "parent": [] + "parent": [], + "grouped_products": [], + "menu_order": 0 } } ``` @@ -1643,7 +1812,7 @@ To update is necessary to send objects containing IDs and to create new not just </div> ```shell -curl -X PUT https://example.com/wc-api/v3/products/bulk \ +curl -X POST https://example.com/wc-api/v3/products/bulk \ -u consumer_key:consumer_secret \ -H "Content-Type: application/json" \ -d '{ @@ -1674,29 +1843,57 @@ var data = { products: [ { id: 546, - regular_price: "29.99" + regular_price: '29.99' }, { id: 604, variations: [ { id: 609, - regular_price: "29.99" + regular_price: '29.99' }, { id: 611, - regular_price: "29.99" + regular_price: '29.99' } ] } ] }; -WooCommerce.put('products/bulk', data, function(err, data, res) { +WooCommerce.post('products/bulk', data, function(err, data, res) { console.log(res); }); ``` +```php +<?php +$data = [ + 'products' => [ + [ + 'id' => 546, + 'regular_price' => '29.99' + ], + [ + 'id' => 604, + 'variations' => [ + [ + 'id' => 609, + 'regular_price' => '29.99' + ], + [ + 'id' => 611, + 'regular_price' => '29.99' + ] + ] + ] + ] +]; + +print_r($woocommerce->post('products/bulk', $data)); +?> +``` + ```python data = { "products": [ @@ -1720,7 +1917,7 @@ data = { ] } -print(wcapi.put("products/bulk", data).json()) +print(wcapi.post("products/bulk", data).json()) ``` ```ruby @@ -1746,7 +1943,7 @@ data = { ] } -woocommerce.put("products/bulk", data).parsed_response +woocommerce.post("products/bulk", data).parsed_response ``` > JSON response example: @@ -1843,7 +2040,9 @@ woocommerce.put("products/bulk", data).parsed_response "purchase_note": "", "total_sales": 0, "variations": [], - "parent": [] + "parent": [], + "grouped_products": [], + "menu_order": 0 }, { "title": "Ship Your Idea", @@ -2069,13 +2268,15 @@ woocommerce.put("products/bulk", data).parsed_response "download_expiry": 0 } ], - "parent": [] + "parent": [], + "grouped_products": [], + "menu_order": 0 } ] } ``` -## Delete A Product ## +## Delete a Product ## This API helps you delete a product. @@ -2099,6 +2300,10 @@ WooCommerce.delete('products/546?force=true', function(err, data, res) { }); ``` +```php +<?php print_r($woocommerce->delete('products/546', ['force' => true])); ?> +``` + ```python print(wcapi.delete("products/546?force=true").json()) ``` @@ -2145,6 +2350,10 @@ WooCommerce.get('products/count', function(err, data, res) { }); ``` +```php +<?php print_r($woocommerce->get('products/count')); ?> +``` + ```python print(wcapi.get("products/count").json()) ``` @@ -2163,509 +2372,20 @@ woocommerce.get("products/count").parsed_response #### Available Filters #### -| Filter | Type | Description | -| ---------- | ------ | -------------------------------------------- | -| `type` | string | Products by type. eg: `simple` or `variable` | -| `category` | string | Products by category. | - -## Create A Product Attribute ## - -This API helps you to create a new product attribute. - -### HTTP Request ### - -<div class="api-endpoint"> - <div class="endpoint-data"> - <i class="label label-post">POST</i> - <h6>/wc-api/v3/products/attributes</h6> - </div> -</div> - -```shell -curl -X POST https://example.com/wc-api/v3/products/attributes \ - -u consumer_key:consumer_secret \ - -H "Content-Type: application/json" \ - -d '{ - "product_attribute": { - "name": "Color", - "slug": "pa_color", - "type": "select", - "order_by": "menu_order", - "has_archives": true - } -}' -``` - -```javascript -var data = { - product_attribute: { - 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); -}); -``` - -```python -data = { - "product_attribute": { - "name": "Color", - "slug": "pa_color", - "type": "select", - "order_by": "menu_order", - "has_archives": True - } -} - -print(wcapi.post("products/attributes", data).json()) -``` - -```ruby -data = { - product_attribute: { - 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 -{ - "product_attribute": { - "id": 1, - "name": "Color", - "slug": "pa_color", - "type": "select", - "order_by": "menu_order", - "has_archives": true - } -} -``` - -### Product Attribute Properties ### - -| Attribute | Type | Description | -| -------------- | ------- | -------------------------------------------------------------------------------------------------------------------- | -| `id` | integer | Attribute ID <i class="label label-info">read-only</i> | -| `name` | string | Attribute name | -| `slug` | string | Attribute slug | -| `type` | string | Attribute type, the types available include by default are: `select` and `text` (some plugins can include new types) | -| `order_by` | string | Default sort order. Available: `menu_order`, `name`, `name_num` and `id` | -| `has_archives` | boolean | Enable/Disable attribute archives | - -## View A Product Attribute ## - -This API lets you retrieve and view a specific product attribute by ID. - -<div class="api-endpoint"> - <div class="endpoint-data"> - <i class="label label-get">GET</i> - <h6>/wc-api/v3/products/attributes/<id></h6> - </div> -</div> - -```shell -curl https://example.com/wc-api/v3/products/attributes/1 \ - -u consumer_key:consumer_secret -``` - -```javascript -WooCommerce.get('products/attributes/1', function(err, data, res) { - console.log(res); -}); -``` - -```python -print(wcapi.get("products/attributes/1").json()) -``` - -```ruby -woocommerce.get("products/attributes/1").parsed_response -``` - -> JSON response example: - -```json -{ - "product_attribute": { - "id": 1, - "name": "Color", - "slug": "pa_color", - "type": "select", - "order_by": "menu_order", - "has_archives": true - } -} -``` - -<aside class="notice"> - View the <a href="#product-attribute-properties">Product Attribute Properties</a> for more details on this response. -</aside> - -## View List Of Product Attributes ## - -This API helps you to view all the product attributes. - -### HTTP Request ### - -<div class="api-endpoint"> - <div class="endpoint-data"> - <i class="label label-get">GET</i> - <h6>/wc-api/v3/products/attributes</h6> - </div> -</div> - -```shell -curl https://example.com/wc-api/v3/products/attributes \ - -u consumer_key:consumer_secret -``` - -```javascript -WooCommerce.get('products/attributes', function(err, data, res) { - console.log(res); -}); -``` - -```python -print(wcapi.get("products/attributes").json()) -``` - -```ruby -woocommerce.get("products/attributes").parsed_response -``` - -> JSON response example: - -```json -{ - "product_attributes": [ - { - "id": 1, - "name": "Color", - "slug": "pa_color", - "type": "select", - "order_by": "menu_order", - "has_archives": true - }, - { - "id": 2, - "name": "Size", - "slug": "pa_size", - "type": "select", - "order_by": "menu_order", - "has_archives": false - } - ] -} -``` - -<aside class="notice"> - View the <a href="#product-attribute-properties">Product Attribute Properties</a> for more details on this response. -</aside> - -## Update A Product Attribute ## - -This API lets you make changes to a product attribute. - -### HTTP Request ### - -<div class="api-endpoint"> - <div class="endpoint-data"> - <i class="label label-put">PUT</i> - <h6>/wc-api/v3/products/attributes/<id></h6> - </div> -</div> - -```shell -curl -X PUT https://example.com/wc-api/v3/products/attributes/1 \ - -u consumer_key:consumer_secret \ - -H "Content-Type: application/json" \ - -d '{ - "product_attribute": { - "order_by": "name" - } -}' -``` - -```javascript -var data = { - product_attribute: { - order_by: 'name' - } -}; - -WooCommerce.put('products/attributes/1', data, function(err, data, res) { - console.log(res); -}); -``` - -```python -data = { - "product_attribute": { - "order_by": "name" - } -} - -print(wcapi.put("products/attributes/1", data).json()) -``` - -```ruby -data = { - product_attribute: { - order_by: "name" - } -} - -woocommerce.put("products/attributes/1", data).parsed_response -``` - -> JSON response example: - -```json -{ - "product_attribute": { - "id": 1, - "name": "Color", - "slug": "pa_color", - "type": "select", - "order_by": "name", - "has_archives": true - } -} -``` - -<aside class="notice"> - View the <a href="#product-attribute-properties">Product Attribute Properties</a> for more details on this response. -</aside> - -## Delete A Product Attribute ## - -This API helps you delete a product attribute. - -### HTTP Request ### - -<div class="api-endpoint"> - <div class="endpoint-data"> - <i class="label label-delete">DELETE</i> - <h6>/wc-api/v3/products/attributes/<id></h6> - </div> -</div> - -```shell -curl -X DELETE https://example.com/wc-api/v3/products/attributes/1 \ - -u consumer_key:consumer_secret -``` - -```javascript -WooCommerce.delete('products/attributes/1', function(err, data, res) { - console.log(res); -}); -``` - -```python -print(wcapi.delete("products/attributes/1").json()) -``` - -```ruby -woocommerce.delete("products/attributes/1").parsed_response -``` - -> JSON response example: - -```json -{ - "message": "Deleted product_attribute" -} -``` - -## View A Product Category ## - -This API lets you retrieve a product category. - -<div class="api-endpoint"> - <div class="endpoint-data"> - <i class="label label-get">GET</i> - <h6>/wc-api/v3/products/categories/<id></h6> - </div> -</div> - -```shell -curl https://example.com/wc-api/v3/products/categories/9 \ - -u consumer_key:consumer_secret -``` - -```javascript -WooCommerce.get('products/categories/9', function(err, data, res) { - console.log(res); -}); -``` - -```python -print(wcapi.get("products/categories/9").json()) -``` - -```ruby -woocommerce.get("products/categories/9").parsed_response -``` - -> JSON response example: - -```json -{ - "product_category": { - "id": 9, - "name": "Clothing", - "slug": "clothing", - "parent": 0, - "description": "", - "display": "default", - "image": "", - "count": 23 - } -} -``` - -### Product Category Properties ### - -| Attribute | Type | Description | -| ------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `id` | integer | Category ID (term ID) <i class="label label-info">read-only</i> | -| `name` | string | Category name <i class="label label-info">read-only</i> | -| `slug` | string | Category slug <i class="label label-info">read-only</i> | -| `parent` | integer | Category parent <i class="label label-info">read-only</i> | -| `description` | string | Category description <i class="label label-info">read-only</i> | -| `display` | string | Category archive display type, the types available include: `default`, `products`, `subcategories` and `both` <i class="label label-info">read-only</i> | -| `image` | string | Category image URL <i class="label label-info">read-only</i> | -| `count` | boolean | Shows the quantity of products in this category <i class="label label-info">read-only</i> | - - -## View List Of Product Categories ## - -This API lets you retrieve all product categories. - -<div class="api-endpoint"> - <div class="endpoint-data"> - <i class="label label-get">GET</i> - <h6>/wc-api/v3/products/categories</h6> - </div> -</div> - -```shell -curl https://example.com/wc-api/v3/products/categories \ - -u consumer_key:consumer_secret -``` - -```javascript -WooCommerce.get('products/categories', function(err, data, res) { - console.log(res); -}); -``` - -```python -print(wcapi.get("products/categories").json()) -``` - -```ruby -woocommerce.get("products/categories").parsed_response -``` - -> JSON response example: - -```json -{ - "product_categories": [ - { - "id": 15, - "name": "Albums", - "slug": "albums", - "parent": 11, - "description": "", - "display": "default", - "image": "", - "count": 4 - }, - { - "id": 9, - "name": "Clothing", - "slug": "clothing", - "parent": 0, - "description": "", - "display": "default", - "image": "", - "count": 23 - }, - { - "id": 10, - "name": "Hoodies", - "slug": "hoodies", - "parent": 9, - "description": "", - "display": "default", - "image": "", - "count": 6 - }, - { - "id": 11, - "name": "Music", - "slug": "music", - "parent": 0, - "description": "", - "display": "default", - "image": "", - "count": 6 - }, - { - "id": 12, - "name": "Posters", - "slug": "posters", - "parent": 0, - "description": "", - "display": "default", - "image": "", - "count": 5 - }, - { - "id": 13, - "name": "Singles", - "slug": "singles", - "parent": 11, - "description": "", - "display": "default", - "image": "", - "count": 2 - }, - { - "id": 14, - "name": "T-shirts", - "slug": "t-shirts", - "parent": 9, - "description": "", - "display": "default", - "image": "", - "count": 17 - } - ] -} -``` +| Filter | Type | Description | +| ---------------- | ------ | ---------------------------------------------------- | +| `type` | string | Products by type. eg: `simple` or `variable`. | +| `category` | string | Products by category. | +| `tag` | string | Products by tag. | +| `shipping_class` | string | Products by shipping class. | +| `pa_*` | string | Products by attributes. eg: `filter[pa_color]=black` | +| `sku` | string | Filter a product by SKU. | <aside class="notice"> - View the <a href="#product-category-properties">Product Category Properties</a> for more details on this response. + <code>tag</code>, <code>shipping_class</code> and <code>pa_*</code> filters are available starting from WooCommerce 2.5. </aside> -## View List Of Product Orders ## +## View List of Product Orders ## This API lets you retrieve all product orders. @@ -2687,6 +2407,10 @@ WooCommerce.get('products/546/orders', function(err, data, res) { }); ``` +```php +<?php print_r($woocommerce->get('products/546/orders')); ?> +``` + ```python print(wcapi.get("products/546/orders").json()) ``` @@ -3008,7 +2732,7 @@ woocommerce.get("products/546/orders").parsed_response View the <a href="#orders-properties">Order Properties</a> for more details on this response. </aside> -## View List Of Product Reviews ## +## View List of Product Reviews ## This API lets you retrieve all reviews of a product. @@ -3030,6 +2754,10 @@ WooCommerce.get('products/546/reviews', function(err, data, res) { }); ``` +```php +<?php print_r($woocommerce->get('products/546/reviews')); ?> +``` + ```python print(wcapi.get("products/546/reviews").json()) ``` diff --git a/source/includes/v3/_reports.md b/source/includes/v3/_reports.md index d76a20ad..75cc8b15 100644 --- a/source/includes/v3/_reports.md +++ b/source/includes/v3/_reports.md @@ -1,10 +1,10 @@ # Reports # -This section lists all API that can be used view reports. +This section lists all API endpoints that can be used view reports. ## Reports Filters ## -Use the following filters for any type of report to specify the period of sales: +Use the following filters for any type of report to specify the period of sales: | Filter | Type | Description | | ---------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | @@ -12,7 +12,7 @@ Use the following filters for any type of report to specify the period of sales: | `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 dates need to be in the `YYYY-MM-AA` format. Required to set the `filter[date_min]` too | -## View List Of Reports ## +## View List of Reports ## This API lets you retrieve and view a simple list of available reports. @@ -36,6 +36,10 @@ WooCommerce.get('reports', function(err, data, res) { }); ``` +```php +<?php print_r($woocommerce->get('reports')); ?> +``` + ```python print(wcapi.get("reports").json()) ``` @@ -55,7 +59,7 @@ woocommerce.get("reports").parsed_response } ``` -## View List Of Sales Report ## +## View List of Sales Report ## This API lets you retrieve and view a list of sales report. @@ -79,12 +83,32 @@ WooCommerce.get('reports/sales?filter[date_min]=2015-01-18&filter[date_max]=2015 }); ``` +```php +<?php +$query = [ + 'filter' => [ + 'date_min' => '2015-01-18', + 'date_max' => '2015-01-21' + ] +]; + +print_r($woocommerce->get('reports/sales', $query)); +?> +``` + ```python print(wcapi.get("reports/sales?filter[date_min]=2015-01-18&filter[date_max]=2015-01-21").json()) ``` ```ruby -woocommerce.get("reports/sales?filter[date_min]=2015-01-18&filter[date_max]=2015-01-21").parsed_response +query = { + filter: { + date_min: "2015-01-18", + date_max: "2015-01-21" + } +} + +woocommerce.get("reports/sales", query).parsed_response ``` > JSON response example: @@ -143,7 +167,7 @@ woocommerce.get("reports/sales?filter[date_min]=2015-01-18&filter[date_max]=2015 } ``` -## View List Of Top Sellers Report ## +## View List of Top Sellers Report ## This API lets you retrieve and view a list of top sellers report. @@ -167,12 +191,30 @@ WooCommerce.get('reports/sales/top_sellers?filter[period]=last_month', function( }); ``` +```php +<?php +$query = [ + 'filter' => [ + 'period' => 'last_month' + ] +]; + +print_r($woocommerce->get('reports/sales/top_sellers', $query)); +?> +``` + ```python print(wcapi.get("reports/sales/top_sellers?filter[period]=last_month").json()) ``` ```ruby -woocommerce.get("reports/sales/top_sellers?filter[period]=last_month").parsed_response +query = { + filter: { + period: "last_month" + } +} + +woocommerce.get("reports/sales/top_sellers", query).parsed_response ``` > JSON response example: diff --git a/source/includes/v3/_tax-classes.md b/source/includes/v3/_tax-classes.md new file mode 100644 index 00000000..26d823af --- /dev/null +++ b/source/includes/v3/_tax-classes.md @@ -0,0 +1,254 @@ +# Tax - Classes # + +This section lists all API endpoints that can be used to create, edit or otherwise manipulate tax classes. + +## Taxes Properties ## + +| Attribute | Type | Description | +| --------- | ------ | -------------------------------------------------------- | +| `slug` | string | Tax class slug <i class="label label-info">read-only</i> | +| `name` | string | Tax class name | + +## Create a Tax Class ## + +This API helps you to create a new tax class. + +### HTTP Request ### + +<div class="api-endpoint"> + <div class="endpoint-data"> + <i class="label label-post">POST</i> + <h6>/wc-api/v3/taxes/classes</h6> + </div> +</div> + +```shell +curl -X POST https://example.com/wc-api/v3/taxes/classes \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "tax_class": { + "name": "Zero Rate" + } +}' +``` + +```javascript +var data = { + tax_class: { + name: 'Zero Rate' + } +}; + +WooCommerce.post('taxes/classes', data, function(err, data, res) { + console.log(res); +}); +``` + +```php +<?php +$data = [ + 'tax_class' => [ + 'name' => 'Zero Rate' + ] +]; + +print_r($woocommerce->post('taxes/classes', $data)); +?> +``` + +```python +data = { + "tax_class": { + "name": "Zero Rate" + } +} + +print(wcapi.post("taxes/classes", data).json()) +``` + +```ruby +data = { + tax_class: { + name: "Zero Rate" + } +} + +woocommerce.post("taxes/classes", data).parsed_response +``` + +> JSON response example: + +```json +{ + "tax_class": { + "slug": "zero-rate", + "name": "Zero Rate" + } +} +``` + +<aside class="notice"> + Endpoint introduced since WooCommerce 2.5. +</aside> + +## View List of Tax Classes ## + +This API helps you to view all the tax classes. + +### HTTP Request ### + +<div class="api-endpoint"> + <div class="endpoint-data"> + <i class="label label-get">GET</i> + <h6>/wc-api/v3/taxes/classes</h6> + </div> +</div> + +```shell +curl https://example.com/wc-api/v3/taxes/classes \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('taxes/classes', function(err, data, res) { + console.log(res); +}); +``` + +```php +<?php print_r($woocommerce->get('taxes/classes')); ?> +``` + +```python +print(wcapi.get("taxes/classes").json()) +``` + +```ruby +woocommerce.get("taxes/classes").parsed_response +``` + +> JSON response example: + +```json +{ + "tax_classes": [ + { + "slug": "standard", + "name": "Standard Rate" + }, + { + "slug": "reduced-rate", + "name": "Reduced Rate" + }, + { + "slug": "zero-rate", + "name": "Zero Rate" + } + ] +} +``` + +<aside class="notice"> + Endpoint introduced since WooCommerce 2.5. +</aside> + +## Delete a Tax Class ## + +This API helps you delete a tax class. + +<aside class="warning"> + This also will delete all tax rates from the selected class. +</aside> + +### HTTP Request ### + +<div class="api-endpoint"> + <div class="endpoint-data"> + <i class="label label-delete">DELETE</i> + <h6>/wc-api/v3/taxes/classes/<slug></h6> + </div> +</div> + +```shell +curl -X DELETE https://example.com/wc-api/v3/taxes/classes/zero-rate \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.delete('taxes/classes/zero-rate', function(err, data, res) { + console.log(res); +}); +``` + +```php +<?php print_r($woocommerce->delete('taxes/classes/zero-rate')); ?> +``` + +```python +print(wcapi.delete("taxes/classes/zero-rate").json()) +``` + +```ruby +woocommerce.delete("taxes/classes/zero-rate").parsed_response +``` + +> JSON response example: + +```json +{ + "message": "Deleted tax_class" +} +``` + +<aside class="notice"> + Endpoint introduced since WooCommerce 2.5. +</aside> + +## View Tax Rate Count ## + +This API lets you retrieve a count of all tax rates. + +### HTTP Request ### + +<div class="api-endpoint"> + <div class="endpoint-data"> + <i class="label label-get">GET</i> + <h6>/wc-api/v3/taxes/classes/count</h6> + </div> +</div> + +```shell +curl https://example.com/wc-api/v3/taxes/classes/count \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('taxes/classes/count', function(err, data, res) { + console.log(res); +}); +``` + +```php +<?php print_r($woocommerce->get('taxes/classes/count')); ?> +``` + +```python +print(wcapi.get("taxes/classes/count").json()) +``` + +```ruby +woocommerce.get("taxes/classes/count").parsed_response +``` + +> JSON response example: + +```json +{ + "count": 3 +} +``` + +<aside class="notice"> + Endpoint introduced since WooCommerce 2.5. +</aside> diff --git a/source/includes/v3/_taxes.md b/source/includes/v3/_taxes.md new file mode 100644 index 00000000..0bc76c30 --- /dev/null +++ b/source/includes/v3/_taxes.md @@ -0,0 +1,3282 @@ +# Taxes # + +This section lists all API endpoints that can be used to create, edit or otherwise manipulate tax rates. + +## Taxes Properties ## + +| Attribute | Type | Description | +| ---------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `id` | integer | Tax rate ID <i class="label label-info">read-only</i> | +| `country` | string | Country 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 | Choose whether or not this is a compound rate. Compound tax rates are applied on top of other tax rates. Default is `false` | +| `shipping` | boolean | Choose 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 ### + +<div class="api-endpoint"> + <div class="endpoint-data"> + <i class="label label-post">POST</i> + <h6>/wc-api/v3/taxes</h6> + </div> +</div> + +```shell +curl -X POST https://example.com/wc-api/v3/taxes \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "tax": { + "country": "US", + "state": "AL", + "rate": "4", + "name": "State Tax", + "shipping": false + } +}' +``` + +```javascript +var data = { + tax: { + country: 'US', + state: 'AL', + rate: '4', + name: 'State Tax', + shipping: false + } +}; + +WooCommerce.post('taxes', data, function(err, data, res) { + console.log(res); +}); +``` + +```php +<?php +$data = [ + 'tax' => [ + 'country' => 'US', + 'state' => 'AL', + 'rate' => '4', + 'name' => 'State Tax', + 'shipping' => false + ] +]; + +print_r($woocommerce->post('taxes', $data)); +?> +``` + +```python +data = { + "tax": { + "country": "US", + "state": "AL", + "rate": "4", + "name": "State Tax", + "shipping": False + } +} + +print(wcapi.post("taxes", data).json()) +``` + +```ruby +data = { + tax: { + country: "US", + state: "AL", + rate: "4", + name: "State Tax", + shipping: false + } +} + +woocommerce.post("taxes", data).parsed_response +``` + +> JSON response example: + +```json +{ + "tax": { + "id": 53, + "country": "US", + "state": "AL", + "postcode": "", + "city": "", + "rate": "4.0000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": false, + "order": 0, + "class": "standard" + } +} +``` + +<aside class="notice"> + Endpoint introduced since WooCommerce 2.5. +</aside> + +## View a Tax Rate ## + +This API lets you retrieve and view a specific tax rate by ID. + +<div class="api-endpoint"> + <div class="endpoint-data"> + <i class="label label-get">GET</i> + <h6>/wc-api/v3/taxes/<id></h6> + </div> +</div> + +```shell +curl https://example.com/wc-api/v3/taxes/53 \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('taxes/53', function(err, data, res) { + console.log(res); +}); +``` + +```php +<?php print_r($woocommerce->get('taxes/53')); ?> +``` + +```python +print(wcapi.get("taxes/53").json()) +``` + +```ruby +woocommerce.get("taxes/53").parsed_response +``` + +> JSON response example: + +```json +{ + "tax": { + "id": 53, + "country": "US", + "state": "AL", + "postcode": "", + "city": "", + "rate": "4.0000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": false, + "order": 0, + "class": "standard" + } +} +``` + +<aside class="notice"> + Endpoint introduced since WooCommerce 2.5. +</aside> + +## View List of Tax Rates ## + +This API helps you to view all the tax rates. + +### HTTP Request ### + +<div class="api-endpoint"> + <div class="endpoint-data"> + <i class="label label-get">GET</i> + <h6>/wc-api/v3/taxes</h6> + </div> +</div> + +```shell +curl https://example.com/wc-api/v3/taxes \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('taxes', function(err, data, res) { + console.log(res); +}); +``` + +```php +<?php print_r($woocommerce->get('taxes')); ?> +``` + +```python +print(wcapi.get("taxes").json()) +``` + +```ruby +woocommerce.get("taxes").parsed_response +``` + +> JSON response example: + +```json +{ + "taxes": [ + { + "id": 53, + "country": "US", + "state": "AL", + "postcode": "", + "city": "", + "rate": "4.0000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": false, + "order": 1, + "class": "standard" + }, + { + "id": 54, + "country": "US", + "state": "AZ", + "postcode": "", + "city": "", + "rate": "5.6000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": false, + "order": 2, + "class": "standard" + }, + { + "id": 55, + "country": "US", + "state": "AR", + "postcode": "", + "city": "", + "rate": "6.5000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": true, + "order": 3, + "class": "standard" + }, + { + "id": 56, + "country": "US", + "state": "CA", + "postcode": "", + "city": "", + "rate": "7.5000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": false, + "order": 4, + "class": "standard" + }, + { + "id": 57, + "country": "US", + "state": "CO", + "postcode": "", + "city": "", + "rate": "2.9000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": false, + "order": 5, + "class": "standard" + }, + { + "id": 58, + "country": "US", + "state": "CT", + "postcode": "", + "city": "", + "rate": "6.3500", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": true, + "order": 6, + "class": "standard" + }, + { + "id": 59, + "country": "US", + "state": "DC", + "postcode": "", + "city": "", + "rate": "5.7500", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": true, + "order": 7, + "class": "standard" + }, + { + "id": 60, + "country": "US", + "state": "FL", + "postcode": "", + "city": "", + "rate": "6.0000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": true, + "order": 8, + "class": "standard" + }, + { + "id": 61, + "country": "US", + "state": "GA", + "postcode": "", + "city": "", + "rate": "4.0000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": true, + "order": 9, + "class": "standard" + }, + { + "id": 62, + "country": "US", + "state": "GU", + "postcode": "", + "city": "", + "rate": "4.0000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": false, + "order": 10, + "class": "standard" + }, + { + "id": 63, + "country": "US", + "state": "HI", + "postcode": "", + "city": "", + "rate": "4.0000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": true, + "order": 11, + "class": "standard" + }, + { + "id": 64, + "country": "US", + "state": "ID", + "postcode": "", + "city": "", + "rate": "6.0000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": false, + "order": 12, + "class": "standard" + } + ] +} +``` + +#### Available Filters #### + +| Filter | Type | Description | +| ---------------- | ------ | ----------------------------------------------------------------- | +| `tax_rate_class` | string | Tax rates by class. eg: `standard`, `reduced-rate` or `zero-rate` | + +<aside class="notice"> + Endpoint introduced since WooCommerce 2.5. +</aside> + +## Update a Tax Rate ## + +This API lets you make changes to a tax rate. + +### HTTP Request ### + +<div class="api-endpoint"> + <div class="endpoint-data"> + <i class="label label-put">PUT</i> + <h6>/wc-api/v3/taxes/<id></h6> + </div> +</div> + +```shell +curl -X PUT https://example.com/wc-api/v3/taxes/53 \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "tax": { + "name": "US Tax" + } +}' +``` + +```javascript +var data = { + tax: { + name: 'US Tax' + } +}; + +WooCommerce.put('taxes/53', data, function(err, data, res) { + console.log(res); +}); +``` + +```php +<?php +$data = [ + 'tax' => [ + 'name' => 'US Tax' + ] +]; + +print_r($woocommerce->put('taxes/53', $data)); +?> +``` + +```python +data = { + "tax": { + "name": "US Tax" + } +} + +print(wcapi.put("taxes/53", data).json()) +``` + +```ruby +data = { + tax: { + name: "US Tax" + } +} + +woocommerce.put("taxes/53", data).parsed_response +``` + +> JSON response example: + +```json +{ + "tax": { + "id": 53, + "country": "US", + "state": "AL", + "postcode": "", + "city": "", + "rate": "4.0000", + "name": "US Tax", + "priority": 1, + "compound": false, + "shipping": false, + "order": 0, + "class": "standard" + } +} +``` + +<aside class="notice"> + Endpoint introduced since WooCommerce 2.5. +</aside> + +## Create/Update Multiple Tax Rates ## + +This API helps you to bulk create/update multiple tax rates. + +To update is necessary to send objects containing IDs and to create new not just send the ID. + +### HTTP Request ### + +<div class="api-endpoint"> + <div class="endpoint-data"> + <i class="label label-post">POST</i> + <h6>/wc-api/v3/taxes/bulk</h6> + </div> +</div> + +> Example bulk creating all US taxes: + +```shell +curl -X POST https://example.com/wc-api/v3/taxes/bulk \ + -u consumer_key:consumer_secret \ + -H "Content-Type: application/json" \ + -d '{ + "taxes": [ + { + "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 = { + taxes: [ + { + 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/bulk', data, function(err, data, res) { + console.log(res); +}); +``` + +```php +<?php +$data = [ + 'taxes' => [ + [ + '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/bulk', $data)); +?> +``` + +```python +data = { + "taxes": [ + { + "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/bulk", data).json()) +``` + +```ruby +data = { + taxes: [ + { + 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/bulk", data).parsed_response +``` + +> JSON response example: + +```json +{ + "taxes": [ + { + "id": 53, + "country": "US", + "state": "AL", + "postcode": "", + "city": "", + "rate": "4.0000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": false, + "order": 1, + "class": "standard" + }, + { + "id": 54, + "country": "US", + "state": "AZ", + "postcode": "", + "city": "", + "rate": "5.6000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": false, + "order": 2, + "class": "standard" + }, + { + "id": 55, + "country": "US", + "state": "AR", + "postcode": "", + "city": "", + "rate": "6.5000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": true, + "order": 3, + "class": "standard" + }, + { + "id": 56, + "country": "US", + "state": "CA", + "postcode": "", + "city": "", + "rate": "7.5000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": false, + "order": 4, + "class": "standard" + }, + { + "id": 57, + "country": "US", + "state": "CO", + "postcode": "", + "city": "", + "rate": "2.9000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": false, + "order": 5, + "class": "standard" + }, + { + "id": 58, + "country": "US", + "state": "CT", + "postcode": "", + "city": "", + "rate": "6.3500", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": true, + "order": 6, + "class": "standard" + }, + { + "id": 59, + "country": "US", + "state": "DC", + "postcode": "", + "city": "", + "rate": "5.7500", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": true, + "order": 7, + "class": "standard" + }, + { + "id": 60, + "country": "US", + "state": "FL", + "postcode": "", + "city": "", + "rate": "6.0000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": true, + "order": 8, + "class": "standard" + }, + { + "id": 61, + "country": "US", + "state": "GA", + "postcode": "", + "city": "", + "rate": "4.0000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": true, + "order": 9, + "class": "standard" + }, + { + "id": 62, + "country": "US", + "state": "GU", + "postcode": "", + "city": "", + "rate": "4.0000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": false, + "order": 10, + "class": "standard" + }, + { + "id": 63, + "country": "US", + "state": "HI", + "postcode": "", + "city": "", + "rate": "4.0000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": true, + "order": 11, + "class": "standard" + }, + { + "id": 64, + "country": "US", + "state": "ID", + "postcode": "", + "city": "", + "rate": "6.0000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": false, + "order": 12, + "class": "standard" + }, + { + "id": 65, + "country": "US", + "state": "IL", + "postcode": "", + "city": "", + "rate": "6.2500", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": false, + "order": 13, + "class": "standard" + }, + { + "id": 66, + "country": "US", + "state": "IN", + "postcode": "", + "city": "", + "rate": "7.0000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": false, + "order": 14, + "class": "standard" + }, + { + "id": 67, + "country": "US", + "state": "IA", + "postcode": "", + "city": "", + "rate": "6.0000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": false, + "order": 15, + "class": "standard" + }, + { + "id": 68, + "country": "US", + "state": "KS", + "postcode": "", + "city": "", + "rate": "6.1500", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": true, + "order": 16, + "class": "standard" + }, + { + "id": 69, + "country": "US", + "state": "KY", + "postcode": "", + "city": "", + "rate": "6.0000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": true, + "order": 17, + "class": "standard" + }, + { + "id": 70, + "country": "US", + "state": "LA", + "postcode": "", + "city": "", + "rate": "4.0000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": false, + "order": 18, + "class": "standard" + }, + { + "id": 71, + "country": "US", + "state": "ME", + "postcode": "", + "city": "", + "rate": "5.5000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": false, + "order": 19, + "class": "standard" + }, + { + "id": 72, + "country": "US", + "state": "MD", + "postcode": "", + "city": "", + "rate": "6.0000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": false, + "order": 20, + "class": "standard" + }, + { + "id": 73, + "country": "US", + "state": "MA", + "postcode": "", + "city": "", + "rate": "6.2500", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": false, + "order": 21, + "class": "standard" + }, + { + "id": 74, + "country": "US", + "state": "MI", + "postcode": "", + "city": "", + "rate": "6.0000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": true, + "order": 22, + "class": "standard" + }, + { + "id": 75, + "country": "US", + "state": "MN", + "postcode": "", + "city": "", + "rate": "6.8750", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": true, + "order": 23, + "class": "standard" + }, + { + "id": 76, + "country": "US", + "state": "MS", + "postcode": "", + "city": "", + "rate": "7.0000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": true, + "order": 24, + "class": "standard" + }, + { + "id": 77, + "country": "US", + "state": "MO", + "postcode": "", + "city": "", + "rate": "4.2250", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": false, + "order": 25, + "class": "standard" + }, + { + "id": 78, + "country": "US", + "state": "NE", + "postcode": "", + "city": "", + "rate": "5.5000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": true, + "order": 26, + "class": "standard" + }, + { + "id": 79, + "country": "US", + "state": "NV", + "postcode": "", + "city": "", + "rate": "6.8500", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": false, + "order": 27, + "class": "standard" + }, + { + "id": 80, + "country": "US", + "state": "NJ", + "postcode": "", + "city": "", + "rate": "7.0000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": true, + "order": 28, + "class": "standard" + }, + { + "id": 81, + "country": "US", + "state": "NM", + "postcode": "", + "city": "", + "rate": "5.1250", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": true, + "order": 29, + "class": "standard" + }, + { + "id": 82, + "country": "US", + "state": "NY", + "postcode": "", + "city": "", + "rate": "4.0000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": true, + "order": 30, + "class": "standard" + }, + { + "id": 83, + "country": "US", + "state": "NC", + "postcode": "", + "city": "", + "rate": "4.7500", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": true, + "order": 31, + "class": "standard" + }, + { + "id": 84, + "country": "US", + "state": "ND", + "postcode": "", + "city": "", + "rate": "5.0000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": true, + "order": 32, + "class": "standard" + }, + { + "id": 85, + "country": "US", + "state": "OH", + "postcode": "", + "city": "", + "rate": "5.7500", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": true, + "order": 33, + "class": "standard" + }, + { + "id": 86, + "country": "US", + "state": "OK", + "postcode": "", + "city": "", + "rate": "4.5000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": false, + "order": 34, + "class": "standard" + }, + { + "id": 87, + "country": "US", + "state": "PA", + "postcode": "", + "city": "", + "rate": "6.0000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": true, + "order": 35, + "class": "standard" + }, + { + "id": 88, + "country": "US", + "state": "PR", + "postcode": "", + "city": "", + "rate": "6.0000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": false, + "order": 36, + "class": "standard" + }, + { + "id": 89, + "country": "US", + "state": "RI", + "postcode": "", + "city": "", + "rate": "7.0000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": false, + "order": 37, + "class": "standard" + }, + { + "id": 90, + "country": "US", + "state": "SC", + "postcode": "", + "city": "", + "rate": "6.0000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": true, + "order": 38, + "class": "standard" + }, + { + "id": 91, + "country": "US", + "state": "SD", + "postcode": "", + "city": "", + "rate": "4.0000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": true, + "order": 39, + "class": "standard" + }, + { + "id": 92, + "country": "US", + "state": "TN", + "postcode": "", + "city": "", + "rate": "7.0000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": true, + "order": 40, + "class": "standard" + }, + { + "id": 93, + "country": "US", + "state": "TX", + "postcode": "", + "city": "", + "rate": "6.2500", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": true, + "order": 41, + "class": "standard" + }, + { + "id": 94, + "country": "US", + "state": "UT", + "postcode": "", + "city": "", + "rate": "5.9500", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": false, + "order": 42, + "class": "standard" + }, + { + "id": 95, + "country": "US", + "state": "VT", + "postcode": "", + "city": "", + "rate": "6.0000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": true, + "order": 43, + "class": "standard" + }, + { + "id": 96, + "country": "US", + "state": "VA", + "postcode": "", + "city": "", + "rate": "5.3000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": false, + "order": 44, + "class": "standard" + }, + { + "id": 97, + "country": "US", + "state": "WA", + "postcode": "", + "city": "", + "rate": "6.5000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": true, + "order": 45, + "class": "standard" + }, + { + "id": 98, + "country": "US", + "state": "WV", + "postcode": "", + "city": "", + "rate": "6.0000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": true, + "order": 46, + "class": "standard" + }, + { + "id": 99, + "country": "US", + "state": "WI", + "postcode": "", + "city": "", + "rate": "5.0000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": true, + "order": 47, + "class": "standard" + }, + { + "id": 100, + "country": "US", + "state": "WY", + "postcode": "", + "city": "", + "rate": "4.0000", + "name": "State Tax", + "priority": 1, + "compound": false, + "shipping": true, + "order": 48, + "class": "standard" + } + ] +} +``` + +<aside class="notice"> + Endpoint introduced since WooCommerce 2.5. +</aside> + +## Delete a Tax Rate ## + +This API helps you delete a tax rate. + +### HTTP Request ### + +<div class="api-endpoint"> + <div class="endpoint-data"> + <i class="label label-delete">DELETE</i> + <h6>/wc-api/v3/taxes/<id></h6> + </div> +</div> + +```shell +curl -X DELETE https://example.com/wc-api/v3/taxes/53 \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.delete('taxes/53', function(err, data, res) { + console.log(res); +}); +``` + +```php +<?php print_r($woocommerce->delete('taxes/53')); ?> +``` + +```python +print(wcapi.delete("taxes/53").json()) +``` + +```ruby +woocommerce.delete("taxes/53").parsed_response +``` + +> JSON response example: + +```json +{ + "message": "Deleted tax" +} +``` + +<aside class="notice"> + Endpoint introduced since WooCommerce 2.5. +</aside> + +## View Tax Rate Count ## + +This API lets you retrieve a count of all tax rates. + +### HTTP Request ### + +<div class="api-endpoint"> + <div class="endpoint-data"> + <i class="label label-get">GET</i> + <h6>/wc-api/v3/taxes/count</h6> + </div> +</div> + +```shell +curl https://example.com/wc-api/v3/taxes/count \ + -u consumer_key:consumer_secret +``` + +```javascript +WooCommerce.get('taxes/count', function(err, data, res) { + console.log(res); +}); +``` + +```php +<?php print_r($woocommerce->get('taxes/53')); ?> +``` + +```python +print(wcapi.get("taxes/count").json()) +``` + +```ruby +woocommerce.get("taxes/count").parsed_response +``` + +> JSON response example: + +```json +{ + "count": 48 +} +``` + +#### Available Filters #### + +| Filter | Type | Description | +| ---------------- | ------ | ----------------------------------------------------------------- | +| `tax_rate_class` | string | Tax rates by class. eg: `standard`, `reduced-rate` or `zero-rate` | + +<aside class="notice"> + Endpoint introduced since WooCommerce 2.5. +</aside> diff --git a/source/includes/v3/_webhooks.md b/source/includes/v3/_webhooks.md index b2652a5c..af9a5d39 100644 --- a/source/includes/v3/_webhooks.md +++ b/source/includes/v3/_webhooks.md @@ -1,6 +1,6 @@ # Webhooks # -This section lists all API that can be used to create, edit or otherwise manipulate webhooks. +This section lists all API endpoints that can be used to create, edit or otherwise manipulate webhooks. ## Webhooks Properties ## @@ -48,7 +48,7 @@ This section lists all API that can be used to create, edit or otherwise manipul | `X-WC-Webhook-ID` | integer | The webhook's ID | | `X-WC-Webhook-Delivery-ID` | integer | The delivery ID | -## Create A Webhook ## +## Create a Webhook ## This API helps you to create a new webhook. @@ -90,6 +90,21 @@ WooCommerce.post('webhooks', data, function(err, data, res) { }); ``` +```php +<?php +$data = [ + 'webhook' => [ + 'name' => 'An add to cart webhook', + 'secret' => 'my-super-secret-private-key', + 'topic' => 'action.woocommerce_add_to_cart', + 'delivery_url' => 'http://requestb.in/1exdwip1' + ] +]; + +print_r($woocommerce->post('webhooks', $data)); +?> +``` + ```python data = { "webhook": { @@ -137,7 +152,7 @@ woocommerce.post("webhooks", data).parsed_response } ``` -## View A Webhook ## +## View a Webhook ## This API lets you retrieve and view a specific webhook. @@ -161,6 +176,10 @@ WooCommerce.get('webhooks/535', function(err, data, res) { }); ``` +```php +<?php print_r($woocommerce->get('webhooks/535')); ?> +``` + ```python print(wcapi.get("webhooks/535").json()) ``` @@ -190,7 +209,7 @@ woocommerce.get("webhooks/535").parsed_response } ``` -## View List Of Webhooks ## +## View List of Webhooks ## This API helps you to view all the webhooks. @@ -214,6 +233,10 @@ WooCommerce.get('webhooks', function(err, data, res) { }); ``` +```php +<?php print_r($woocommerce->get('webhooks')); ?> +``` + ```python print(wcapi.get("webhooks").json()) ``` @@ -267,7 +290,7 @@ woocommerce.get("webhooks").parsed_response | -------- | ------ | ----------------------------------------------------------------------------------------------------------------- | | `status` | string | Webhooks by status. The following options are available: `active` or `paused` and `disabled`. Default is `active` | -## Update A Webhook ## +## Update a Webhook ## This API lets you make changes to a webhook. @@ -303,6 +326,18 @@ WooCommerce.put('webhooks/535', data, function(err, data, res) { }); ``` +```php +<?php +$data = [ + 'webhook' => [ + 'status' => 'paused' + ] +]; + +print_r($woocommerce->put('webhooks/535', $data)); +?> +``` + ```python data = { "webhook": { @@ -344,7 +379,7 @@ woocommerce.put("webhooks/535", data).parsed_response } ``` -## Delete A Webhook ## +## Delete a Webhook ## This API helps you delete a webhook. @@ -368,6 +403,10 @@ WooCommerce.delete('webhooks/535', function(err, data, res) { }); ``` +```php +<?php print_r($woocommerce->delete('webhooks/535')); ?> +``` + ```python print(wcapi.delete("webhooks/535").json()) ``` @@ -408,6 +447,10 @@ WooCommerce.get('webhooks/count', function(err, data, res) { }); ``` +```php +<?php print_r($woocommerce->get('webhooks/count')); ?> +``` + ```python print(wcapi.get("webhooks/count").json()) ``` @@ -430,7 +473,7 @@ woocommerce.get("webhooks/count").parsed_response | -------- | ------ | -------------------------------------------------------------------------------------------- | | `status` | string | Webhooks by status. The following options are available: `active` or `paused` and `disabled` | -## View A Webhooks Delivery ## +## View a Webhooks Delivery ## This API lets you retrieve and view a specific webhook delivery. @@ -454,6 +497,10 @@ WooCommerce.get('webhooks/535/deliveries/378', function(err, data, res) { }); ``` +```php +<?php print_r($woocommerce->get('webhooks/535/deliveries/378')); ?> +``` + ```python print(wcapi.get("webhooks/535/deliveries/378").json()) ``` @@ -504,7 +551,7 @@ woocommerce.get("webhooks/535/deliveries/378").parsed_response View the <a href="#delivery-properties">Delivery Properties</a> for more details on this response. </aside> -## View List Of Webhooks Deliveries ## +## View List of Webhooks Deliveries ## This API helps you to view all deliveries from a specific webhooks. @@ -528,6 +575,10 @@ WooCommerce.get('webhooks/535/deliveries', function(err, data, res) { }); ``` +```php +<?php print_r($woocommerce->get('webhooks/535/deliveries')); ?> +``` + ```python print(wcapi.get("webhooks/535/deliveries").json()) ``` diff --git a/source/index.md b/source/index.md index f7911b55..70f23b1e 100644 --- a/source/index.md +++ b/source/index.md @@ -4,6 +4,7 @@ title: WooCommerce REST API Documentation v3 language_tabs: - shell: cURL - javascript: Node.js + - php: PHP - python: Python - ruby: Ruby @@ -14,7 +15,6 @@ toc_footers: - <a href="http://docs.woothemes.com/documentation/plugins/woocommerce/">WooCommerce Documentation</a> - <a href="https://github.com/woothemes/woocommerce">WooCommerce Repository</a> - <a href="http://github.com/tripit/slate">Documentation Powered by Slate</a> - - <div class="github-buttons"><iframe src="https://ghbtns.com/github-btn.html?user=woothemes&repo=woocommerce&type=star&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="170px" height="20px"></iframe> <iframe src="https://ghbtns.com/github-btn.html?user=woothemes&repo=woocommerce&type=fork&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="170px" height="20px"></iframe></div> includes: - v3/introduction @@ -22,8 +22,17 @@ includes: - 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 diff --git a/source/v1.md b/source/v1.md index 814247b4..37878335 100644 --- a/source/v1.md +++ b/source/v1.md @@ -12,7 +12,6 @@ toc_footers: - <a href="http://docs.woothemes.com/documentation/plugins/woocommerce/">WooCommerce Documentation</a> - <a href="https://github.com/woothemes/woocommerce">WooCommerce Repository</a> - <a href="http://github.com/tripit/slate">Documentation Powered by Slate</a> - - <div class="github-buttons"><iframe src="https://ghbtns.com/github-btn.html?user=woothemes&repo=woocommerce&type=star&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="170px" height="20px"></iframe> <iframe src="https://ghbtns.com/github-btn.html?user=woothemes&repo=woocommerce&type=fork&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="170px" height="20px"></iframe></div> includes: - v1/docs diff --git a/source/v2.md b/source/v2.md index 2ee823e0..d8a4ac76 100644 --- a/source/v2.md +++ b/source/v2.md @@ -15,7 +15,6 @@ toc_footers: - <a href="http://docs.woothemes.com/documentation/plugins/woocommerce/">WooCommerce Documentation</a> - <a href="https://github.com/woothemes/woocommerce">WooCommerce Repository</a> - <a href="http://github.com/tripit/slate">Documentation Powered by Slate</a> - - <div class="github-buttons"><iframe src="https://ghbtns.com/github-btn.html?user=woothemes&repo=woocommerce&type=star&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="170px" height="20px"></iframe> <iframe src="https://ghbtns.com/github-btn.html?user=woothemes&repo=woocommerce&type=fork&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="170px" height="20px"></iframe></div> includes: - v2/introduction