Customize formatted billing full name with a custom field in Woocommerce emails

强颜欢笑 提交于 2019-12-07 08:34:25

You will need to replace in emails/admin-new-order.php template the following (on line 28):

 <p><?php printf( __( 'You have received an order from %s. The order is as follows:', 'woocommerce' ), $order->get_formatted_billing_full_name() ); ?></p>

By this code (where _billing_voornaam_1_24 is the meta_key of your custom field):

<p><?php 
    $formatted_full_name   = $order->get_billing_first_name();
    $formatted_full_name  .= ' ' . get_post_meta( $order->get_id(), '_billing_voornaam_1_24', true );
    $formatted_full_name  .= ' ' . $order->get_billing_last_name();

    printf( __( 'You have received an order from %s. The order is as follows:', 'woocommerce' ), $formatted_full_name ); ?></p>

This should work if _billing_voornaam_1_24 custom field exists for the order…

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!