1. Go to this page and download the library: Download baldie81/woocommerce-sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Baldie81\WooCommerceSDK\Support\OrderInput;
use Baldie81\WooCommerceSDK\Support\Address;
use Baldie81\WooCommerceSDK\Support\LineItem;
use Baldie81\WooCommerceSDK\Enum\OrderStatus;
$order = $woo->orders()->create(
OrderInput::make()
->status(OrderStatus::Processing)->setPaid(true)
->paymentMethod('bacs', 'Direct bank transfer')
->billing(
Address::make()->name('Jane', 'Doe')
->line1('1 High St')->city('London')->postcode('EC1A 1AA')->country('GB')
->email('[email protected]')
)
->lineItem(LineItem::make()->product(93)->quantity(2))
->shippingLine('flat_rate', 'Flat rate', '5.00')
->couponLine('SAVE10')
);
$woo->orders()->setStatus($order['id'], OrderStatus::Completed);
// Notes and refunds hang off an order id:
$woo->orders()->notes($order['id'])->create('Picked & packed', customerNote: false);
$woo->orders()->refunds($order['id'])->refundAmount('12.50', 'Damaged item');
use Baldie81\WooCommerceSDK\Support\Query;
use Baldie81\WooCommerceSDK\Enum\ProductStatus;
// One page:
$page = $woo->products()->list(
Query::create()->search('shirt')->status(ProductStatus::Publish)->perPage(50)
);
// Every matching record, across all pages:
$everything = $woo->products()->all(
Query::create()->after('2026-01-01T00:00:00')->orderBy('date', 'desc')
);
// Direct look-ups by natural key:
$bySku = $woo->products()->bySku('SKU-123'); // ?array
$byEmail = $woo->customers()->byEmail('[email protected]');
$byCode = $woo->coupons()->byCode('SAVE10');
use Baldie81\WooCommerceSDK\Support\BatchPayload;
use Baldie81\WooCommerceSDK\Support\ProductInput;
$result = $woo->products()->batch(
BatchPayload::make()
->create(ProductInput::make()->name('A')->sku('A-1')->regularPrice('5'))
->update(ProductInput::make()->id(42)->regularPrice('9.99'))
->delete(43, 44)
);
// $result['create'], $result['update'], $result['delete']