Different tax according to the User Role (Code)
-
Hello everyone
In my online store there are three types of users and I need to show the tax according to the User Role. All users have the same tax, 21% VAT.
Users “customer” and “guest”
Show the prices of the products with the tax included.“Partner” users
Show the prices of the products without the tax. The tax must appear separately.After trying several plugins I found in this forum the help of a code that can solve the problem but strangely adds a few lines of text that I do not understand.
Code:
`add_filter(‘pre_option_woocommerce_tax_display_shop’, ‘alter_tax_display’);
add_filter(‘pre_option_woocommerce_tax_display_cart’, ‘alter_tax_display’);function alter_tax_display( $tax_display ) {
if (current_user_can(“mayorista”)){
return “excl”;
} else {
return “incl”;
}
}add_filter( ‘woocommerce_get_price_suffix’, ‘wc_get_price_suffix_filter’, 10, 2 );
function wc_get_price_suffix_filter( $price_display_suffix, $item, $cart ) {
// check for the user role return blank if it matches
if (current_user_can(“mayorista”))
$price_display_suffix = ‘<span class=”sufijomayoristas”>(+ IVA)</span>’;return $price_display_suffix;
}Text lines after applying the code:
https://vegan-tattoo.com/wp-content/uploads/02-a.jpgWarnings:
I am using the “WooCommerce Dynamic Pricing” plugin to configure different prices according to User Roles. As can be seen in the image, the product has a different price according to the User Role.Please, any help would be fantastic.
Thanks in advanceThe page I need help with: [log in to see the link]
- The topic ‘Different tax according to the User Role (Code)’ is closed to new replies.