Home / eCommerce / Customize the WooCommerce Email Template Subject for Wholesale Customers
Duplicate Snippet

Embed Snippet on Your Site

Customize the WooCommerce Email Template Subject for Wholesale Customers

Code Preview
php
<?php
/**
 * Customize the Subject for wholesalers
 */
add_filter( 'woocommerce_email_subject_customer_completed_order', function( $subject, $order ) {
    if ( ! $order ) return $subject;
    $customer_id = $order->get_customer_id();
    if ( ! $customer_id ) return $subject;
    $wholesale_roles = [ 'wholesale_customer', 'wholesale_vip' ];
    $user = get_userdata( $customer_id );
    if ( $user && array_intersect( $wholesale_roles, (array) $user->roles ) ) {
        // We use get_bloginfo('name') instead of {site_title}
        return 'Your wholesale order with ' . get_bloginfo( 'name' ) . ' is complete';
    }
    return $subject;
}, 10, 2 );

Comments

Add a Comment