Download the PHP package badgerwise/wc-connect without Composer

On this page you can find all versions of the php package badgerwise/wc-connect. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package wc-connect

wc-connect

Framework-agnostic WooCommerce REST API client for PHP, with first-class support for WordPress Application Password authentication. Drop it into any PHP project — Laravel, plain PHP, or a NativePHP mobile app.

Requirements

Installation

Quick start

With a WordPress Application Password

Create one under Users → Profile → Application Passwords in wp-admin.

The spaces WordPress shows in the password are ignored — paste it as-is.

With WooCommerce consumer keys

Generate a key/secret under WooCommerce → Settings → Advanced → REST API.

Consumer keys are sent as HTTP Basic auth (HTTPS only). For a plain-HTTP dev store, pass them as query-string parameters instead:

The Application Password authorization flow (mobile / one-click)

Instead of asking users to generate a password by hand, send them through WordPress's built-in authorization screen. This is the recommended flow for a NativePHP mobile app: WordPress hands your app a scoped application password, and the user's real credentials never touch your code.

fromCallback() throws a WcConnectException if the user rejected the request or the credentials are missing (e.g. the store predates WordPress 5.6 or does not serve HTTPS).

Generic client

get, post, put, and delete all return the decoded JSON body as an array.

Need response headers (e.g. for pagination)? Use send(), which returns a Response (status code, headers, decoded body):

A different REST namespace

The default namespace is wc/v3. Pass another to hit core WordPress or other plugins:

Uploading a file to the Media Library

uploadMedia() posts a file to WordPress' Media Library (wp/v2/media) and returns the created media object — regardless of the client's namespace. Handy for attaching images/PDFs (e.g. a delivery photo) and then referencing the returned id / source_url from an order's meta_data.

The authenticated user needs the WordPress upload_files capability.

Resource helpers

Typed sugar over the generic client. Each helper exposes list, find, create, update, and delete.

Pagination

list() returns a PaginatedResult — iterable and countable — that also carries WooCommerce's X-WP-Total / X-WP-TotalPages metadata:

Walk every page:

Verifying incoming webhooks

WooCommerce can push events (new order, status change, …) to your app. Each delivery is signed as base64(HMAC-SHA256(rawBody, secret)) in the X-WC-Webhook-Signature header. Verify it against the raw request body before trusting the payload:

The check is timing-safe and returns false for an empty or mismatched signature. Use the exact bytes received (e.g. Laravel's $request->getContent()), not a re-encoded array, or the signature won't match.

Error handling

Every failure is a WcConnectException (extends RuntimeException), so a single catch covers transport errors, invalid JSON, and API errors.

A non-2xx API response throws ApiException, which exposes the WooCommerce error details:

Injecting your own HTTP client

Discovery is convenient, but you can pass everything explicitly — useful in tests or when you want a preconfigured client (timeouts, retries, logging):

Development

composer is not on PATH by default here; use Herd's binaries:

License

MIT


All versions of wc-connect with dependencies

PHP Build Version
Package Version
Requires php Version >=8.3
psr/http-client Version ^1.0
psr/http-factory Version ^1.0
psr/http-message Version ^1.1 || ^2.0
php-http/discovery Version ^1.19
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package badgerwise/wc-connect contains the following files

Loading the files please wait ...