我在Wooccommerce订单处理电子邮件中添加了一些文本,内容如下:
add_action(
'woocommerce_email_before_order_table',
'add_order_email_instructions',
0
);
function add_order_email_instructions( $order ) {
if ( 'paypal' == $order->payment_method ) {
echo 'my text:';
}
}
这是有效的,但我希望文本只在发送给客户的电子邮件中,而不是管理员。我需要补充什么?
传入两个args。
add_action(
'woocommerce_email_before_order_table',
'add_order_email_instructions',
0,2
);
第二个参数是您想要的条件。
function add_order_email_instructions( $order, $sent_to_admin ) {
if ( 'paypal' == $order->payment_method && !$sent_to_admin) {
echo 'my text:';
}
}
限制订单处理时的操作:
add_action('woocommerce_order_status_processing', 'scriptonomy_when_processing');
function scriptonomy_when_processing(){
add_action('woocommerce_email_before_order_table', 'add_order_email_instructions', 0,2);
}