Skip to content

Instantly share code, notes, and snippets.

@kloon
Created January 22, 2014 13:16
Show Gist options
  • Save kloon/8558532 to your computer and use it in GitHub Desktop.
Save kloon/8558532 to your computer and use it in GitHub Desktop.
WooCommerce add order notes to completed emails
<?php
// Add an order notes section to customers' completed emails
add_action( 'woocommerce_email_after_order_table', 'wc_add_order_notes_to_completed_emails', 10, 1 );
function wc_add_order_notes_to_completed_emails( $order ) {
if ( 'completed' == $order->status ) {
echo '<h2>' . __( 'Order Notes', 'woocommerce' ) . '</h2>';
$order_notes = $order->get_customer_order_notes();
foreach ( $order_notes as $order_note ) {
echo '<p>' . $order_note->comment_content . '<p>';
}
}
}
?>
@pacmanito
Copy link

Not sure if it's a right place to ask, but can you shed some light onto if it's better to use
if ( 'completed' == $order->status ) {}
or
if ( $email->id == 'customer_completed_order' ) {}
to target order completed emails while inserting something into email via hooks?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment