Duplicate email issue
-
Hello,
I identified a duplicate email issue related to the plugin when editing an order or changing its status to “completed” from the WooCommerce admin.
Environment:
- Latest version of WooCommerce
- Latest version of WooCommerce PDF Invoices & Packing Slips
- WP Mail SMTP enabled
- Issue reproduced both locally (MailHog) and in production (Brevo SMTP)
To diagnose the issue accurately, I developed a custom WordPress email debugging plugin that traces wp_mail() calls with full stack traces, hooks, and plugin origin detection.
Issue:
When the order status changes to “completed”, WooCommerce correctly sends the “completed order” email once.Then, the plugin triggers a second identical email.
The second send appears to originate from:
File:
wp-content/plugins/woocommerce-pdf-invoices-packing-slips/includes/Admin.phpLine:
1563Method:
send_emails()Detected trace: 4
wp_mail
woocommerce/includes/emails/class-wc-email.php : 1136 5send
woocommerce/includes/emails/class-wc-email-customer-completed-order.php : 79 6trigger
WC_Email_Customer_Completed_Order 7send_emails
woocommerce-pdf-invoices-packing-slips/includes/Admin.php : 1563The plugin appears to call:
WC_Email_Customer_Completed_Order->trigger()even though WooCommerce has already sent this email earlier in the same request.
Result:
Customers receive the same “completed order” email twice.The issue is consistently reproducible when:
- editing an order from wp-admin
- changing the order status to “completed”
Additional information:
- disabling the plugin immediately removes the duplicate email issue
- the problem occurs even without Brevo (reproduced locally with MailHog)
- WP Mail SMTP is probably not responsible, as it only handles email transport
You may want to check whether send_emails() should ignore WooCommerce transactional emails that were already sent during the same workflow, or prevent a second trigger of WC_Email_Customer_Completed_Order.
Thanks.
mp-weblab
You must be logged in to reply to this review.