WooCommerce remove tax for user

Today we talk about how in WooCommerce remove tax for user. We will remove the tax on basis of the user id or user groups. Now, let’s start with our example.

add_filter( 'wc_tax_enabled',  'custom_enable_tax' , 1, 2 );
function custom_enable_tax(){
   $user = wp_get_current_user(); //get current user
   if( '20' == $user->ID ){
      return false;//remove tax for current user on basis of id
   }
   if( 'customer' == $user->roles[0] ){
     return false; //remove tax for current user on basis of user group
   }
  return true,
}

Qaisar Satti

Hi, I'm Qaisar Satti! I've been a developer for over 20 years, and now I love sharing what I've learned through tutorials and guides. Whether you're working with Magento, PrestaShop, or WooCommerce, my goal is to make your development journey a bit easier and more fun. When I'm not coding or writing, you can find me exploring new tech trends and hanging out with the amazing developer community. Thanks for stopping by, and happy coding!

Leave a Reply