I used the following code to get all info in the email:
add_action( 'woocommerce_email_order_details', 'action_wc_email_order_details', 50, 4 );
function action_wc_email_order_details( $order, $sent_to_admin, $plain_text, $email ){
// Get the Order ID (WooCommerce retro-compatibility)
$order_id = method_exists( $order, 'get_id' ) ? $order->get_id() : $order->id;
// Get "serial" custom field value
$serial = get_post_meta($order_id, $key = '', $single = false );
// Display "serial" custom field value
echo '<p>'.__('Serial', 'woocommerce') . $serial . '</p>';
echo print_r( $serial );
$order = wc_get_order( $order_id);
// Loop through order line items
foreach( $order->get_items() as $item ){
// get order item data (in an unprotected array)
$item_data = $item->get_data();
// get order item meta data (in an unprotected array)
$item_meta_data = $item->get_meta_data();
// get only additional meta data (formatted in an unprotected array)
$formatted_meta_data = $item->get_formatted_meta_data();
// Display the raw outputs (for testing)
echo '<pre>'; print_r($item_meta_data); echo '</pre>';
echo '<pre>'; print_r($formatted_meta_data); echo '</pre>';
}
}
This outputs the array with all the data of the order:
[10395] => stdClass Object
(
[key] => _uni_cpo_foto_slagroomaanbieding
[value] => 2983
[display_key] => Upload hier uw foto
[display_value] => rechts-3.jpg
)
The “rechts-3.jpg” needs to be “www.domain.nl/wp-contents/uploads/rechts-3.jpg”
I have no idea if the code above is an hook… I just copied it from the internet ??