我已成功更改 Woocommerce 处理订单的电子邮件主题(using 这个线程 https://stackoverflow.com/a/48880997/3730754):
add_filter( 'woocommerce_email_subject_customer_processing_order', 'email_subject_procs_order', 10, 2 );
function email_subject_procs_order( $formated_subject, $order ){
return sprintf( esc_html__( 'Example of subject #%s', 'textdomain'), $order->get_id() );
}
但我想在订单状态更改后再次发送带有新主题的处理订单电子邮件,所以我遵循这个踏板 https://stackoverflow.com/questions/48616541/add-custom-order-status-and-send-email-on-status-change-in-woocommerce调整主题等
add_action('woocommerce_order_status_order-accepted', 'backorder_status_custom_notification', 20, 2);
function backorder_status_custom_notification( $order_id, $order ) {
// HERE below your settings
$heading = __('Your Awaiting delivery order','woocommerce');
$subject = sprintf( esc_html__( 'New subject #%s', 'textdomain'), $order->get_id() );
// Getting all WC_emails objects
$mailer = WC()->mailer()->get_emails();
// Customizing Heading and subject In the WC_email processing Order object
$mailer['WC_Email_Customer_Processing_Order']->heading = $heading;
$mailer['WC_Email_Customer_Processing_Order']->settings['heading'] = $heading;
$mailer['WC_Email_Customer_Processing_Order']->subject = $subject;
$mailer['WC_Email_Customer_Processing_Order']->settings['subject'] = $subject;
// Sending the customized email
$mailer['WC_Email_Customer_Processing_Order']->trigger( $order_id );
}
但仅接受第一封电子邮件主题更改。有办法让它一起工作吗?
Is if( $order->has_status( 'order-accepted' ))
有权使用吗?