Php 在Woocommerce管理员电子邮件通知中显示购买说明
我正在使用Php 在Woocommerce管理员电子邮件通知中显示购买说明,php,wordpress,woocommerce,orders,email-notifications,Php,Wordpress,Woocommerce,Orders,Email Notifications,我正在使用functions.php文件中的一个函数在Woocommerce客户电子邮件中显示产品的购买说明。看起来是这样的: function sww_add_note_woocommerce_emails( $output, $order ) { // set a flag so we don't recursively call this filter static $run = 0; // if we've already run this filter, b
functions.php
文件中的一个函数在Woocommerce客户电子邮件中显示产品的购买说明。看起来是这样的:
function sww_add_note_woocommerce_emails( $output, $order ) {
// set a flag so we don't recursively call this filter
static $run = 0;
// if we've already run this filter, bail out
if ( $run ) {
return $output;
}
$args = array(
'show_purchase_note' => true,
);
// increment our flag so we don't run again
$run++;
// if first run, give WooComm our updated table
return wc_get_email_order_items( $order, $args );
}
add_filter( 'wc_get_email_order_items', 'sww_add_note_woocommerce_emails', 10, 2 );
这非常适用于客户收到的电子邮件,但我也希望它显示管理员收到的“新订单”电子邮件中的注释
它们都使用同一个订单表,所以我不确定它为什么不工作。我没有找到一个钩子,而是找到了一个带有其他钩子的函数。请尝试:
add_filter( 'woocommerce_email_order_items_args', 'display_customer_note_in_all_emails', 10, 1 );
function display_customer_note_in_all_emails( $args ) {
$args['show_purchase_note'] = true;
return $args;
}
代码进入活动子主题(或活动主题)的function.php文件。它应该有效