Duplicate admin emails for new orders
-
We’re seeing duplicate admin “New order” emails on instant payments (Paytrail/Klarna).
Trace shows two separate plugin triggers after payment:PLLWC_Emails->send_new_order_email→ callsWC_Email_New_Order->trigger(Polylang)Brightplugins_COS\Checkout->admin_new_order_email→ callsWC_Email_New_Order->triggeronwoocommerce_payment_complete(Custom Order Status Manager)
WooCommerce also sends onpending → processing, so these extra triggers duplicate the notification.
Could you either:
- avoid manual triggering when Woo core will send, or
- gate your trigger with an idempotency check (e.g.,
_admin_new_order_sentmeta), or - provide a setting/filter to disable your extra send in instant-payment flows?
Example guard (pseudo):
add_action('woocommerce_payment_complete', function($order_id){
$order = wc_get_order($order_id);
if (!$order || $order->get_meta('_admin_new_order_sent')) return;
$email = WC()->mailer()->emails['WC_Email_New_Order'] ?? null;
if (!$email || !$email->is_enabled()) return;
// Optionally: only trigger if core won't (e.g., no status transition occurred)
$email->trigger($order_id);
$order->update_meta_data('_admin_new_order_sent', time());
$order->save();
});Thank you for the plugin!
You must be logged in to reply to this topic.