How to Change WooCommerce Order Confirmation Email Title

How to change order confirmation email title in woocommerce; Woocommerce change order email subject line; Edit woocommerce order confirmation email title; Customize subject of woocommerce order emails; Change title of order confirmation email woocommerce; Woocommerce email subject line customization; Modify order confirmation email title woocommerce; How to edit woocommerce order email subject; Woocommerce change email title for order confirmation; Update subject line in woocommerce order emails;

Explanation

Want to tweak the subject lines of your WooCommerce order emails? Here's a simple way to do it.

For Processing Orders:

  • This code changes the subject line for emails sent when an order is being processed.
  • It checks if the email is related to a processing order and then updates the subject to say, "Your Order #123 is Being Processed."

For Completed Orders:

  • Similarly, this code updates the subject line for completed order emails.
  • It changes the subject to "Your Order #123 is Complete" once the order status is marked as completed.

These changes help make your emails more informative and personalized by including the order number directly in the subject line. Just make sure to add this code to your theme's functions.php file or a custom plugin to see it in action.

Code

<?php
// Function to change the subject line of WooCommerce order confirmation emails
function wp_dudecom_custom_order_email_subject( $subject, $order ) {
    // Check if the email is the customer processing order email
    if ( is_a( $order, 'WC_Order' ) && $order->has_status( 'processing' ) ) {
        // Customize the subject line
        $subject = sprintf( __( 'Your Order #%s is Being Processed', 'woocommerce' ), $order->get_order_number() );
    }
    return $subject;
}
add_filter( 'woocommerce_email_subject_customer_processing_order', 'wp_dudecom_custom_order_email_subject', 10, 2 );

// Function to change the subject line of WooCommerce completed order emails
function wp_dudecom_custom_completed_order_email_subject( $subject, $order ) {
    // Check if the email is the customer completed order email
    if ( is_a( $order, 'WC_Order' ) && $order->has_status( 'completed' ) ) {
        // Customize the subject line
        $subject = sprintf( __( 'Your Order #%s is Complete', 'woocommerce' ), $order->get_order_number() );
    }
    return $subject;
}
add_filter( 'woocommerce_email_subject_customer_completed_order', 'wp_dudecom_custom_completed_order_email_subject', 10, 2 );
?>

Instructions

File Location: Add the following code to your theme's functions.php file or create a custom plugin file.

Prerequisites:

  • Ensure WooCommerce is installed and activated on your WordPress site.

Implementation Steps:

  1. Access your WordPress admin dashboard.
  2. Navigate to Appearance > Theme Editor if you are adding the code to functions.php. Alternatively, go to Plugins > Add New > Create a new plugin if you prefer using a custom plugin.
  3. In the Theme Editor, locate and open the functions.php file of your active theme. If creating a plugin, open your plugin file.
  4. Copy and paste the provided code snippet into the file.
  5. Save the changes to the file.
  6. Test the functionality by placing a test order and checking the email subject lines for processing and completed orders.

By following these steps, you can customize the subject lines of your WooCommerce order confirmation emails to make them more informative and personalized.

Need help with implementation or more advanced functionality? Visit wp-dude.com for expert assistance.