在woocommerce管理设置面板中重命名电子邮件通知标题

时间:2018-11-05 15:34:19

标签: php wordpress woocommerce title email-notifications

一个简单的问题:如何在WooCommerce->电子邮件下重命名WooCommerce电子邮件模板名称?

enter image description here

例如:

Old:Neue Bestellung 新增:新标题

1 个答案:

答案 0 :(得分:2)

要重命名电子邮件通知标题,您将使用以下(由您自己替换)

add_filter( 'woocommerce_email_title', 'change_woocommerce_email_title', 10, 2 );
function change_woocommerce_email_title( $email_title, $email ){

    // Only on backend Woocommerce Settings "Emails" tab
    if( isset($_GET['page']) && $_GET['page'] == 'wc-settings' && isset($_GET['tab'])  && $_GET['tab'] == 'email' ) {

        $domain = "woocommerce"; // The text domain

        switch ($email->id) {

            case 'new_order':
                $email_title = __("New Order Email", $domain);
                break;

            case 'cancelled_order':
                $email_title = __("Cancelled Order Email", $domain);
                break;

            case 'failed_order':
                $email_title = __("Failed Order", $domain);
                break;

            case 'customer_on_hold_order':
                $email_title = __("Customer On Hold Order Email", $domain);
                break;

            case 'customer_processing_order':
                $email_title = __("Customer Processing Order Email", $domain);
                break;

            case 'customer_completed_order':
                $email_title = __("Customer Completed Order Email", $domain);
                break;

            case 'customer_refunded_order':
                $email_title = __("Customer Refunded Email", $domain);
                break;

            case 'customer_invoice':
                $email_title = __("Customer Invoice Email", $domain);
                break;

            case 'customer_note':
                $email_title = __("Customer note Email", $domain);
                break;

            case 'customer_reset_password':
                $email_title = __("Customer Reset Password Email", $domain);
                break;

            case 'customer_new_account':
                $email_title = __("Customer New Account Email", $domain);
                break;
        }
    }

    return $email_title;
}

代码进入您的活动子主题(活动主题)的function.php文件中。经过测试,可以正常工作。