Hi @clarru ,
Greetings from WebToffee Support!
Thank you for reaching out to us regarding the requirement you are seeking. To ensure that your custom field is displayed in the order emails, you can utilize the provided code snippet. You can copy the code snippet provided below and paste it into your active theme’s functions.php file (WordPress Dashboard > Appearance > Theme Editor > functions.php), or you can use a Code Snippet plugin to do that for you.
add_filter('wt_woomail_order_body_text','wbte_dec_add_custom_placeholder_to_order_emails',10,5);
function wbte_dec_add_custom_placeholder_to_order_emails($body_text, $order, $sent_to_admin, $plain_text, $email) {
if ( is_a( $email->object, 'WC_Order' ) && !empty($order) ) {
$shipping_link = $order->get_meta( '_shipping_link', true );
if ( ! empty( $shipping_link ) && strpos( $body_text, '{_shipping_link}' ) !== false ) {
$body_text = str_replace( '{_shipping_link}', $shipping_link, $body_text );
}
}
return $body_text;
}This code snippet will replace the {_shipping_link} placeholder in your order emails with the value of the _shipping_link custom field from your WooCommerce orders.
Feel free to reach out if you need any further clarification or assistance. We’re here to help!
Thread Starter
clarru
(@clarru)
Thank you! Works perfectly!
Now I have another problem with the email rendering but I’ll create a sepparate ticket!
