Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save andrasguseo/d8245648574ba9620d6ce90763ac58f7 to your computer and use it in GitHub Desktop.
Save andrasguseo/d8245648574ba9620d6ce90763ac58f7 to your computer and use it in GitHub Desktop.

Revisions

  1. Andras Guseo revised this gist Mar 6, 2018. 1 changed file with 20 additions and 3 deletions.
    23 changes: 20 additions & 3 deletions add_bcc_to_certain_emails.php
    Original file line number Diff line number Diff line change
    @@ -2,22 +2,39 @@

    /**
    * Function adds a BCC header to emails that match our array
    *
    * Plugins: WooCommerce
    * Original Author: Jesse Pearson (https://gist.github.com/jessepearson)
    * Modified by: Andras Guseo
    * Last updated: March 5, 2018
    *
    *
    * @param string $headers The default headers being used
    * @param string $object The email type/object that is being processed
    */
    function add_bcc_to_certain_emails( $headers, $object ) {

    // email types/objects to add bcc to
    // Comment out what you don't need
    $add_bcc_to = array(
    'customer_renewal_invoice', // Renewal invoice from WooCommerce Subscriptions
    'customer_processing_order', // Customer Processing order from WooCommerce
    //'customer_renewal_invoice', // Renewal invoice from WooCommerce Subscriptions
    //'customer_processing_order', // Customer Processing order from WooCommerce
    //'cancelled_order', // Customer Cancelled order from WooCommerce
    //'customer_completed_order', // Customer Completed order from WooCommerce
    //'customer_invoice', // Customer Invoice email from WooCommerce
    //'customer_new_account', // Customer New Account email from WooCommerce
    //'customer_note', // Customer Note email from WooCommerce
    //'customer_on_hold_order', // Customer On Hold order from WooCommerce
    //'customer_refunded_order', // Customer Refunded order from WooCommerce
    //'customer_reset_password', // Customer Reset Password email order from WooCommerce
    //'failed_order', // Customer Failed order from WooCommerce
    'new_order', // Customer New Order order from WooCommerce
    );

    // if our email object is in our array
    if ( in_array( $object, $add_bcc_to ) ) {

    // change our headers
    // Change our headers
    $headers = array(
    $headers,
    'Bcc: Me <[email protected]>' ."\r\n",
  2. @jessepearson jessepearson created this gist Oct 31, 2016.
    29 changes: 29 additions & 0 deletions add_bcc_to_certain_emails.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    <?php // only copy this line if needed

    /**
    * Function adds a BCC header to emails that match our array
    *
    * @param string $headers The default headers being used
    * @param string $object The email type/object that is being processed
    */
    function add_bcc_to_certain_emails( $headers, $object ) {

    // email types/objects to add bcc to
    $add_bcc_to = array(
    'customer_renewal_invoice', // Renewal invoice from WooCommerce Subscriptions
    'customer_processing_order', // Customer Processing order from WooCommerce
    );

    // if our email object is in our array
    if ( in_array( $object, $add_bcc_to ) ) {

    // change our headers
    $headers = array(
    $headers,
    'Bcc: Me <[email protected]>' ."\r\n",
    );
    }

    return $headers;
    }
    add_filter( 'woocommerce_email_headers', 'add_bcc_to_certain_emails', 10, 2 );