Last active
September 23, 2021 20:53
-
-
Save woogists/1b71d6842960fa056bd61bd0ca60ecba to your computer and use it in GitHub Desktop.
Add a custom field (in an order) to the emails
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Add a custom field (in an order) to the emails | |
*/ | |
add_filter( 'woocommerce_email_order_meta_fields', 'custom_woocommerce_email_order_meta_fields', 10, 3 ); | |
function custom_woocommerce_email_order_meta_fields( $fields, $sent_to_admin, $order ) { | |
$fields['meta_key'] = array( | |
'label' => __( 'Label' ), | |
'value' => get_post_meta( $order->id, 'meta_key', true ), | |
); | |
return $fields; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@marketingsolution the if/else is for emails that are sent in plain text versus emails that are sent with HTML markup. You didn't say what your fatal error was so it's hard to say... though I do see a problem at the end of
echo 'The value for <strong>some field</strong> is ' . $NIP.;
there's a period just before the semi-colon that should not be there.