Created
January 22, 2014 13:16
-
-
Save kloon/8558532 to your computer and use it in GitHub Desktop.
WooCommerce add order notes to completed emails
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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>'; | |
} | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?