PHPackages                             zonbloginc/woocommerce - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. zonbloginc/woocommerce

ActiveLibrary[API Development](/categories/api)

zonbloginc/woocommerce
======================

A PHP wrapper for the WooCommerce REST API

3.1.0(2y ago)04MITPHPPHP &gt;= 7.1.0

Since Apr 15Pushed 2y agoCompare

[ Source](https://github.com/zonbloginc/woocommerce-rest-api)[ Packagist](https://packagist.org/packages/zonbloginc/woocommerce)[ RSS](/packages/zonbloginc-woocommerce/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

WooCommerce API - PHP Client
============================

[](#woocommerce-api---php-client)

A PHP wrapper for the WooCommerce REST API. Easily interact with the WooCommerce REST API securely using this library. If using a HTTPS connection this library uses BasicAuth, else it uses Oauth to provide a secure connection to WooCommerce.

[![CI status](https://github.com/woocommerce/wc-api-php/actions/workflows/ci.yml/badge.svg?branch=trunk)](https://github.com/woocommerce/wc-api-php/actions/workflows/ci.yml)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/bab7f3f6a86424faad38adb6cbc2e21cff6d4171de4cf07c060c70216a0dcb67/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f776f6f636f6d6d657263652f77632d6170692d7068702f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/woocommerce/wc-api-php/?branch=master)[![PHP version](https://camo.githubusercontent.com/85a933c1158e476b3d9de855b1426096390b5aea689ad9c8b843145c37846e70/68747470733a2f2f62616467652e667572792e696f2f70682f6175746f6d6174746963253246776f6f636f6d6d657263652e737667)](https://packagist.org/packages/automattic/woocommerce)

Installation
------------

[](#installation)

```
composer require zonbloginc/woocommerce

```

Getting started
---------------

[](#getting-started)

Generate API credentials (Consumer Key &amp; Consumer Secret) following this instructions .

Check out the WooCommerce API endpoints and data that can be manipulated in .

Setup
-----

[](#setup)

Setup for the new WP REST API integration (WooCommerce 2.6 or later):

```
require __DIR__ . '/vendor/autoload.php';

use Automattic\WooCommerce\Client;

$woocommerce = new Client(
  'http://example.com',
  'ck_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
  'cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
  [
    'version' => 'wc/v3',
  ]
);
```

Client class
------------

[](#client-class)

```
$woocommerce = new Client($url, $consumer_key, $consumer_secret, $options);
```

### Options

[](#options)

OptionTypeRequiredDescription`url``string`yesYour Store URL, example: `consumer_key``string`yesYour API consumer key`consumer_secret``string`yesYour API consumer secret`options``array`noExtra arguments (see client options table)#### Client options

[](#client-options)

OptionTypeRequiredDescription`version``string`noAPI version, default is `wc/v3``timeout``int`noRequest timeout, default is `15``verify_ssl``bool`noVerify SSL when connect, use this option as `false` when need to test with self-signed certificates, default is `true``follow_redirects``bool`noAllow the API call to follow redirects`query_string_auth``bool`noForce Basic Authentication as query string when `true` and using under HTTPS, default is `false``oauth_timestamp``string`noCustom oAuth timestamp, default is `time()``oauth_only``bool`noOnly use oauth for requests, it will disable Basic Auth, default is `false``user_agent``string`noCustom user-agent, default is `WooCommerce API Client-PHP``wp_api_prefix``string`noCustom WP REST API URL prefix, used to support custom prefixes created with the `rest_url_prefix` filter`wp_api``bool`noSet to `false` in order to use the legacy WooCommerce REST API (deprecated and not recommended)`method_override_query``bool`noIf true will mask all non-GET/POST methods by using POST method with added query parameter `?_method=METHOD` into URL`method_override_header``bool`noIf true will mask all non-GET/POST methods (PUT/DELETE/etc.) by using POST method with added `X-HTTP-Method-Override: METHOD` HTTP header into requestClient methods
--------------

[](#client-methods)

### GET

[](#get)

```
$woocommerce->get($endpoint, $parameters = []);
```

### POST

[](#post)

```
$woocommerce->post($endpoint, $data);
```

### PUT

[](#put)

```
$woocommerce->put($endpoint, $data);
```

### DELETE

[](#delete)

```
$woocommerce->delete($endpoint, $parameters = []);
```

### OPTIONS

[](#options-1)

```
$woocommerce->options($endpoint);
```

#### Arguments

[](#arguments)

ParamsTypeDescription`endpoint``string`WooCommerce API endpoint, example: `customers` or `order/12``data``array`Only for POST and PUT, data that will be converted to JSON`parameters``array`Only for GET and DELETE, request query string#### Response

[](#response)

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

```
use Automattic\WooCommerce\HttpClient\HttpClientException;

try {
  // Array of response results.
  $results = $woocommerce->get('customers');
  // Example: ['customers' => [[ 'id' => 8, 'created_at' => '2015-05-06T17:43:51Z', 'email' => ...
  echo '' . print_r($results, true) . ''; // JSON output.

  // Last request data.
  $lastRequest = $woocommerce->http->getRequest();
  echo '' . print_r($lastRequest->getUrl(), true) . ''; // Requested URL (string).
  echo '' .
    print_r($lastRequest->getMethod(), true) .
    ''; // Request method (string).
  echo '' .
    print_r($lastRequest->getParameters(), true) .
    ''; // Request parameters (array).
  echo '' .
    print_r($lastRequest->getHeaders(), true) .
    ''; // Request headers (array).
  echo '' . print_r($lastRequest->getBody(), true) . ''; // Request body (JSON).

  // Last response data.
  $lastResponse = $woocommerce->http->getResponse();
  echo '' . print_r($lastResponse->getCode(), true) . ''; // Response code (int).
  echo '' .
    print_r($lastResponse->getHeaders(), true) .
    ''; // Response headers (array).
  echo '' . print_r($lastResponse->getBody(), true) . ''; // Response body (JSON).
} catch (HttpClientException $e) {
  echo '' . print_r($e->getMessage(), true) . ''; // Error message.
  echo '' . print_r($e->getRequest(), true) . ''; // Last request data.
  echo '' . print_r($e->getResponse(), true) . ''; // Last response data.
}
```

Release History
---------------

[](#release-history)

- 2022-03-18 - 3.1.0 - Added new options to support `_method` and `X-HTTP-Method-Override` from WP, supports 7+, dropped support to PHP 5.
- 2019-01-16 - 3.0.0 - Legacy API turned off by default, and improved JSON error handler.
- 2018-03-29 - 2.0.1 - Fixed fatal errors on `lookForErrors`.
- 2018-01-12 - 2.0.0 - Responses changes from arrays to `stdClass` objects. Added `follow_redirects` option.
- 2017-06-06 - 1.3.0 - Remove BOM before decoding and added support for multi-dimensional arrays for oAuth1.0a.
- 2017-03-15 - 1.2.0 - Added `user_agent` option.
- 2016-12-14 - 1.1.4 - Fixed WordPress 4.7 compatibility.
- 2016-10-26 - 1.1.3 - Allow set `oauth_timestamp` and improved how is handled the response headers.
- 2016-09-30 - 1.1.2 - Added `wp_api_prefix` option to allow custom WP REST API URL prefix.
- 2016-05-10 - 1.1.1 - Fixed oAuth and error handler for WP REST API.
- 2016-05-09 - 1.1.0 - Added support for WP REST API, added method `Automattic\WooCommerce\Client::options` and fixed multiple headers responses.
- 2016-01-25 - 1.0.2 - Fixed an error when getting data containing non-latin characters.
- 2016-01-21 - 1.0.1 - Sort all oAuth parameters before build request URLs.
- 2016-01-11 - 1.0.0 - Stable release.

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 Bus Factor1

Top contributor holds 81.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

764d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/107382607747942b9b950ea720b72e9ea26ec999a9f73c667a7a14b82000dd79?d=identicon)[zonbloginc](/maintainers/zonbloginc)

---

Top Contributors

[![claudiosanches](https://avatars.githubusercontent.com/u/1264099?v=4)](https://github.com/claudiosanches "claudiosanches (161 commits)")[![bryceadams](https://avatars.githubusercontent.com/u/1532482?v=4)](https://github.com/bryceadams "bryceadams (9 commits)")[![bkuhl](https://avatars.githubusercontent.com/u/524933?v=4)](https://github.com/bkuhl "bkuhl (9 commits)")[![westi](https://avatars.githubusercontent.com/u/551898?v=4)](https://github.com/westi "westi (4 commits)")[![zonbloginc](https://avatars.githubusercontent.com/u/134373013?v=4)](https://github.com/zonbloginc "zonbloginc (2 commits)")[![cgrama-ac](https://avatars.githubusercontent.com/u/172446623?v=4)](https://github.com/cgrama-ac "cgrama-ac (2 commits)")[![gugglegum](https://avatars.githubusercontent.com/u/1580712?v=4)](https://github.com/gugglegum "gugglegum (2 commits)")[![nicolasb827](https://avatars.githubusercontent.com/u/3798825?v=4)](https://github.com/nicolasb827 "nicolasb827 (2 commits)")[![chizdrel](https://avatars.githubusercontent.com/u/4534533?v=4)](https://github.com/chizdrel "chizdrel (1 commits)")[![redelschaap](https://avatars.githubusercontent.com/u/6915990?v=4)](https://github.com/redelschaap "redelschaap (1 commits)")[![simoor](https://avatars.githubusercontent.com/u/10817707?v=4)](https://github.com/simoor "simoor (1 commits)")[![vishalkakadiya](https://avatars.githubusercontent.com/u/9035925?v=4)](https://github.com/vishalkakadiya "vishalkakadiya (1 commits)")[![fastdivision](https://avatars.githubusercontent.com/u/1137184?v=4)](https://github.com/fastdivision "fastdivision (1 commits)")[![wiesys](https://avatars.githubusercontent.com/u/4457340?v=4)](https://github.com/wiesys "wiesys (1 commits)")[![mrohnstock](https://avatars.githubusercontent.com/u/823072?v=4)](https://github.com/mrohnstock "mrohnstock (1 commits)")

---

Tags

apiwoocommerce

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/zonbloginc-woocommerce/health.svg)

```
[![Health](https://phpackages.com/badges/zonbloginc-woocommerce/health.svg)](https://phpackages.com/packages/zonbloginc-woocommerce)
```

###  Alternatives

[automattic/woocommerce

A PHP wrapper for the WooCommerce REST API

5475.9M19](/packages/automattic-woocommerce)[wp-graphql/wp-graphql-woocommerce

WooCommerce bindings for WPGraphQL

69146.8k](/packages/wp-graphql-wp-graphql-woocommerce)[m165437/laravel-blueprint-docs

API Blueprint Renderer for Laravel

22779.0k](/packages/m165437-laravel-blueprint-docs)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
