How to control price suffix for B2B users / VAT exempt users

B2BKing can directly set the price suffix based on the user's VAT-exempt status. This is controlled through the setting in B2BKing -> Settings -> Other -> Modify VAT suffix automatically

Please note that for this to work, you must have already configured a tax exemption.

How to change price suffixes #

By default the plugin uses 'ex. VAT' and 'inc. VAT' as suffixes. If you would like to change / translate this, the easiest way is by going to B2BKing -> Settings -> Language, through the following settings:

Set suffix programmatically #

Another option is to modify the suffix by using code snippets. The 2 filter hooks that can be used are b2bking_price_suffix_ex_vat and b2bking_price_suffix_inc_vat.

Code example

add_filter('b2bking_price_suffix_inc_vat', function($val){
	return 'including VAT';
}, 10, 1);
add_filter('b2bking_price_suffix_ex_vat', function($val){
	return 'excluding VAT';
}, 10, 1);

Another filter you can use is "apply_filters('b2bking_modify_suffix', true, $user_id)". This can allow you to show the suffix for some users, but not for others. Here is an example of a code snippet to make it show the suffix only to logged in users (but not to logged out users).

add_filter('b2bking_modify_suffix', function($val, $user_id){
	if ($user_id === 0){
		return false;
	}
	return $val;
}, 10, 2);

Additional Info #

Some WooCommerce themes, and possibly depending on settings, will automatically add "inc. VAT" and "excl. VAT" suffixes to prices based on the user's VAT exempt status. In this case, you can simply disable B2BKing's "Modify VAT suffix automatically" setting.

If you want to control the suffix in more detail, such as based on B2BKing B2B groups, you can disable that setting and use the below code snippet.

The code sets the suffix to "excl. VAT" for B2B users and "incl. VAT" for B2C users:

// get if user is b2b
$user_is_b2b = get_user_meta(get_current_user_id(),'b2bking_b2buser', true);

if ($user_is_b2b === 'yes'){
	add_filter( 'woocommerce_get_price_suffix', 'add_price_suffix', 99, 4 );
	  
	function add_price_suffix( $html, $product, $price, $qty ){
	    $html = '<small class="woocommerce-price-suffix"> excl. VAT</small>';
	    return $html;
	}
} else {
	add_filter( 'woocommerce_get_price_suffix', 'add_price_suffixtwo', 99, 4 );
	  
	function add_price_suffixtwo( $html, $product, $price, $qty ){
	    $html = '<small class="woocommerce-price-suffix"> incl. VAT</small>';
	    return $html;
	}
}

Powered by BetterDocs