Woocommerce new order email to customer
In WooCommerce, you can customize the new order email sent to customers by modifying the woocommerce_new_order_email
filter. Here's a step-by-step guide:
Method 1: Using the WooCommerce settings
- Log in to your WordPress dashboard and navigate to WooCommerce > Settings.
- Click on the Emails tab.
- Scroll down to the New Order section.
- Click on the Edit button next to New Order Email.
- In the Email Template field, you can modify the email template using HTML and WooCommerce placeholders (e.g.,
{order_number}
,{order_total}
,{customer_name}
, etc.). - Click Save Changes.
Method 2: Using a plugin
- Install and activate a plugin like WooCommerce Email Customizer or WooCommerce Email Templates.
- Configure the plugin to modify the new order email template.
Method 3: Using code
-
Add the following code to your theme's
functions.php
file or a custom plugin:function custom_woocommerce_new_order_email($order, $sent_to_admin, $plain_text) { // Modify the email template here $email_template = '<p>New order received!</p>'; $email_template.= '<p>Order Number: '. $order->get_order_number(). '</p>'; $email_template.= '<p>Order Total: '. $order->get_total(). '</p>'; $email_template.= '<p>Customer Name: '. $order->get_billing_first_name(). ' '. $order->get_billing_last_name(). '</p>'; return $email_template; } add_filter('woocommerce_new_order_email', 'custom_woocommerce_new_order_email', 10, 3);
In this example, we're modifying the email template to include the order number, total, and customer name.
Tips and Variations
- You can use WooCommerce's built-in placeholders (e.g.,
{order_number}
,{order_total}
,{customer_name}
, etc.) in your email template. - You can also use custom placeholders by defining them in your theme's
functions.php
file or a custom plugin. - To send a custom email to the customer, you can use the
woocommerce_new_order
action hook and send the email using thewp_mail
function. - You can also use a plugin like WooCommerce Email Customizer to create custom email templates and send them to customers.
Remember to test your modified email template to ensure it's working as expected.