Download the PHP package baldie81/woocommerce-sdk without Composer
On this page you can find all versions of the php package baldie81/woocommerce-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download baldie81/woocommerce-sdk
More information about baldie81/woocommerce-sdk
Files in baldie81/woocommerce-sdk
Package woocommerce-sdk
Short Description Framework-independent PHP SDK for the WooCommerce REST API (v3): products, variations, categories, attributes, orders, customers, coupons, tax, shipping, webhooks, settings and the batch API.
License MIT
Informations about the package woocommerce-sdk
WooCommerce PHP SDK
A small, framework-independent PHP client for the WooCommerce REST API (v3). No WordPress/Laravel/Symfony coupling — just PHP 8.1+ and Guzzle. It wraps the endpoints you actually reach for when integrating a store:
- Products — get / create / update / delete, list & paginate, look up by SKU
- Product variations — the variations of a variable product
- Product categories / tags / attributes — full catalog taxonomy, attribute terms
- Orders — get / list, create, partial update, set status, notes & refunds
- Customers — get / list, create / update (with inline addresses), look up by email
- Coupons — get / list, create / update, look up by code
- Tax — tax rates and tax classes
- Shipping — zones, their locations, and their methods
- Webhooks — register topic → delivery-URL hooks
- Store config — payment gateways, system status & tools, settings
- Batch API — create/update/delete up to 100 per call, auto-chunked past that
It also gives you fluent value-object builders (ProductInput, VariationInput,
OrderInput, LineItem, Address, CustomerInput, CouponInput,
CategoryInput, MetaData, BatchPayload) that every write method accepts
interchangeably with plain arrays, a fluent Query builder for list endpoints,
typed enums (ProductStatus, ProductType, CatalogVisibility, StockStatus,
OrderStatus, DiscountType), and a clean exception hierarchy instead of leaking
Guzzle exceptions.
Scope: this targets the standard WooCommerce core REST API (
wc/v3). Endpoints added by extensions (subscriptions, bookings, …) are out of scope, though their custom fields pass straight through viameta_dataand theset()escape hatches.
Install
Quick start
Authentication
Create a consumer key / consumer secret pair under WooCommerce → Settings → Advanced → REST API. Over HTTPS the SDK sends them as HTTP Basic auth, which is all WooCommerce needs.
TLS verification is on by default; pass verifySsl: false only for
local/self-signed environments.
For a non-SSL store (local dev), WooCommerce can't use Basic auth, so set
queryStringAuth: true to send the credentials as query parameters instead.
Don't do this over plain HTTP in production — it exposes the credentials in URLs
and logs.
Value objects (or arrays)
Every write method accepts either a fluent builder or a raw array, so you
can opt into type-safety without giving up the array escape hatch. The builders
all implement Arrayable:
Money is a string in WooCommerce. The builders' price setters accept a string or a number and stringify it for you (
->regularPrice(19.9)→"19.9").
A variable product carries its variations separately:
Orders
Listing & pagination
Build list queries with Query; list() returns one page, all() walks every
page for you.
WooCommerce reports totals in the X-WP-Total / X-WP-TotalPages response
headers (not the body) and caps per_page at 100. all() reads those headers
and paginates until the last page, so you never silently truncate a large result
set:
Batch API
Most collections expose a /batch endpoint that creates, updates and deletes in
one round-trip. BatchPayload builds it; the SDK splits payloads larger than
WooCommerce's 100-operation limit into several requests and merges the results:
Deleting
delete() permanently deletes by default (force: true) — required for
resources that can't be trashed (customers, webhooks) and usually what an
integration wants. Pass force: false to move a product/order to the trash
instead:
Errors
Every failure is a WooCommerceException. Two concrete types:
ApiException— WooCommerce returned a 4xx/5xx. Carries the HTTPstatusCode, the machineerrorCode(e.g.woocommerce_rest_product_invalid_id), the parseddata, and therawBody.TransportException— no usable HTTP response (DNS, connection, timeout, TLS).
Custom transport
Need retries, logging or your own middleware? Build a Guzzle client yourself and
hand it over — its base_uri must point at the store root and the API prefix is
prepended to every path:
Examples
Copy-pasteable usage lives in examples/ — one class per area,
each method demonstrating a single operation against the real API. Build a client
with ExampleClient::create() (edit its dummy placeholder credentials first —
never commit real keys), then call a class, e.g.
(new ProductExamples($woo))->create().
- ProductExamples — create / update / status / delete / get / by-SKU / list / paginate
- VariationExamples — variable parent, add variations, bulk-create the matrix
- CategoryExamples — categories (nesting, tree) and tags
- AttributeExamples — global attributes and their terms (single & batch)
- OrderExamples — create, set status, search, notes, refunds
- CustomerExamples — CRUD, by-email, idempotent upsert
- CouponExamples — percentage & fixed-cart coupons, by-code
- TaxExamples — tax classes and rates
- ShippingExamples — zones, locations, flat-rate & free-shipping methods
- WebhookExamples — register / pause / list / delete webhooks
- BatchExamples — mixed create/update/delete, large auto-chunked imports
- StoreConfigExamples — payment gateways, settings, system status & tools
Testing
The suite drives the client against a Guzzle MockHandler, so it makes no real
HTTP calls.
License
MIT — see LICENSE.