dragon0023 2018-01-29 15:10
浏览 77
已采纳

使用Woocommerce电子邮件中的自定义字段自定义格式化的结算全名

On one of my websites I use the Flexible Checkout Fields for WooCommerce to make 20 custom fields. Two of them needed to be a select/dropdown field. I wasn't able to do so via the plugin (didn't want to pay for it. Regret that decision now. It is horrible); so I used the first-name and last-name default tags from WooCommerce to make them into a select field. I use them to select the Mr/Mrs title before the name.

The emails now only show the first-name and last-name fields, as where I would like to have the first-name (Mr/Mrs title select) and my new custom field for the first name.

I found the code below in admin-new-order.php; <p><?php printf( __( 'You have received an order from %s. The order is as follows:', 'woocommerce' ), $order->get_formatted_billing_full_name() ); ?></p>

as where $order->get_formatted_billing_full_name() will display the billing first-name and billing last-name.

Is there a way to display billing first-name and my custom field? And if so, how?

Thanks in advance.

  • 写回答

1条回答 默认 最新

  • douliang7068 2018-01-29 16:19
    关注

    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…

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 请问为什么我配置IPsec后PC1 ping不通 PC2,抓包出来数据包也并没有被加密
  • ¥200 求博主教我搞定neo4j简易问答系统,有偿
  • ¥15 nginx的使用与作用
  • ¥100 关于#VijeoCitect#的问题,如何解决?(标签-ar|关键词-数据类型)
  • ¥15 一个矿井排水监控系统的plc梯形图,求各程序段都是什么意思
  • ¥15 ensp路由器启动不了一直报#
  • ¥50 安卓10如何在没有root权限的情况下设置开机自动启动指定app?
  • ¥15 ats2837 spi2从机的代码
  • ¥200 wsl2 vllm qwen1.5部署问题
  • ¥100 有偿求数字经济对经贸的影响机制的一个数学模型,弄不出来已经快要碎掉了