以下是我在订单状态变为“处理中”时向管理员发送通知电子邮件的代码:
add_action( 'woocommerce_checkout_order_processed', 'process_new_order_notification', 20, 1 );
function process_new_order_notification( $order_id ) {
// Get an instance of the WC_Order object
$order = wc_get_order( $order_id );
//Order status processing
if( ! $order->has_status( 'processing' ) ) return;
// Send "New Email" notification (to admin)
WC()->mailer()->get_emails()['WC_Email_New_Order']->trigger( $order_id );
}
但它不起作用,因为当订单状态变为处理中时,管理员不会收到任何电子邮件。我认为我的代码有问题。有什么帮助吗?
阿晨1998