When a third-party fulfilment service (such as Royal Mail Click & Drop) marks an order as Completed via API before tracking is added, WooCommerce sends the Completed email immediately — without tracking info. A second email follows when tracking is added. This snippet suppresses the first email so the customer receives only one, complete with tracking.
This filter suppresses the Completed email for every order that has no tracking at the moment WooCommerce tries to send it — including virtual products, downloadable orders, and manual completions that never receive tracking. Only use it if your store requires tracking on every completed order. If some orders should complete without tracking, add a condition to the callback (for example, check a product category or order meta before returning false).
Code snippet
Add to your child theme’s functions.php or a site-specific plugin:
add_filter( 'woocommerce_email_enabled_customer_completed_order', 'zorem_disable_completed_email_without_tracking', 10, 3 );
function zorem_disable_completed_email_without_tracking( $enabled, $order, $email ) {
if ( function_exists( 'ast_get_tracking_items' ) ) {
$tracking_items = ast_get_tracking_items( $order->get_id() );
if ( empty( $tracking_items ) || ! is_array( $tracking_items ) ) {
return false; // Suppress email — no tracking on this order yet
}
}
return $enabled;
}
How it works
Filter reference
| Parameter | Type | Description |
|---|---|---|
$enabled | bool | Whether the email is currently enabled. Return false to suppress. |
$order | WC_Order | The order object. Call $order->get_id() to get the order ID. |
$email | WC_Email | The email object being sent. |