Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29898

How to conditionally add function to completed order when custom field to order_id is set in woocommerce

$
0
0

I try to add a function to the completed order email in woocommerce if a specific custom field is set. I am certain the custom field is attached to the order, as i can output it on the admin order page. so far i have:

function test(){
global $woocommerce, $post;
$check = get_post_meta( $order->ID, '_digital', TRUE);
if (!empty($check)){

function order_completed_email_add_cc_bcc( $headers, $email_id, $order ) {
    if ( 'customer_completed_order' == $email_id ) {
        $headers .= "Bcc: admin <admin@example.com>" . "\r\n";
            }
    return $headers;
        }
add_filter( 'woocommerce_email_headers', 'order_completed_email_add_cc_bcc', 9999, 3 );
    }
}

However, this doesn't work...


Viewing all articles
Browse latest Browse all 29898

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>