READ FIRST: This code needs to be added at the end of the functions.php file. If you are familiar with editing functions.php, feel free to continue reading. If you haven’t done this before, adding this code in the wrong place might bring the site down and the only way to access it is by editing functions.php file again via FTP. Feel free to contact us if you need help!
If you want to add referral information when a new order comes, use the code below:
add_action('woocommerce_email_order_details', 'action_email_order_details', 10, 4);
function action_email_order_details($order, $sent_to_admin, $plain_text, $email)
{
if ($sent_to_admin) :
// Retrieve the raf_info metadata from the order
$raf_info = get_post_meta($order->get_id(), '_wpgens_raf_meta', true);
// Check if raf_info exists and do something with it
if (!empty($raf_info)) {
echo '<h3>New Referral order</h3>';
echo '<p>' . $raf_info["info"] . '</p>';
}
endif;
}