Support » Plugin: WooCommerce » Code Snippets not executing in Woo Product Page

  • Hi,
    I use this small code bellow to tax exempt certain user roles, changing Tax class to Zero Tax.
    It works beutifully in ALL pages, for simple products including Product Page, Cart and CheckOut Pages.
    However, for a variable product, it doesn’t run in the PRODUCT PAGE, for the VARIATION PRICE. Any clue? Tks 4 any help.

    /**
     * Apply a zero tax rate for 'role1' AND "role3" user roles.
     */
    function wc_diff_rate_for_user( $tax_class, $product ) {
    
      global $woocommerce;
         if( current_user_can('role1') || current_user_can('role3')) {
        $tax_class = 'Zero Tax';
      }
    
      return $tax_class;
    }
    add_filter( 'woocommerce_product_get_tax_class', 'wc_diff_rate_for_user', 1, 2 );
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.