Skip to content
Advertisement

Displayed WooCommerce product prices with or without taxes for specific user roles

I have this code which shows prices with Taxes Included for the ‘customer’ user role and prices with Taxes Excluded for ‘customer_2’ user role.

It works great for “Simple Products”. But it does not work at all for “Variable Products”. What is the change I need to do to this code to make sure it will works for both types of products (simple and variable)

JavaScript

Advertisement

Answer

Your code is a bit outdated since WooCommerce 3… The code handle handle simple products, variable products and products variations prices. There is 2 cases:

1). Displayed prices excluding taxes for specific user roles:

Your Woocommerce setting for “Display prices in the shop” is “Including taxes”.

JavaScript

2). Displayed prices including taxes for specific user roles:

Your Woocommerce setting for “Display prices in the shop” is “Excluding taxes”.

JavaScript

Code goes in functions.php file of your active child theme (or active theme). Tested and works.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement