Skip to content

Instantly share code, notes, and snippets.

@yratof
Created August 18, 2016 07:29
Show Gist options
  • Save yratof/a6cada2f14967a353ab24203d8d789e5 to your computer and use it in GitHub Desktop.
Save yratof/a6cada2f14967a353ab24203d8d789e5 to your computer and use it in GitHub Desktop.
Add content to emails sent out by woocommerce
<?php
add_action( 'woocommerce_email_before_order_table', __CLASS__ . '::before_order_email', 10, 4 );
add_action( 'woocommerce_email_after_order_table', __CLASS__ . '::after_order_email', 10, 4 );
// Add content before the order table
static function before_order_email( $order, $sent_to_admin, $plain_text, $email ) {
// If the emails links to the dashboard
if ( $sent_to_admin ) {
// email is plain text, not html
if ( ! $plain_text ) {
// HTML content here
} else {
// Plain text only
}
}
}
// Add content after the order table
static function after_order_email( $order, $sent_to_admin, $plain_text, $email ) {
// If the emails links to the dashboard
if ( $sent_to_admin ) {
// email is plain text, not html
if ( ! $plain_text ) {
// HTML content here
} else {
// Plain text only
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment