向 WooCommerce 处理订单的更多收件人发送客户发票电子邮件
Send customer invoice email with more recipients for WooCommerce processing orders
在 woocommerce 感谢页面上,如果订单状态正在处理中,我想发送 WC_Email_Customer_Invoice 电子邮件到多个电子邮件地址。
add_action( 'woocommerce_thankyou', 'dvs_add_more_recipient' );
function dvs_add_more_recipient($order_id) {
$order = new WC_Order($order_id);
if( ! $order->has_status( 'processing' ) ) return;
$wc_email = WC()->mailer()->get_emails()['WC_Email_Customer_Invoice'];
$wc_email->settings['recipient'] .= ',prohostreview@gmail.com';
$wc_email->trigger( $order_id );
}
但问题是电子邮件只发送到客户的电子邮件地址,没有电子邮件发送到 prohostreview@gmail.com。我正在使用最新的 WordPress 和 woo-commerce 插件。
请告诉我这里做错了什么。
此致。
从 WooCommerce 3.7 开始,您可以改用以下内容:
// Trigger email customer invoice for processing orders
add_action( 'woocommerce_order_status_processing', 'send_wc_email_customer_invoice', 10, 2 );
function send_wc_email_customer_invoice( $order_id, $order ) {
WC()->mailer()->get_emails()['WC_Email_Customer_Invoice']->trigger( $order_id );
}
// Add recipient to customer invoice for processing orders
add_filter( 'woocommerce_email_recipient_customer_invoice', 'add_recipient_processing_email_customer_invoice', 10, 2 );
function add_recipient_processing_email_customer_invoice( $recipient, $order = false ) {
if ( ! $order || ! is_a( $order, 'WC_Order' ) )
return $recipient;
if ( $order->get_status() === 'processing' ) {
$recipient .= ',prohostreview@gmail.com';
}
return $recipient;
}
代码进入活动子主题(或活动主题)的 functions.php 文件。它应该可以工作。
相关:
在 woocommerce 感谢页面上,如果订单状态正在处理中,我想发送 WC_Email_Customer_Invoice 电子邮件到多个电子邮件地址。
add_action( 'woocommerce_thankyou', 'dvs_add_more_recipient' );
function dvs_add_more_recipient($order_id) {
$order = new WC_Order($order_id);
if( ! $order->has_status( 'processing' ) ) return;
$wc_email = WC()->mailer()->get_emails()['WC_Email_Customer_Invoice'];
$wc_email->settings['recipient'] .= ',prohostreview@gmail.com';
$wc_email->trigger( $order_id );
}
但问题是电子邮件只发送到客户的电子邮件地址,没有电子邮件发送到 prohostreview@gmail.com。我正在使用最新的 WordPress 和 woo-commerce 插件。
请告诉我这里做错了什么。
此致。
从 WooCommerce 3.7 开始,您可以改用以下内容:
// Trigger email customer invoice for processing orders
add_action( 'woocommerce_order_status_processing', 'send_wc_email_customer_invoice', 10, 2 );
function send_wc_email_customer_invoice( $order_id, $order ) {
WC()->mailer()->get_emails()['WC_Email_Customer_Invoice']->trigger( $order_id );
}
// Add recipient to customer invoice for processing orders
add_filter( 'woocommerce_email_recipient_customer_invoice', 'add_recipient_processing_email_customer_invoice', 10, 2 );
function add_recipient_processing_email_customer_invoice( $recipient, $order = false ) {
if ( ! $order || ! is_a( $order, 'WC_Order' ) )
return $recipient;
if ( $order->get_status() === 'processing' ) {
$recipient .= ',prohostreview@gmail.com';
}
return $recipient;
}
代码进入活动子主题(或活动主题)的 functions.php 文件。它应该可以工作。
相关: