Hi
Im struggling to add a field i have created to woocoomerce email. The field appears under the users profile in WordPress. Its an internal name that we use to distinguish customers and is entered by an admin. – This all works fine.
I cannot get this field to appear in our admin-new-order email.
field name is escentia_internal
I have tried code snippets for both functions file and woocommerce email template. All result in an error on front end.
One example below.
<?php
// Get the $order ID (WooCommerce version compatibility)
if ( version_compare( WC_VERSION, ‘3.0’, ‘<‘ ) ) {
$order_id = int_val( $order->id ); // Older than 3.0
} else {
$order_id = int_val( $order->get_id() ); // 3.0+
}
$internal = get_field(‘escentia_internal’, $order_id );
if( $internal ){
echo ‘<p>’ . $internal . ‘</p>’;
}
?>
Your help would be greatly appreciated
The field is attached to the user (on user profile page), not the order.
To get the field from the user you need the user ID
get_field('escentia_internal', 'user_'.$user_id)
that being said, I have no idea how to get the user ID wherever it is that you are trying to add code.