How to send a different New Order email subject for Wholesale Orders

Table Of Contents

    By default, all of the new order emails will use the same email template for both retail and wholesale orders. Unfortunately, we don’t have the feature to override this yet.

    The workaround that we can do to distinguish the retail and wholesale order on the new order email is by adding the order type in the subject line. You can do this by adding the following snippet to your child theme’s function.php

    // Custom New Order Subject - Adding the Order Type in the Subject Line
    add_filter('woocommerce_email_subject_new_order', 'wwpp_change_email_subject', 1, 2);
    function wwpp_change_email_subject($subject, $order) {
        //getting the blogname scaping special chars for email
        $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
        $order_type = $order->get_meta('_wwpp_wholesale_order_type'); // The Order data
        // creating our new subject line
        $subject = sprintf('[%s] Order # %s - %s', $order_type, $order->get_id(), $blogname);
        // sending our custom subject back to WooCommerce
        return $subject;
    in WooCommerce Wholesale Prices Premium