Display customer group in user area


Thursday, 07 May 2020

This feature is now integrated since version 3.0.2

One of WooCommerce B2B best features is to create groups and assign them to customers, to apply different prices, minimum purchase amount, products category visibility, shipping and payment methods and so on.
If you need to show assigned group in customer my account area, edit functions.php file that you find in your site’s FTP space in:


and insert this code:

add_action( 'woocommerce_account_navigation', function() {
    if ( ! in_array( 'customer', get_userdata( get_current_user_id() )->roles ) ) { return; }
    if ( $wcb2b_user_group = get_the_author_meta( 'wcb2b_group', get_current_user_id() ) ) {
    	$wcb2b_group_name = get_the_title( $wcb2b_user_group );
        echo '<div class="wcb2b-customer-group">'.sprintf( __( 'Your group: %s' ), $wcb2b_group_name ).'</div>';
} );
WARNING! Before making any changes, make sure you have made a complete backup of site files and database.
It is advisable not to edit the theme files directly, but to use a child theme.
For more information on child themes, please read: WordPress Official guide on Child Themes