I'd like to remove the auto-generated order number from both the "Order on-hold" and "New order" emails generated by WooCommerce.
I'm using a third-party plugin to assign custom order numbers after an order has been placed, so it's important that the new order number I assign can still be used in future emails. I don't want the customer (or admin) to see the original order number until it has been changed.
Any help would be greatly appreciated!
Updated (only for woocommerce 3.3+ specific template)
You will need to override a Woocommerce email template via your child theme as explained on the below linked official documentation:
Template structure & Overriding templates via a theme
The template to copy and override is woocommerce/templates/emails/email-order-details.php
In this template (copied to your theme as explained) you will need to change this entire block:
<h2>
<?php
if ( $sent_to_admin ) {
$before = '<a class="link" href="' . esc_url( $order->get_edit_order_url() ) . '">';
$after = '</a>';
} else {
$before = '';
$after = '';
}
/* translators: %s: Order ID. */
echo wp_kses_post( $before . sprintf( __( 'Order #%s', 'woocommerce' ) . $after . ' (<time datetime="%s">%s</time>)', $order->get_order_number(), $order->get_date_created()->format( 'c' ), wc_format_datetime( $order->get_date_created() ) ) );
?>
</h2>
to:
<?php
// Targetting specific email notificatoins
$email_ids = array('new_order', 'customer_on_hold_order');
$date = sprintf( '<time datetime="%s">%s</time>', $order->get_date_created()->format( 'c' ), wc_format_datetime( $order->get_date_created() ) );
// Displaying order number except for "New Order" and "Customer On Hold Order" notifications
if( ! in_array($email->id, $email_ids) ){
$order_number = sprintf( __( 'Order #%s', 'woocommerce' ), $order->get_order_number() );
$date = '('.$date.')';
} else {
$date = __('Order date:', 'woocommerce') . ' ' . $date;
$order_number = '';
}
if ( $sent_to_admin ) {
$before = '<a class="link" href="' . esc_url( $order->get_edit_order_url() ) . '">';
$after = '</a> ';
} else {
$before = '';
$after = ' ';
}
?>
<h2><?php echo $before . $order_number . $after . $date; ?></h2>
This will remove the Order number on "New Order" and "Customer On Hold Order" email notifications. You will get:
1) New order (admin):
2) Customer On-Hold Order:
Now you will also need in WooCommerce > Settings > Emails to remove ({order_number})
from "New Order" subject and save…
You are done…