Email PDF Ticket
Email PDF Ticket#
Auto-attach professional PDF raffle tickets to WooCommerce order confirmation emails. When a customer completes an order containing raffle products, each ticket is generated as a branded PDF and included as an email attachment — no manual download needed.
Enabling#
- Go to WooCommerce → Settings → Raffle → Modules and enable Email PDF Ticket.
- Configure which email types should include PDF attachments (appears after enabling).
Settings#
| Setting | Description | Default |
|---|---|---|
| Completed Order Email | Attach tickets to the “Order complete” email sent after payment | Yes |
| Processing Order Email | Attach tickets to the “Order processing” email for manual payment methods | Yes |
How It Works#
- Customer completes a raffle ticket purchase.
- WooCommerce triggers the order confirmation email.
- The module intercepts the email via
woocommerce_email_attachments. - For each raffle ticket in the order, a PDF is generated using DOMPDF.
- PDFs are attached to the email and cleaned up after sending.
PDF Content#
Each PDF ticket includes:
- Site logo or site name (from WordPress Customizer)
- Raffle name — the product title
- Ticket number — formatted ticket number in monospace font
- Ticket holder — purchaser or gift recipient name
- Draw date — raffle end date
- Prize — only shown if the ticket is a winning ticket
- QR code — scannable verification code (embedded as base64)
- Order number — reference back to the WooCommerce order
- Footer text — customizable via
rfwc_ticket_footer_textoption - Brand color — uses
rfwc_ticket_primary_colorfor header and accents
File Naming#
PDFs are named raffle-ticket-{ticket_number}-{random}.pdf (e.g., raffle-ticket-00042-x8k2m9p1.pdf). The random suffix prevents caching conflicts.
Multiple Tickets#
If an order contains multiple raffle tickets (e.g., quantity 5), each ticket gets its own PDF attachment. Gift tickets use the recipient’s name as the ticket holder.
Ticket Statuses#
Only active and winner tickets are attached. Cancelled or refunded tickets are skipped.
Temp File Management#
PDFs are generated to wp-content/uploads/rfwc-temp/ and cleaned up:
- Immediately after the email is sent (via
wp_mail_succeededaction). - Hourly cron fallback removes any orphaned files older than 1 hour.
- The temp directory is protected with
.htaccess(deny all) and an emptyindex.php.
Developer Hooks#
Filter: rfwc_pro_email_pdf_allowed_emails#
Control which WooCommerce email types receive PDF attachments.
add_filter( 'rfwc_pro_email_pdf_allowed_emails', function( $allowed, $email_id ) {
// Also attach to the "New order" admin email.
$allowed[] = 'new_order';
return $allowed;
}, 10, 2 );
Parameters:
$allowed(string[]) — Array of WC email IDs that receive attachments.$email_id(string) — The current email being processed.
Requirements#
- DOMPDF library (bundled via Composer in the Pro plugin).
- QR code generation requires outbound HTTP access to
api.qrserver.com(same as the free plugin’s QR system). Falls back gracefully if unavailable — PDF renders without QR image.
Troubleshooting#
| Issue | Solution |
|---|---|
| No PDF attached to emails | Verify the module is enabled in Modules settings and the email type checkboxes are checked |
| PDF missing QR code | Server may block outbound HTTP. Check wp-content/uploads/rfwc-temp/ for generated files |
| Blank PDF | Check PHP error log for DOMPDF errors. Ensure Composer dependencies are installed |
| Temp files not cleaning up | Verify WP-Cron is running. Check rfwc_pro_cleanup_temp_pdfs scheduled event |