0

In our webshop we need to display prices without tax for companies, and with tax for persons. Both shall pay taxes, so we just need to change the view setting (woocommerce_tax_display_shop and woocommerce_tax_display_cart) based on user role (customer vs company).

We can't figure this out. Can anyone give us a hand?

Virik
  • 397
  • 1
  • 4
  • 18
  • have you check [this](http://stackoverflow.com/questions/39972780/disable-tax-programmatically-for-a-specific-user-role/39975559#39975559) and [this](http://stackoverflow.com/questions/17866674/role-based-taxes-in-woocommerce) and also [this](http://stackoverflow.com/questions/38894444/add-tax-free-fees-to-woocommerce-cart-programmatically/38902400#38902400) so questions, may be this can help you. – Raunak Gupta Mar 21 '17 at 07:33

1 Answers1

1

pre_option_ + your option will give you a name of the filter you can use to "temporarily alter a WordPress option before you display a specific view"

https://codex.wordpress.org/Plugin_API/Filter_Reference/pre_option_%28option_name%29

You will need to use the same for your cart option.

add_filter('pre_option_woocommerce_tax_display_shop', 'alter_tax_display');


function alter_tax_display( $tax_display ) {
    if (current_user_can("company")){
    return "excl";
  } else {
    return "incl";
}
tonino.j
  • 3,837
  • 28
  • 27
  • 1
    Hi. This didn't work. First of all there is no function called get_current_user_role(). And it didn't work with this either: in_array( 'company', (array) $user->roles) – Virik Mar 20 '17 at 21:06
  • I edited the answer, you can try and use current_user_can("company") if that is your role. – tonino.j Mar 20 '17 at 21:47