For Developers
Module Settings Structure
Section titled “Module Settings Structure”Global Attachments
Section titled “Global Attachments”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
Section titled “Product Attachments”Product attachments are stored as post meta:
$attachments = get_post_meta( $product_id, 'email_attachments', true );Custom Fields (Dynamic Paths)
Section titled “Custom Fields (Dynamic Paths)”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 pathupdate_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 fileThis feature allows you to attach dynamically generated files (like invoices) without additional code.
Available Email IDs
Section titled “Available Email IDs”Use these IDs when configuring which emails should include attachments:
| ID | Description |
|---|---|
new_order | New order (admin) |
cancelled_order | Cancelled order (admin) |
failed_order | Failed order (admin) |
customer_on_hold_order | Order on hold |
customer_processing_order | Order processing |
customer_completed_order | Order completed |
customer_refunded_order | Order refunded |
customer_invoice | Customer invoice |
customer_note | Order note |
Module Priority
Section titled “Module Priority”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.