REST endpoint
GET /wp-json/lh-woocommerce-pdf-invoicing/v1/invoice/{order_id} generates and streams a PDF invoice for the specified order.
Authentication: Standard WordPress REST API authentication — cookie+nonce (?_wpnonce=...), application passwords, or any other WP REST auth method.
Permission:
- Users with
install_pluginscapability (admins) may download any order’s invoice. - Logged-in customers may download invoices for their own orders only.
- Unauthenticated requests are rejected with HTTP 401.
Response: Binary PDF (Content-Type: application/pdf) with Content-Disposition: attachment.
| HTTP Status | Reason |
|---|---|
| 401 | Not logged in |
| 403 | Logged in but order belongs to a different customer |
| 404 | Order ID not found |
Admin interface
PDF Invoice metabox
A PDF Invoice metabox appears in the side column of every WooCommerce order edit screen, containing a Download PDF Invoice button that links directly to the REST endpoint with a wp_rest nonce. Requires the install_plugins capability.
Order actions dropdown
A Download PDF Invoice entry is available in the WooCommerce order actions dropdown. Selecting it and clicking Update redirects the admin to the REST download URL. Requires the install_plugins capability.
My Account orders screen
A Download Invoice button appears alongside the standard order action buttons on the customer’s My Account → Orders screen, visible to the order’s own customer only.
Constants
| Constant | Description |
|---|---|
LH_WOOCOMMERCE_PDF_INVOICING_VERSION | Current plugin version string |
LH_WOOCOMMERCE_PDF_INVOICING_FILE | Absolute path to the main plugin file |
LH_WOOCOMMERCE_PDF_INVOICING_DIR | Absolute path to the plugin directory (trailing slash) |