Install
This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.
Install straight from GitHub with WP-CLI:
wp plugin install https://github.com/rustemas/docuhook-woocommerce/archive/refs/heads/main.zipDocuHook for WooCommerce
WordPress plugin + examples to turn WooCommerce orders into PDFs via DocuHook — merge order JSON into an HTML invoice template, no Puppeteer box to maintain.
WooCommerce order.completed → JSON payload → HTML template → PDF
Install
- Download the plugin zip, or clone this repo into
wp-content/plugins/docuhook - Activate DocuHook in WP Admin
- Settings → DocuHook → API URL
https://docuhook.com+ your API key - Click Send test render
Requires WordPress 5.8+, PHP 7.4+, and WooCommerce for the invoice example.
Quick usage
$result = docuhook_render(
[
'order' => [
'number' => '1042',
'total' => '49.00',
],
'billing' => [
'name' => 'Ada Lovelace',
'email' => 'ada@example.com',
],
],
'<h1>Invoice {{order.number}}</h1><p>{{billing.name}} — {{order.total}}</p>',
['filename' => 'invoice-1042.pdf', 'mode' => 'sync']
);
if ( ! empty( $result['ok'] ) ) {
// Merged HTML from DocuHook (PDF via API / your delivery pipeline)
echo $result['html'];
}
Prefer mode => 'async' on storefront webhooks so WooCommerce is not held open during render.
WooCommerce: invoice on order completed
Copy examples/order-completed-invoice.php into a small custom plugin (or mu-plugin), and put examples/invoice-template.html somewhere readable (e.g. wp-content/uploads/invoice-template.html).
add_action( 'woocommerce_order_status_completed', 'my_docuhook_invoice_on_complete', 20, 1 );
Flow:
- Order status → completed
- Build JSON from
WC_Order docuhook_render( $data, $html, [ 'mode' => 'async' ] )- Store
job_idon the order; polldocuhook_job_result()when you need the HTML/PDF
Full walkthrough: WooCommerce webhook → PDF invoice
Helpers
| Function | Purpose |
|---|---|
docuhook_render( $data, $html, $args ) |
Merge + render (sync or async) |
docuhook_job_status( $job_id ) |
Poll async job |
docuhook_job_result( $job_id ) |
Fetch completed HTML |
Pure webhook (no PHP hook)
Point a WooCommerce webhook at:
POST https://docuhook.com/api/v1/hooks/render
Authorization: Bearer dh_...
Content-Type: application/json
{
"mode": "async",
"data": { "order": { "number": "1042" } },
"html": "<h1>Invoice {{order.number}}</h1>",
"filename": "invoice.pdf"
}
Returns 202 with job_id, status_url, and result_url.
Links
- Product / live sandbox: docuhook.com
- API docs: docuhook.com/docs
- Other clients: Node · PHP · Python · Go · React
License
GPL-2.0-or-later (WordPress plugin license).