How to Customise the WooCommerce Order Confirmation Email with Product-Specific Messages – 2026

Last updated on December 23rd, 2024 at 06:44 am

Customising the WooCommerce order confirmation email to include product-specific messages is a great way to personalise communication with your customers. You can use this method to provide product instructions, warranty details, usage tips, or promotional content.

In this guide, we’ll show you how to add custom product-specific messages to the WooCommerce order confirmation email, without using a plugin. This approach allows you to tailor the email based on the products purchased.


Step 1: Add a Custom Field for Product-Specific Messages

To display product-specific messages in the order confirmation email, we first need a place to store these messages for each product. We’ll add a custom field on the WooCommerce product edit page.

Code to Add a Custom Field for Product Messages

Add this code to your theme’s functions.php file or your child theme:

/*
 * Snippet: How to Customise the WooCommerce Order Confirmation Email with Product-Specific Messages – 2026
* Author: John Cook
* URL: https://wcsuccessacademy.com/?p=1789
* Tested with WooCommerce 10.7.0
* "This function adds a custom field for product specific messages"
*/ function wcsuccess_add_product_custom_message_field() { woocommerce_wp_textarea_input( array( 'id' => '_product_custom_message', 'label' => __( 'Custom Email Message', 'woocommerce' ), 'description' => __( 'This message will be displayed in the order confirmation email for this product.', 'woocommerce' ), 'desc_tip' => true, )); } add_action( 'woocommerce_product_options_general_product_data', 'wcsuccess_add_product_custom_message_field' ); /* * Snippet: How to Customise the WooCommerce Order Confirmation Email with Product-Specific Messages – 2026
* Author: John Cook
* URL: https://wcsuccessacademy.com/?p=1789
* Tested with WooCommerce 10.7.0
* "This function saves the custom field value for product specific messages"
*/ function wcsuccess_save_product_custom_message_field( $post_id ) { $custom_message = isset( $_POST['_product_custom_message'] ) ? sanitize_textarea_field( $_POST['_product_custom_message'] ) : ''; update_post_meta( $post_id, '_product_custom_message', $custom_message ); } add_action( 'woocommerce_process_product_meta', 'wcsuccess_save_product_custom_message_field' );

Explanation:

  • Custom Field: Adds a new text area under the “General” tab in the WooCommerce product edit screen.
  • Data Storage: Stores the custom message in the product’s metadata so it can be retrieved later for email customisation.

Step 2: Add Product-Specific Messages to the Email Template

Next, we’ll display the custom message in the order confirmation email for each product purchased.

Code to Add Product-Specific Messages to the Email

Add this code to your functions.php file:

/*
 * Snippet: How to Customise the WooCommerce Order Confirmation Email with Product-Specific Messages – 2026
* Author: John Cook
* URL: https://wcsuccessacademy.com/?p=1789
* Tested with WooCommerce 10.7.0
* "This function adds the product specific message to the order confirmation email"
*/ function wcsuccess_add_product_message_to_email( $order, $sent_to_admin, $plain_text, $email ) { if ( ! is_a( $order, 'WC_Order' ) ) { return; } echo '<h2>Important Product Information</h2>'; foreach ( $order->get_items() as $item_id => $item ) { $product_id = $item->get_product_id(); $product_message = get_post_meta( $product_id, '_product_custom_message', true ); if ( ! empty( $product_message ) ) { echo '<div class="product-message" style="margin-bottom: 15px; padding: 10px; background-color: #f9f9f9; border-left: 4px solid #3498db;">'; echo '<strong>' . esc_html( $item->get_name() ) . ':</strong><br>'; echo '<p>' . esc_html( $product_message ) . '</p>'; echo '</div>'; } } } add_action( 'woocommerce_email_order_meta', 'wcsuccess_add_product_message_to_email', 20, 4 );

Explanation:

  • Order Loop: Loops through all items in the order and retrieves the custom message for each product.
  • Email Content: Displays the message under an Important Product Information section in the order confirmation email.
  • Custom Styling: Customises the appearance of the message with a blue border and background.
See also  How to Programmatically Disable WooCommerce Emails - 2026

Step 3: Customise the Email Styling

You can make the product-specific message look more appealing by adding custom CSS to your WooCommerce email template.

CSS to Style the Product Messages

Add this CSS to your WooCommerce email-styles.php file or override it via the WordPress customiser.

.product-message {
    background-color: #f9f9f9;
    border-left: 4px solid #3498db;
    padding: 10px;
    margin-bottom: 15px;
}

.product-message p {
    font-size: 14px;
    color: #333;
    margin: 0;
}

Explanation:

  • Product Message Design: The message appears with a blue border and light grey background.
  • Custom Styling: Customise the padding, font size, and border colour to suit your store’s branding.

Step 4: Customise the Display Conditions (Optional)

If you’d like to show the message only for specific order statuses (like Processing or Completed), you can customise the display logic.

Code to Show Product Messages for Specific Email Types

Modify the following part of the function:

if ( $email->id !== 'customer_processing_order' && $email->id !== 'customer_completed_order' ) {
    return;
}

This will ensure that the product-specific messages are only shown in the Processing and Completed order emails.


Example Workflow

  1. Customise the Product:
    • Edit a WooCommerce product and add a custom message in the Custom Email Message field.
  2. Customer Places an Order:
    • The customer buys the product, triggering the order confirmation email.
  3. Order Confirmation Email:
    • The product-specific message is displayed below the product details in the email.

Example Use Case

ProductCustom Message
T-shirt“Wash inside-out at 30°C to maintain colour.”
Smartphone“Register your device for a 1-year warranty.”
Furniture“Assembly required. Follow the included manual.”

When a customer buys the Smartphone, they will see this message in their order confirmation email:

Important Product Information
Smartphone
Register your device for a 1-year warranty.


Advanced Customisation

Add Messages for Variable Products

If you’d like to add messages for specific variations, change the following line:

$product_id = $item->get_variation_id() ? $item->get_variation_id() : $item->get_product_id();

This allows you to add custom messages for specific variations instead of the parent product.

See also  How to Export WooCommerce Reviews Without a Plugin - 2026

Add Custom Messages for Order Notes

Instead of placing the message below the product, you could add it as an order note.

function wcsuccess_add_order_note_for_product_message( $order_id ) {
    $order = wc_get_order( $order_id );

    foreach ( $order->get_items() as $item_id => $item ) {
        $product_id = $item->get_product_id();
        $product_message = get_post_meta( $product_id, '_product_custom_message', true );

        if ( ! empty( $product_message ) ) {
            $order->add_order_note( 'Product: ' . $item->get_name() . ' - ' . $product_message );
        }
    }
}
add_action( 'woocommerce_thankyou', 'wcsuccess_add_order_note_for_product_message' );

This will add the product-specific message as an order note visible in the WooCommerce admin panel.


Conclusion

Customising the WooCommerce order confirmation email with product-specific messages allows you to provide important details, usage instructions, or promotional content. By following this guide, you can display these messages for each product included in the order.

Test these changes in a staging environment before applying them to your live site. For more WooCommerce customisation tips, check out our WooCommerce Visual Hooks Guide or use our wp-config generator for advanced configurations.

0 0 votes
Article Rating

Stay In Touch

Was this post helpful? Why not show your support and buy me a coffee?

Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Scroll to Top
0
Would love your thoughts, please comment.x
()
x
×