Skip to content

Instantly share code, notes, and snippets.

@andrewreal
Last active December 3, 2020 09:19
Show Gist options
  • Save andrewreal/b5d6771f538c0384aecb39a7560afff8 to your computer and use it in GitHub Desktop.
Save andrewreal/b5d6771f538c0384aecb39a7560afff8 to your computer and use it in GitHub Desktop.
WooCommerce Email Hooks

Modify Email Receipients

Filter - woocommerce_email_recipient_new_order

add_filter( 'woocommerce_email_recipient_new_order', 'blz_add_recipient', 10, 3 );

/**
 * Add Branch to order notification email recipients
 *
 * @param string $recipient
 * @param WC_Order|bool $order
 * @param WC_Email $wc_email e.g. WC_Email_New_Order
 * @return string
 */
public function blz_add_recipient( $recipient, $order, $wc_email ){
    if ( ! $order instanceof WC_Order ) {
        return $recipient; 
    }
    // Code to add or edit recipient
    return $recipient;
}

Filter - woocommerce_email_recipient_cancelled_order

add_filter( 'woocommerce_email_recipient_cancelled_order', 'blz_add_recipient', 10, 3 );
// Similar function structure to above 

Filter - woocommerce_email_recipient_failed_order

add_filter( 'woocommerce_email_recipient_failed_order', 'blz_add_recipient', 10, 3 );
// Similar function structure to above 

Filter - woocommerce_email_recipient_customer_refunded_order

add_filter( 'woocommerce_email_recipient_customer_refunded_order', 'blz_add_recipient', 10, 3 );
// Similar function structure to above 

Filter - woocommerce_email_recipient_customer_partially_refunded_order

add_filter( 'woocommerce_email_recipient_customer_partially_refunded_order', 'blz_add_recipient', 10, 3 );
// Similar function structure to above 

Modify Email Content - Meta

Action - woocommerce_email_order_meta

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