当订单状态从待定变为取消时,我使用以下代码发送管理员电子邮件。
add_action('woocommerce_order_status_pending_to_cancelled', 'cancelled_send_an_email_notification', 10, 2 );
function cancelled_send_an_email_notification( $order_id, $order ){
// Getting all WC_emails objects
$email_notifications = WC()->mailer()->get_emails();
// Sending the email
$email_notifications['WC_Email_Cancelled_Order']->trigger( $order_id );
}
现在,每当订单停留在“待付款”状态时,我都希望实现同样的效果。
有人有解决这个问题的方法吗?
由于每个创建的订单都会获得初始待处理状态,为了避免收到所有订单的通知,您可以使用以下方法,该方法将向管理员发送每日自定义电子邮件通知,其中包含待处理订单的链接列表(如果有):
未经测试,它可以工作。
注意:列出的订单至少是 1 天前的,以避免列出 WooCommerce 正在处理的订单。例如,您可以通过将“-1 天”更改为“-3 小时”来进行微调。
这里,每个订单的链接都将转到管理员编辑订单以启用高性能订单存储。如果不是这种情况,您将不得不调整
admin_url()
函数内的字符串。