Automatic sending and XML testing with the Fatture in Cloud addon
Goal
Enable automatic sending of invoices to Fatture in Cloud after an order is completed, and verify the flow with a test order before relying on the automation.
Prerequisites
- The Fatture in Cloud connection already active.
Steps
Configure automatic sending
In the Fatture in Cloud tab:
- Order status that triggers sending (“Enable auto-send for status:”) — defaults to “Completed”, but can be set to another WooCommerce order status.
- Enable automatic sending of invoices (“Enable automatic sending”) — once an order reaches the configured status, an event is scheduled that runs after a configurable delay in hours (default 12 hours).
- When the delay elapses: the invoice is uploaded to Fatture in Cloud, then its formal validity is checked; only if valid is it forwarded to the SDI. If an invoice is invalid, sending stops and must be completed manually once the errors have been fixed.
- Disable automatic sending of invoices to the SDI (“Disables the automatic sending of invoices to the SDI”) — if enabled, stops the process after the upload/check on Fatture in Cloud and does not perform the automatic forwarding to the SDI (useful if you want Fatture in Cloud, not the plugin, to always decide when to send to the SDI).
- Email notification on failed creation — there is a dedicated option (“Send an email to the WordPress installation administrator … to report the failure to create the document on Fatture in Cloud”) to receive an email if automatic invoice creation fails.
WP-Cron reliability
Automatic-sending events are handled by WP-Cron, which only fires when someone visits a page on the site. On low-traffic sites, sending can be delayed or not start at all. To make it reliable, add a real system-level Cron job (via hosting, VPS, or a dedicated server) that calls it periodically (e.g. every 30 minutes):
cd <document_root>/public_html; wp cron event run --due-now >/dev/null 2>&1
where <document_root> is the domain’s root directory.
Diagnostic log
To trace the scheduling and execution of sends (including the order statuses passed through and the
reason an automatic send was skipped), add this to wp-config.php:
define("WP_FATT_CLOUD_LOG", true);
Generating a test XML
Before relying on the automation, verify the flow with a test order:
- Make sure the addon is connected (see fatture-in-cloud-connect).
- Temporarily disable both “Enable automatic sending of invoices” and “Disable automatic sending of invoices to the SDI”, so no send happens on its own.
- Make a test purchase and move the order to the status configured as the trigger (default “Completed”). Go to the plugin’s Invoices section: you’ll find the generated XML, downloadable so you can check its structure.
- Once you’ve checked the XML, use the “Upload” button on the invoice to send it manually to Fatture in Cloud: after sending you’ll see it appear among the documents in your account.
Verify
- With the log enabled, the file records the creation, check, and sending (or the reason for the skip) for each order.
- The document appears on Fatture in Cloud with a validity/sending status consistent with what’s shown in the plugin.
Common errors
- Automatic sending never starts — almost always it’s WP-Cron not firing due to lack of traffic: add the system Cron job described above.
- The invoice stays stuck after upload — the formal check on Fatture in Cloud flagged it as invalid: fix the order/invoice data and resend manually.
- You want to test without risking a real send — follow the “Generating a test XML” procedure above: with both automatic-sending options disabled, no document goes out on its own until you upload it manually.
Related configuration
For the invoice data contract (payload, field mapping), see api/sdi. To understand an SDI rejection after forwarding, see sdi-invoice-rejected.