I have custom fields in the checkout in woocommerce and I want these fields to appear in the email template.
I am adding the following but it still not showing:
<?php if ( have_posts() ) : while ( have_posts() ) : the_post();
$mycustom = get_post_meta( $order->id, 'wccf_delivery_day', true );
echo $mycustom;?>
<?php endwhile; ?>
You can customize the emails via your wp-admin > WooCommerce > Settings > Emails. Here you'll find the ability to customize all of the emails that WooCommerce sends both to you as a store admin, and to your customers.
Double-check that “Enable this email notification” is ticked for order notifications at WooCommerce > Settings > Emails and select the Processing Order email template. An additional test should be setting the Email Type to plain text.
You can make use of woocommerce_email_order_meta_keys
filter hook
add_filter('woocommerce_email_order_meta_keys', 'my_woocommerce_email_order_meta_keys');
function my_woocommerce_email_order_meta_keys( $keys ) {
$keys['Delivery Day'] = '_wccf_delivery_day';
return $keys;
}
If you need more control over the display try using woocommerce_email_after_order_table
action hook
add_action( "woocommerce_email_after_order_table", "custom_woocommerce_email_after_order_table", 10, 1);
function custom_woocommerce_email_after_order_table( $order ) {
echo '<p><strong>Delivery Day :</strong>'. get_post_meta( $order->id, "_wccf_delivery_day", true ) .'</p>';
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With