Skip to content
OSULZER.AT
Code2 min read· updated March 2, 2022

WooCommerce B2B Market: Disable Tax Calculation for Customer Groups

Without German Market, B2B Market charges tax at checkout even for B2B customers. This snippet exempts selected WooCommerce customer groups from tax.

Below you will find another handy snippet related to B2B Market. If you use the WooCommerce plugin B2B Market without German Market, it is not possible to validate the VAT ID automatically and then disable tax calculation during checkout. On request, the prices in the shop itself are displayed as net prices using B2B Market’s built-in features, but as soon as the checkout starts, taxes are calculated as usual. If you do not mind validating VAT ID numbers manually, you can use the following function to exempt selected customer groups from tax calculation.

As usual, you can add the code to your functions.php or activate it via a plugin such as “Snippets”. Simply fill the array $b2bRoles with the slugs of your B2B Market groups, nothing more is needed.

function osulzer_excempt_group_from_vat($post_data) {


    # enter the slugs of the b2b groups whose customers pay no taxes
    $b2bRoles = [
        'role_1',
        'role_2',
    ];

    $userdata = is_user_logged_in() ? get_userdata(get_current_user_id()) : false;

    if($userdata) {

        $isB2B = count(array_intersect($userdata->roles, $b2bRoles)) != 0;

        if($isB2B) {

            # set the user to tax exempt
            WC()->customer->set_is_vat_exempt( true );

        }

    }


}

add_action( 'woocommerce_checkout_update_order_review', 'osulzer_excempt_group_from_vat' );

I am happy to support you with building your B2B shop. Get in touch with your project in a non-binding initial consultation.

WooCommerce Development

Prefer to have it done for you?

Custom plugins, integrations, and B2B features for your shop - €120/h plus VAT.

See WooCommerce development

New project?

Contact.

Tell me briefly about your project - I'll get back to you personally.

Your data is used solely to handle your inquiry. More in the privacy policy.