[英]Display purchase note in Woocommerce admin 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, 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;
}
代码进入您的活动子主题(或活动主题)的function.php文件中。 它应该工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.