Skip to content

Commit 4f71263

Browse files
Version 3.0.0
1 parent 099f643 commit 4f71263

File tree

2 files changed

+25
-17
lines changed

2 files changed

+25
-17
lines changed

README.md

+24-16
Original file line numberDiff line numberDiff line change
@@ -33,42 +33,41 @@ $woocommerce = new Client(
3333
'ck_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
3434
'cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
3535
[
36-
'wp_api' => true,
3736
'version' => 'wc/v3',
3837
]
3938
);
4039
```
4140

41+
## Client class
42+
43+
```php
44+
$woocommerce = new Client($url, $consumer_key, $consumer_secret, $options)
45+
```
46+
4247
### Options
4348

44-
| Option | Type | Required | Description |
45-
| ----------------- | -------- | -------- | ------------------------------------------ |
49+
| Option | Type | Required | Description |
50+
|-------------------|----------|----------|--------------------------------------------|
4651
| `url` | `string` | yes | Your Store URL, example: http://woo.dev/ |
4752
| `consumer_key` | `string` | yes | Your API consumer key |
4853
| `consumer_secret` | `string` | yes | Your API consumer secret |
4954
| `options` | `array` | no | Extra arguments (see client options table) |
5055

5156
#### Client options
5257

53-
| Option | Type | Required | Description |
58+
| Option | Type | Required | Description |
5459
|---------------------|----------|----------|------------------------------------------------------------------------------------------------------------------------|
55-
| `wp_api` | `bool` | no | Allow make requests to the new WP REST API integration (WooCommerce 2.6 or later) |
56-
| `wp_api_prefix` | `string` | no | Custom WP REST API URL prefix, used to support custom prefixes created with the `rest_url_prefix` filter |
57-
| `version` | `string` | no | API version, default is `v3` |
60+
| `version` | `string` | no | API version, default is `wc/v3` |
5861
| `timeout` | `int` | no | Request timeout, default is `15` |
59-
| `follow_redirects` | `bool` | no | Allow the API call to follow redirects |
6062
| `verify_ssl` | `bool` | no | Verify SSL when connect, use this option as `false` when need to test with self-signed certificates, default is `true` |
63+
| `follow_redirects` | `bool` | no | Allow the API call to follow redirects |
6164
| `query_string_auth` | `bool` | no | Force Basic Authentication as query string when `true` and using under HTTPS, default is `false` |
6265
| `oauth_timestamp` | `string` | no | Custom oAuth timestamp, default is `time()` |
6366
| `user_agent` | `string` | no | Custom user-agent, default is `WooCommerce API Client-PHP` |
67+
| `wp_api_prefix` | `string` | no | Custom WP REST API URL prefix, used to support custom prefixes created with the `rest_url_prefix` filter |
68+
| `wp_api` | `bool` | no | Set to `false` in order to use the legacy WooCommerce REST API (deprecated and not recommended) |
6469

65-
## Methods
66-
67-
| Params | Type | Description |
68-
| ------------ | -------- | ------------------------------------------------------------ |
69-
| `endpoint` | `string` | WooCommerce API endpoint, example: `customers` or `order/12` |
70-
| `data` | `array` | Only for POST and PUT, data that will be converted to JSON |
71-
| `parameters` | `array` | Only for GET and DELETE, request query string |
70+
## Client methods
7271

7372
### GET
7473

@@ -100,18 +99,26 @@ $woocommerce->delete($endpoint, $parameters = [])
10099
$woocommerce->options($endpoint)
101100
```
102101

102+
#### Arguments
103+
104+
| Params | Type | Description |
105+
|--------------|----------|--------------------------------------------------------------|
106+
| `endpoint` | `string` | WooCommerce API endpoint, example: `customers` or `order/12` |
107+
| `data` | `array` | Only for POST and PUT, data that will be converted to JSON |
108+
| `parameters` | `array` | Only for GET and DELETE, request query string |
109+
103110
#### Response
104111

105112
All methods will return arrays on success or throwing `HttpClientException` errors on failure.
106113

107-
108114
```php
109115
use Automattic\WooCommerce\HttpClient\HttpClientException;
110116

111117
try {
112118
// Array of response results.
113119
$results = $woocommerce->get('customers');
114120
// Example: ['customers' => [[ 'id' => 8, 'created_at' => '2015-05-06T17:43:51Z', 'email' => ...
121+
echo '<pre><code>' . print_r( $results, true ) . '</code><pre>'; // JSON output.
115122

116123
// Last request data.
117124
$lastRequest = $woocommerce->http->getRequest();
@@ -136,6 +143,7 @@ try {
136143

137144
## Release History
138145

146+
- 2019-01-16 - 3.0.0 - Legacy API turned off by default, and improved JSON error handler.
139147
- 2018-03-29 - 2.0.1 - Fixed fatal errors on `lookForErrors`.
140148
- 2018-01-12 - 2.0.0 - Responses changes from arrays to `stdClass` objects. Added `follow_redirects` option.
141149
- 2017-06-06 - 1.3.0 - Remove BOM before decoding and added support for multi-dimensional arrays for oAuth1.0a.

src/WooCommerce/Client.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Client
2121
/**
2222
* WooCommerce REST API Client version.
2323
*/
24-
const VERSION = '2.0.1';
24+
const VERSION = '3.0.0';
2525

2626
/**
2727
* HttpClient instance.

0 commit comments

Comments
 (0)