• Resolved MauroF3rra

    (@maurof3rra)


    Hello,

    On my e-shop i have two type of users: Private and Wholesaler
    I managed to remove the vat on checkout for the Wholesaler category using this code

    function wc_diff_rate_for_user( $tax_class, $product ) {
    if ( is_user_logged_in() && current_user_can( ‘wholesaler’ ) ) {
    $tax_class = ‘Zero Rate’;
    }
    return $tax_class;
    }
    add_filter( ‘woocommerce_product_tax_class’, ‘wc_diff_rate_for_user’, 1, 2 );

    And this works correctly.

    But on the product page the price is shown including the VAT even if the user is a wholesaler, and that’s bad.

    How can I remove the VAT also in the product page ONLY for the Wholesaler role??

    Thank you so much

    https://www.ads-software.com/plugins/woocommerce/

Viewing 15 replies - 1 through 15 (of 17 total)
  • jessepearson

    (@jessepearson)

    Automattic Happiness Engineer

    Hi @maurof3rra,

    The code you have should work, I just tested it with these settings and a logged in user. The tax was not displayed on the product page, nor in the cart page.

    If your settings are different, please let me know which so I can update and test again.

    Thread Starter MauroF3rra

    (@maurof3rra)

    Hi @jesse Pearson

    Thank you for the reply,
    My settings are the same of you, except for the field “Display Prices during Cart and Checkout” which i’ve set to Including Tax.
    I’ve also tried with your settings but it doesn’t changes.

    My problem is not on the checkout, there it works correctly.
    Only on the product page the prices are shown always including the VAT

    jessepearson

    (@jessepearson)

    Automattic Happiness Engineer

    How are you creating and setting the additional user type of ‘wholesaler’?

    Thread Starter MauroF3rra

    (@maurof3rra)

    I created it with the plugin WPFront User Role Editor

    jessepearson

    (@jessepearson)

    Automattic Happiness Engineer

    I used the plugin to create the role, added the role to a user, then copied and pasted your code into my functions.php file. When viewing a product under that user, no tax is applied.

    Do you have the code in functions.php or somewhere else?

    Thread Starter MauroF3rra

    (@maurof3rra)

    Yes, the code is in my theme’s functions.php
    But I think there’s something strange happening. In my product section, some product are shown with VAT and some product not, but the settings for that product are the same!

    jessepearson

    (@jessepearson)

    Automattic Happiness Engineer

    Can you give me an example link to look at?

    Thread Starter MauroF3rra

    (@maurof3rra)

    Sure, what do you need? A link to two product for example?

    jessepearson

    (@jessepearson)

    Automattic Happiness Engineer

    That would help.

    To be honest, though, without being able to see the settings and possibly test, it makes it hard to debug. Do you have a testing environment? If not, I can create an account on my VPS for you to set one up.

    Thread Starter MauroF3rra

    (@maurof3rra)

    Sorry I don’t have a test environment…
    Maybe I can create you an admin account for my site?

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    To be honest, though, without being able to see the settings and possibly test, it makes it hard to debug. Do you have a testing environment? If not, I can create an account on my VPS for you to set one up.

    @maurof3rra @jessepearson Please do not ever ask for or offer log in credentials for any site in these forums. That includes test sites.

    https://codex.www.ads-software.com/Forum_Welcome#The_Bad_Stuff

    It’s good that MauroF3rra is seeking help but these forums are not for that. There are a lot of ways to get the information needed; getting login access isn’t permitted here.

    NOTE: I’m not accusing anyone of any ill will. Honest. But these forums need to be a safe place for experienced and new users and asking for or giving that level of access isn’t it.

    If someone needs that level of support then they may want to consider hiring someone.

    Thread Starter MauroF3rra

    (@maurof3rra)

    Oh ok, sorry Jan.

    jessepearson

    (@jessepearson)

    Automattic Happiness Engineer

    @jdembowski Understandable, and definitely no ill will here. Do you mind if I contact you with some questions via your contact form? I just don’t see a reason to do the back and forth here.

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    The best place really is to ping the #forums Slack channel. Today I’m (mostly) online but that channel is almost always has a forum moderator or two there.

    https://wordpress.slack.com/messages/forums/

    You’ll need to setup a slack account but that’s not difficult.

    Slack

    The reason I suggest Slack is that a) it’s public and b) that’s why the Support Team has that channel. ??

    jessepearson

    (@jessepearson)

    Automattic Happiness Engineer

    Thanks, will do.

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Showing prices without VAT based on roles’ is closed to new replies.