在 Woo-commerce 中发送了许多电子邮件,还有一些模板可以将特定的订单数据提取到电子邮件本身中。要找到这些模板,您可以访问:
woocommerce/templates/emails/(位于插件文件夹中)
此时您要做的基本上是复制您要编辑的电子邮件模板,并将它们保存在以下位置:your_theme/woocommerce/emails/。这实际上是为 Woo-commerce 使用的主模板创建一个子模板,这样在插件更新的情况下,您不会丢失对相应电子邮件模板所做的任何更改。
如果您希望...例如编辑下新订单时管理员收到的电子邮件,此模板位于此处(在您的插件文件夹中)woocommerce/templates/emails/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 );
请记住,这些模板本身仍有许多钩子,您可能必须根据您要在模板中实际更改的内容进行钩子,但大多数情况下,因为您现在知道在哪里可以找到它们,这应该相对简单。
希望这会有所帮助!祝你好运:)