更改订单处理电子邮件模板中的名字和姓氏顺序

时间:2018-02-01 作者:József Kerekes - e-central

在匈牙利语中,我们与每个oter交流时通常使用姓氏+名格式。因此,我想在Woocommerce和客户端电子邮件中更改此方法?

在哪里可以编辑此emial模板,或者应该使用过滤器?感谢您提前回复!约瑟夫

2 个回复
SO网友:József Kerekes - e-central

我想出了一个变通解决方案,它很管用,但不是最漂亮的:

// I made the original action passive
// do_action( \'woocommerce_email_customer_details\', $order, $sent_to_admin, $plain_text, $email );

// ... create a new solution from scratch 
$text_align = is_rtl() ? \'right\' : \'left\';

//to escape # from order id 

$order_id = trim(str_replace(\'#\', \'\', $order->get_order_number()));
echo $order_id;

echo \'<h2>\' . __( \'Customer comments\', \'woocommerce\' ) . \'</h2>\';

$text = apply_filters(\'the_excerpt\', get_post_field(\'post_excerpt\', $order_id)); 
echo $text;

?>

<table id="addresses" cellspacing="0" cellpadding="0" style="width: 100%; vertical-align: top;" border="0">
    <tr>
        <td class="td" style="text-align:<?php echo $text_align; ?>; font-family: \'Helvetica Neue\', Helvetica, Roboto, Arial, sans-serif;" valign="top" width="50%">
        <h3><?php _e( \'Számlázási cím\', \'woocommerce\' ); ?></h3> 
        <?php 
                echo $order->get_billing_last_name() . " ";

                echo $order->get_billing_first_name() . "<br />";

                echo $order->get_billing_address_1() . "<br />";   

                echo $order->get_billing_address_2() . "<br />";   

                echo $order->get_billing_postcode() . "<br />";

                echo $order->get_billing_email() . "<br />";

                echo $order->get_billing_phone() . "<br />";

                ?>
    </td>
    <td class="td" style="text-align:<?php echo $text_align; ?>; font-family: \'Helvetica Neue\', Helvetica, Roboto, Arial, sans-serif;" valign="top" width="50%">
                <h3><?php _e( \'Shipping address\', \'woocommerce\' ); ?></h3>
                <?php 
                echo $order->get_shipping_last_name() . " ";

                echo $order->get_shipping_first_name() . "<br />";

                echo $order->get_shipping_address_1() . "<br />";

                echo $order->get_shipping_postcode() . "<br />";                
                ?>
        </td>
    </tr>
</table>

<?php
/**
 * @hooked WC_Emails::email_footer() Output the email footer
 */ ...

SO网友:vishalprajapati13

编辑店铺的电子邮件模板,进入WooCommerce>Settings>Emails,您可以在此编辑电子邮件模板。

结束

相关推荐