WooCommerce - 替换电子邮件模板中的运输标签



也许这是一个重复的,但我真的很难在谷歌,Stackoverflow等任何地方找到它。

我在WooCommerce中总是遇到更改电子邮件模板的问题,它非常厌烦且不友好。但是我的问题是,在哪里或如何更改客户和管理员收到的电子邮件模板中的"运输"标签?

我需要添加一些钩子还是可以在 php 文件中替换它?

我已经搜索了 php 文件,但找不到它...

有人有想法吗?

Woo-commerce中发送了许多电子邮件,并且还有许多模板可以将特定的订单数据提取到电子邮件本身中。要查找这些模板,您可以转到:

woocommerce/templates/email/(这在插件文件夹中)

此时您要做的基本上是复制要编辑的电子邮件模板,并将它们保存在以下位置:your_theme/woocommerce/email/。这将做的本质上是创建Woo-commerce使用的主要模板的子模板,这样在插件更新的情况下,您不会丢失对相应电子邮件模板所做的任何更改。

如果你想...例如,编辑管理员在下新订单时收到的电子邮件,此模板位于此处(在您的插件文件夹中)woocommerce/templates/email/admin-new-order.php

以下是相应模板中的实际代码,因此您知道您已经找到了我提到的正确代码:

<?php
/**
* Admin new order email
*
* This template can be overridden by copying it to yourtheme/woocommerce/emails/admin-new-order.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see         https://docs.woocommerce.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates/Emails/HTML
* @version 2.5.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* @hooked WC_Emails::email_header() Output the email header
*/
do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
<p><?php printf( __( 'You have received an order from %s. The order is as follows:', 'woocommerce' ), $order->get_formatted_billing_full_name() ); ?></p>
<?php
/**
* @hooked WC_Emails::order_details() Shows the order details table.
* @hooked WC_Structured_Data::generate_order_data() Generates structured data.
* @hooked WC_Structured_Data::output_structured_data() Outputs structured data.
* @since 2.5.0
*/
do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email );
/**
* @hooked WC_Emails::order_meta() Shows order meta data.
*/
do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email );
/**
* @hooked WC_Emails::customer_details() Shows customer details
* @hooked WC_Emails::email_address() Shows email address
*/
do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email );
/**
* @hooked WC_Emails::email_footer() Output the email footer
*/
do_action( 'woocommerce_email_footer', $email );

请记住,这些模板本身中仍有许多钩子,您可能需要根据您尝试在模板中实际更改的内容来钩住它们,但是在大多数情况下,由于您现在知道在哪里可以找到它们,这应该相对简单。

希望这有帮助!祝你好运:)

最新更新