Buy All 47 Premium Themes For the Price Of $199.99

How to Send a Custom Email After WooCommerce Order Completion Using Hooks

Automated emails are one of the most powerful features in WooCommerce.
Instead of relying only on default notifications, you can send custom emails with personalized content after an order is completed.

In this tutorial, you will learn how to use a WooCommerce hook to trigger a custom email when an order status changes to “completed”.

Why Custom Emails Are Important

Post-purchase communication helps improve customer satisfaction and builds long-term loyalty.

  • Strengthens brand experience
  • Increases repeat purchases
  • Allows upselling and cross-selling
  • Improves customer trust

The WooCommerce Hook We Will Use

We will use:

woocommerce_order_status_completed

This hook fires when an order is marked as completed in WooCommerce.

Example Code

Add this code to your theme’s functions.php file or a custom plugin:


add_action('woocommerce_order_status_completed', 'send_custom_completed_order_email');

function send_custom_completed_order_email($order_id) {

    if (!$order_id) {
        return;
    }

    $order = wc_get_order($order_id);
    $email = $order->get_billing_email();
    $name  = $order->get_billing_first_name();

    $subject = 'Thank you for your order!';

    $message = '
        

Hi ' . esc_html($name) . ',

Thank you for your purchase! Your order has been completed successfully.

We hope you enjoy your products. If you have any questions, feel free to contact us.

Best regards,
Your Store Team

'; wp_mail($email, $subject, $message, array('Content-Type: text/html; charset=UTF-8')); }

How It Works

This function runs automatically when an order is completed:

  • Gets order data from WooCommerce
  • Extracts customer email and name
  • Sends a custom HTML email using wp_mail()

Important Notes

  • Make sure your server supports sending emails
  • Use SMTP for better email deliverability
  • Test with real orders before going live

Advanced Ideas

  • Add discount coupons inside the email
  • Include product recommendations
  • Send follow-up emails after 3–7 days
  • Personalize content based on purchased products