Prevent Completed Email Without Tracking Information

If you’re using third-party fulfillment services like Royal Mail Click & Drop, they often trigger a status change to Completed via API before adding tracking information to the order. This can result in WooCommerce sending two separate “Completed Order” email notifications—one without tracking and one with tracking.

To prevent customers from receiving a “Completed” email without tracking information, use the following filter to suppress the email if no tracking exists:

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_id, $order ) {
    if ( function_exists( 'ast_get_tracking_items' ) ) {
        $tracking_items = ast_get_tracking_items( $order_id );
        if ( empty( $tracking_items ) || ! is_array( $tracking_items ) ) {
            return false; // Suppress email if no tracking info
        }
    }
    return $enabled;
}

Use Case

  • When a third-party service marks an order as Completed before adding tracking, WooCommerce sends the email without tracking.
  • Then, a second API call adds the tracking info, triggering another email.
  • With this snippet, the first email is suppressed, and the customer receives only one completed order email, complete with tracking details.

$129.00

Billed annually

Buy Now