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 or translate these, the easiest way is by going to B2BKing -> Settings -> Language and adjusting the following settings:

Set Suffix Programmatically #

Another option is to modify the suffix using code snippets. The two 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 allows you to show the suffix for some users but not for others. Here is an example of a code snippet that displays 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, possibly depending on their 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 code snippet below.

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