如何更改电子邮件中的woocommerce客户详细信息标签?

时间:2017-02-01 17:51:03

标签: php woocommerce

我已更改客户备注的客户详细信息标签,但不会更改“新订单”电子邮件中的标签。我怎么能改变这个?

以下是我在提交订单后更改发票页面上显示方式的方式:

<header><h2><?php _e( 'Customer Details', 'woocommerce' ); ?></h2></header>

<table class="shop_table customer_details">
<?php if ( $order->customer_note ) : ?>
    <tr>
        <th><?php _e( 'Requested Dates:', 'woocommerce' ); ?></th>
        <td><?php echo wptexturize( $order->customer_note ); ?></td>
    </tr>
<?php endif; ?>

这对电子邮件没有任何作用。以下是它在电子邮件中的显示方式的屏幕截图:

I want this to cay "Requested Dates" instead of "Note"

我在email-customer-details.php文件中找到了这段代码:

<h2><?php _e( 'Customer details', 'woocommerce' ); ?></h2>
<ul>
<?php foreach ( $fields as $field ) : ?>
    <li><strong><?php echo wp_kses_post( $field['label'] ); ?>: </strong> 
<span class="text"><?php echo wp_kses_post( $field['value'] );    ?></span></li>
<?php endforeach; ?>
</ul>

解决这个问题可能会有所帮助。

1 个答案:

答案 0 :(得分:2)

您可以过滤woocommerce_email_customer_details_fields,这是传递给email-customer-details.php模板的信息数组。

function so_41986388_email_customer_details_fields( $fields, $sent_to_admin, $order ){
    if( isset( $fields['customer_note'] ) ) {
        $fields['customer_note']['label'] = __( 'Requested Dates:', 'your-text-domain' );
    }
    return $fields;
}
add_filter( 'woocommerce_email_customer_details_fields', 'so_41986388_email_customer_details_fields', 10, 3 );
相关问题