Skip to content

Delivery Notes

“SilentJMA” edited this page Jun 18, 2026 · 1 revision

Delivery Notes

The plugin includes a built-in PDF generator that creates delivery and return notes for Mirakl orders — no external service required.

How It Works

  1. On the WooCommerce order edit page, click Delivery Note in the Mirakl Actions section
  2. The PDF is generated locally on your server using Dompdf (HTML → PDF)
  3. The PDF is served inline in the browser for download/printing

Architecture

Component File Purpose
Handler includes/class-mirakl-admin.php (handle_delivery_note_pdf()) Admin-post action dispatcher
Order Data src/DeliveryNote/OrderData.php Extracts order data from WC_Order
Generator src/DeliveryNote/Generator.php Dompdf-based PDF rendering

The flow:

  1. User clicks "Delivery Note" → URL: admin-post.php?action=mirakl_delivery_note&order_id=N&store_name=StoreName
  2. handle_delivery_note_pdf() gates access (manage_woocommerce cap + _mirakl_order_id meta check)
  3. Creates OrderData::from_wc_order() with the WooCommerce order, store name, and channel code
  4. Instantiates new Generator($data) which resolves the store's language setting
  5. $generator->output() renders the PDF inline

Per-Store Settings

Configured in Mirakl → Stores, under the Delivery Note section:

Setting Description
Logo Upload via WordPress Media Library. Auto-resized to 200×70 px PNG with transparency preserved.
Language Choose: Deutsch, English, Français, Nederlands, Español
Footer Custom footer text. Falls back to language-specific default if left empty.

Logo Details

  • Uploaded through the WordPress Media Library (attachment ID stored per store)
  • Auto-resized to 200×70 px on save using GD (imagecreatefromstring + imagecopyresampled)
  • Transparency is preserved (PNG output with alpha blending)
  • Falls back to original if GD is unavailable
  • Base64 data is pre-computed at save time (not at render time) to avoid filesystem/symlink issues

Supported Languages

Language Code Default Title
German de Lieferschein / Retourenschein
English en Delivery Note / Return Note
French fr Bon de Livraison / Bon de Retour
Dutch nl Leveringsbon / Retourbon
Spanish es Albarán de Entrega / Nota de Devolución

Template Layout

  • Title — 16pt bold, translated per language
  • Store Logo — 200×70 px, right side beside title
  • Address — Left-aligned shipping address
  • Order Info — Right-aligned table: order number, partner order, order date, delivery note date
  • Product Table — 6 columns: Pos., Quantity, SKU, Description, Return Qty, Return Reason
  • Return Codes — 3-column grid of return reason codes
  • Return Instructions — Numbered list with important notes
  • Footer — Fixed-position at page bottom
  • Pure black & white (no colors)
  • A4 portrait, margins: 13mm 18mm 22mm 18mm

Channel-Specific URL Actions

In Mirakl → Stores → Advanced Channel Config, you can configure:

  • URL Template — A custom URL per store+channel for external delivery note services
  • Button Label — Custom label for the delivery note button
  • Enabled — Toggle on/off per channel

When configured, the custom URL template opens instead of the built-in PDF generator. Template variables: {order_id}, {store_name}, {channel_code}.

Clone this wiki locally