[英]Add custom order status and send email on status change in Woocommerce
[英]Send "on hold" email on custom order status change in WooCommerce
我在 Woocommerce 订单页面创建了自定义状态。 似乎工作。 所以我试图发送相同的 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 );
但是什么都没发生? 任何人都可以帮助我吗?
您的代码中有错误,您需要替换此行:
add_action( 'woocommerce_order_status_wc-attesa-pagamento', 'enable_processing_to_on_hold_notification', 10, 2 );
有了这个:
add_action( 'woocommerce_order_status_attesa-pagamento', 'enable_processing_to_on_hold_notification', 10, 2 );
它应该有效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.