=== Document Generator from .docx for WooCommerce ===
Contributors: catcodestudio
Tags: woocommerce, invoice, docx, documents, word
Requires at least: 6.2
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Generate Word documents from your own .docx templates: delivery notes, acts, invoices and contracts, filled in from a WooCommerce order.

== Description ==

Every shop has its own paperwork. A delivery note with the company stamp, an act of acceptance, an invoice with the exact wording the accountant insists on. PDF invoice plugins hand you their layout and let you change a logo; this plugin does the opposite — you keep your own blank, made in Word exactly as your accounting department wants it, and the plugin fills it in.

Upload a .docx file with placeholders such as `{{order.number}}`, `{{customer.full_name}}` or `{{order.total_words}}`. A button appears in the order list and inside every order: one click and the finished .docx is downloaded, ready to print, sign or send on. The result is still a Word file, so anything left to edit by hand can be edited by hand.

= How it works =

* Any table row that contains at least one `{{item.*}}` placeholder becomes the line-item row — it is repeated for every product in the order, with numbering, SKU, quantity, price and line total.
* Word likes to cut a single word into several runs, so a placeholder can physically be split across three XML nodes. The plugin reads the whole paragraph, so a split placeholder is found and replaced exactly like an intact one.
* Headers and footers are processed too, which is where the company details usually live.
* Amount in words is built in: Ukrainian, Russian and English, with the correct grammatical forms for the hryvnia, dollar, euro and zloty.
* No composer, no PHPWord, no external service: ZipArchive plus the plugin's own XML handling. Everything stays on your server.

= Free =

* Up to 2 .docx templates.
* Generation from the order list and from the order screen.
* All placeholders: order, totals, customer, billing and shipping addresses, shop details, line items table.
* Amount in words in three languages, shop date and number formats.
* Custom file name pattern.

= Pro =

* Unlimited templates.
* Own document numbering: prefix, counter and zero padding, per template. A number issued for an order stays with it, so a reprint never changes it.
* Bulk generation: select orders in the list, get one zip archive.
* The document is generated automatically and attached to the WooCommerce e-mails you choose.
* `{{meta.*}}` placeholders — any order meta field, so data added by your delivery, legal-entity or CRM plugin (VAT number, waybill, contract number) reaches the blank as well.

A fresh install is the free tier and nothing else — Pro never switches itself on. The settings screen has a "Try Pro for 7 days" button: you enter an e-mail, we issue a real 7-day key and unlock Pro right away. No card, nothing is charged, one trial per install. When the trial ends the free tier keeps working with no time limit. The licence is annual (1 to 5 years) and includes updates and support for that term.

= Requirements =

* WooCommerce 6.0 or newer, HPOS (high-performance order storage) supported.
* PHP 7.4 or newer with the zip extension — every shared host has it, and the plugin tells you plainly if it is missing.

== Installation ==

1. Install and activate the plugin.
2. Open WooCommerce → Documents .docx and upload your .docx blank.
3. Check the "placeholders found in the file" column: it lists what the plugin actually read out of your template.
4. Open any order and press the template button.

== Frequently Asked Questions ==

= Does it need PHPWord or composer? =

No. The plugin opens the .docx with ZipArchive and edits the document XML itself, so there is nothing to install and nothing to keep updated.

= My placeholder is not replaced. Why? =

Almost always a typo in the name, so check the "placeholders found in the file" column on the templates screen — it shows what the file really contains. A placeholder must sit inside normal text; one typed into a text box that Word stores as a drawing, or into a field code, is not text any more.

= Can it produce PDF? =

No. Converting .docx to PDF needs LibreOffice or a paid service on the server, and neither belongs in a plugin. Word, LibreOffice and Google Docs all export to PDF in one click.

= Will my formatting survive? =

Yes. The file stays your file: the plugin only replaces the text of the placeholders, and a replaced value inherits the formatting of the place where the placeholder started.

= Does it work with the block checkout and HPOS? =

Yes. Orders are read through the WooCommerce CRUD, so both the legacy post storage and the high-performance order tables work.

== Screenshots ==

1. Templates screen: the uploaded blanks and the placeholders found in each one.
2. The placeholder reference, grouped by order, customer and line items.
3. Document buttons in the order list.
4. Settings: language of the amount in words, date format, file name, automation.

== Changelog ==

= 1.0.1 =
* Fixed: bulk action "Documents: ... (zip)" produced an empty page on shops that still keep orders in the classic posts table. WordPress strips the `action` parameter from the redirect of a bulk action, so the download link never reached its handler. The link now uses the plugin's own parameter and works the same on HPOS and on the classic order storage.

= 1.0.0 =
* First release: .docx templates, placeholders for order, customer, addresses and shop, repeating line-item rows, amount in words in Ukrainian, Russian and English, generation from the order list and the order screen.
* Pro: unlimited templates, document numbering series, bulk generation into a zip, automatic document attached to WooCommerce e-mails, `{{meta.*}}` placeholders.

== Upgrade Notice ==

= 1.0.1 =
Bulk zip generation now works on shops with the classic order storage.

= 1.0.0 =
First release.
