Skip to content

For Developers

Settings are stored as a module option:

$module = wpify_woo_container()->get(
\WpifyWoo\Modules\EmailAttachments\EmailAttachmentsModule::class
);
$attachments = $module->get_setting( 'email_attachments' );
// Structure:
// [
// [
// 'email' => ['customer_completed_order', 'customer_processing_order'],
// 'enabled_countries' => ['CZ', 'SK'],
// 'attachments' => [123, 456], // File IDs from Media Library
// 'custom_fields' => [
// ['custom_field' => '_order_invoice_path']
// ]
// ]
// ]

Product attachments are stored as post meta:

$attachments = get_post_meta( $product_id, 'email_attachments', true );

The module supports loading file paths from order meta. This is useful for integrating with invoicing plugins that generate PDF files dynamically.

// When creating an order, save the file path
update_post_meta( $order_id, '_custom_invoice_path', '/path/to/invoice.pdf' );
// In the module settings, enter the meta key: _custom_invoice_path
// The module will automatically load the path and attach the file

This feature allows you to attach dynamically generated files (like invoices) without additional code.

Use these IDs when configuring which emails should include attachments:

IDDescription
new_orderNew order (admin)
cancelled_orderCancelled order (admin)
failed_orderFailed order (admin)
customer_on_hold_orderOrder on hold
customer_processing_orderOrder processing
customer_completed_orderOrder completed
customer_refunded_orderOrder refunded
customer_invoiceCustomer invoice
customer_noteOrder note

The module adds attachments with priority 20 on the woocommerce_email_attachments filter. Other plugins or custom code can add additional attachments using a higher priority.