WP Manifestindependent plugin directory
manifest / ecommerce / docuhook-woocommerce

DocuHook

WooCommerce / WordPress plugin: order JSON → HTML template → PDF via DocuHook

★ 0stars

Install

Download source zip No release zip yet

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.zip
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

DocuHook 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

  1. Download the plugin zip, or clone this repo into wp-content/plugins/docuhook
  2. Activate DocuHook in WP Admin
  3. Settings → DocuHook → API URL https://docuhook.com + your API key
  4. 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:

  1. Order status → completed
  2. Build JSON from WC_Order
  3. docuhook_render( $data, $html, [ 'mode' => 'async' ] )
  4. Store job_id on the order; poll docuhook_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.

License

GPL-2.0-or-later (WordPress plugin license).