Does anyone know how to auto-insert tracking numbers in the customer order status "completed" email?
If the tracking number is part of the Order Metadata you can do it by adding a custom function to the functions.php. For example like this:
add_action( 'woocommerce_email_after_order_table', 'add_trackingnr_meta', 10, 3);
function add_trackingnr_meta( $order_obj, $sent_to_admin, $plain_text )
{
// Important: You need to know the Metaname !!tracking_number!!! is just an example
$is_trackingNr = get_post_meta( $order_obj->get_order_number(), 'tracking_number', true );
// we won't display anything if its empty
if( empty( $is_trackingNr ) )
return;
// Html Email
if ( $plain_text === false )
{
echo '<h2>Trackinginformations</h2>
<ul>
<li><strong>Tracking Number:</strong> ' . $is_trackingNr . '</li>
</ul>';
}
//Plaintext Email
else
{
echo "\n Trackinginformations\n
<strong>Trackingnumber: </strong>$is_trackingNr\n\n";
}
}
Just to clearify this function will always send a Tracking Number if its set and Part of the Ordermeta.
It will not check the Order State(completed eg).