soliddigital
soliddigital

Reputation: 306

Display custom order meta data value in email notifications

In Woocommerce I am using "Show Woocommerce custom checkout field value in admin order making them editable" answer code that display a custom field value in admin order pages and works nicely.

My question: Is it possible to display that Custom field value in email notification?

Upvotes: 0

Views: 138

Answers (1)

LoicTheAztec
LoicTheAztec

Reputation: 254448

You can use the following to display your custom field "Invoice Number" on email notifications:

add_action('woocommerce_email_order_details', 'woocommerce_email_order_invoice_number', 4, 4 );
function woocommerce_email_order_invoice_number( $order, $sent_to_admin, $plain_text, $email ) {
    if( $value = get_post_meta( $order->get_id(), '_billing_options', true ) )
        echo '<p><strong>'.__('Invoice Number').':</strong> '.$value.'</p>';
}

Code goes in function.php file of your active child theme (or active theme). tested and works.

Upvotes: 1

Related Questions