【发布时间】:2018-08-02 08:35:08
【问题描述】:
我已成功更改 Woocommerce 处理订单的电子邮件主题(使用 this thread):
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() );
}
但我想在订单状态更改后再次发送带有新主题的处理订单电子邮件,所以我跟随this tread调整主题等。
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 );
}
但仅接受第一封电子邮件主题更改。有没有办法让它一起工作? if( $order->has_status( 'order-accepted' ))可以使用吗?
【问题讨论】:
标签: php woocommerce orders email-notifications subject