Attaching terms as a PDF to WooCommerce order emails
How WooCommerce order emails pull the approved terms or withdrawal version as a PDF attachment, HTML fragment or JSON from TermShelf — instead of maintaining legal texts in the theme or mail template that gets overwritten on the next update.
Attaching terms as a PDF to WooCommerce order emails
WooCommerce is a WordPress plugin, and its order emails are PHP-based templates that can be overridden in the theme. That makes them a close integration point — and at the same time fragile: legal texts written directly into an overridden mail template or into theme files are tightly coupled to WordPress, the theme and its update cycle.
The order email is the moment the customer receives a concrete version. It should reference an approved, dated version — not a copy sitting in a template file.
What TermShelf does here — and what it doesn’t
TermShelf is the central source for approved legal texts and delivers them as PDF, HTML or JSON. It is not a WooCommerce plugin and not a legal-text generator. WooCommerce remains the shop; the approved version is fetched server-side instead of maintained in the theme.
Which texts are needed at which process step is something teams should have reviewed legally. TermShelf organizes and delivers the approved versions — it does not replace the legal assessment of the content.
Why legal texts don’t belong in the theme or mail template
WooCommerce mail templates often end up as overridden files in the (child) theme. Legal texts maintained there carry several risks:
- A theme or template update can displace overridden files — and with them the text.
- Several plugins (legal-text plugin, PDF-invoice plugin, mail customizer) may hold their own copies.
- The version sitting in the template is not mapped to an approved, dated version.
Why scattered maintenance is fundamentally hard is described in why legal content shouldn’t live scattered across your CMS.
Three integration patterns for WooCommerce
Because WooCommerce runs server-side in PHP, the integration can hook into generating the order email. There are three artifact forms from the Public Delivery API:
- PDF artifact as an attachment to the order email — fetched server-side when terms or withdrawal should be enclosed as a self-contained document.
- HTML fragment for direct embedding into the mail body or a WordPress page.
- JSON for custom logic when the text is further processed in a middleware or a custom plugin.
Which form fits when is compared in delivering legal content via API; the delivery contract is described in the Public Delivery API.
Versioning and proof of the delivered version
On the server-side fetch you can reference either a fixed version number (?version=N) or the state at a timestamp (?effective_at=<ISO-8601>). Which of the two fits depends on whether the currently valid version or a version bound to the order should be sent.
So that the delivered version stays provable, the version number used should be stored with the order. The link between transaction and version is covered in which terms version applied at contract conclusion.
Example flow
- Edit, review and approve the legal text in TermShelf.
- Publish the version — it becomes an immutable, dated snapshot.
- When generating the order email, the server-side integration fetches the terms PDF artifact in the right version, e.g. pinned to version 12:
GET /v1/delivery/sites/23/documents/terms/pdf
?locale=de-DE&market=DE&version=12The order email attaches the PDF or embeds the HTML fragment, and the delivered version stays traceable via the stored version number. Endpoints and headers are in the API reference.
Common mistakes
- Legal text maintained directly in an overridden mail template that a theme update displaces.
- Several plugins keep their own copies of the same terms, aging independently.
- The PDF is generated at send time, but the version number is not stored with the order.
- The external fetch is not cached, so every mail send re-requests the same content.
What TermShelf does not do
TermShelf does not produce legally binding content and is not a substitute for legal advice. TermShelf does not provide an official WooCommerce plugin and deliberately names no specific WordPress hooks or code promises here. What is described is an integration-open approach via the Public Delivery API; the concrete server-side integration depends on the respective WordPress/WooCommerce setup.
Related guides
Frequently asked questions
- Should I write the terms directly into the WooCommerce mail template?
- Not advisable: overridden mail templates live in the theme and can be displaced on updates, and the version is not mapped to an approved one. Better is a server-side fetch of the artifact from the Public Delivery API when generating the order email.
- Is there an official TermShelf plugin for WooCommerce?
- This guide does not claim a ready-made plugin and deliberately names no specific WordPress hooks. What is described is an integration-open, server-side fetch via the Public Delivery API; the concrete integration depends on the WordPress/WooCommerce setup.
- How does the delivered terms version stay provable?
- By storing the version number used at send time with the WooCommerce order. Since every publication is a dated, immutable snapshot, the same version can be retrieved again later.
Related guides
Attaching terms as a PDF to order confirmations
How to attach the approved terms version as a PDF artifact from the Public Delivery API to transactional order confirmations — versioned and traceable.
Embedding the withdrawal notice in order confirmations
HTML in the email footer or PDF as attachment: how the approved withdrawal notice reaches transactional confirmations in a versioned way.
Which terms version applied at contract conclusion?
Version pinning, effective_at delivery and audit trail: how to establish the link between a transaction and the published version that applied at that time.