在 WooCommerce 电子邮件上查找/编辑订单详细信息元文本

我正在尝试将客户电子邮件翻译成中文,但在源代码中的任何地方都找不到这些:

我已经能够找到其他所有内容,我认为这些也是硬编码的,但我无法在代码中找到它们。

http://img4.mukewang.com/6129dcb40001cf2e06840690.jpg

这是在我的email-order-details.php文件中:


<?php

$totals = $order->get_order_item_totals();


if ( $totals ) {

    $i = 0;

    foreach ( $totals as $total ) {

        $i++;

        ?>

        <tr>

            <th class="td" scope="row" colspan="2" style="text-align:<?php echo esc_attr( $text_align ); ?>; <?php echo ( 1 === $i ) ? 'border-top-width: 4px;' : ''; ?>"><?php echo wp_kses_post( $total['label'] ); ?></th>

            <td class="td" style="text-align:<?php echo esc_attr( $text_align ); ?>; <?php echo ( 1 === $i ) ? 'border-top-width: 4px;' : ''; ?>"><?php echo wp_kses_post( $total['value'] ); ?></td>

        </tr>

        <?php

    }

}

if ( $order->get_customer_note() ) {

    ?>

    <tr>

        <th class="td" scope="row" colspan="2" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'Note:', 'woocommerce' ); ?></th>

        <td class="td" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php echo wp_kses_post( wptexturize( $order->get_customer_note() ) ); ?></td>

    </tr>

    <?php

但我看不到在哪里可以更改以下内容:

  • 小计:

  • 折扣:

  • 船运:

  • 付款方法:

  • 全部的:

  • 税费:


慕的地10843
浏览 174回答 1
1回答

四季花海

通过名为的内置 WordPress 过滤器翻译字符串gettext可能是更好的方法,特别是因为翻译应该是站点范围的,而不仅仅是在电子邮件上,示例如下:add_filter( 'gettext', 'my_custom_string_translation', 999, 3 );function my_custom_string_translation( $translated, $text, $domain ) {&nbsp; &nbsp; $translated = str_ireplace( 'Subtotal',&nbsp; &nbsp; &nbsp; &nbsp;'Your translation here.', $translated );&nbsp; &nbsp; $translated = str_ireplace( 'Discount',&nbsp; &nbsp; &nbsp; &nbsp;'Your translation here.', $translated );&nbsp; &nbsp; $translated = str_ireplace( 'Shipping',&nbsp; &nbsp; &nbsp; &nbsp;'Your translation here.', $translated );&nbsp; &nbsp; $translated = str_ireplace( 'Payment Method', 'Your translation here.', $translated );&nbsp; &nbsp; $translated = str_ireplace( 'Total',&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'Your translation here.', $translated );&nbsp; &nbsp; return $translated;}您可以将上面的代码放在您的functions.php或自定义插件文件中。
打开App,查看更多内容
随时随地看视频慕课网APP