我在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文件中。它应该工作。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句