[英]Send "on hold" email on custom order status change in WooCommerce
I've created a custom status in Woocommerce Order Page.我在 Woocommerce 订单页面创建了自定义状态。 It seems work.似乎工作。 So I was trying to send the same email of On Hold status, when my custom status is selected like this:所以我试图发送相同的 email 暂停状态,当我的自定义状态被这样选择时:
add_filter( 'woocommerce_email_actions', 'filter_woocommerce_email_actions' );
function filter_woocommerce_email_actions( $actions ){
$actions[] = 'woocommerce_order_status_wc-attesa-pagamento';
return $actions;
}
add_action( 'woocommerce_order_status_wc-attesa-pagamento', 'enable_processing_to_on_hold_notification', 10, 2 );
function enable_processing_to_on_hold_notification( $order_id, $order ){
// Getting all WC_emails array objects
$mailer = WC()->mailer()->get_emails();
// Send the "On Hold" notification
$mailer['WC_Email_Customer_On_Hold_Order']->trigger( $order_id );
}
add_action( 'woocommerce_order_status_wc-attesa-pagamento', array( WC(), 'send_transactional_email' ), 10, 1 );
But nothing happen?但是什么都没发生? Anyone can help me?任何人都可以帮助我吗?
There is a mistake in your code, you need to replace this line:您的代码中有错误,您需要替换此行:
add_action( 'woocommerce_order_status_wc-attesa-pagamento', 'enable_processing_to_on_hold_notification', 10, 2 );
with this:有了这个:
add_action( 'woocommerce_order_status_attesa-pagamento', 'enable_processing_to_on_hold_notification', 10, 2 );
and it should works.它应该有效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.