在Woocommerce管理员电子邮件通知中显示购买说明



我正在使用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 );

这非常适合客户收到的电子邮件,但我也希望它在管理员收到的"新订单"电子邮件中显示注释。

它们都使用相同的订单表,所以我不确定为什么它不起作用。

我没有找到wc_get_email_order_items的钩子,而是一个带有其他钩子的函数。请尝试:

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;
} 

代码进入函数.php活动子主题(或活动主题(的文件。它应该有效。

最新更新