Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #340765

    Hi i’m still rocking enfold every day! :)

    i have a question… and sinds you guys know everything :) here is my question:

    I have build a woocommerce shop with enfold, and now we have come to a point that we would like to have wholesalers on the website.

    So we have normal custumers that need to see a price including TAX (btw here in in holland) and when a user signs in with the role “wholesale” needs to see the price exluding TAX. :)

    So a role based TAX. i have found some code on the internet but is is nog working. I am using the plugin WooCommerce Prices By User Role to created custom roles and be able to set prices per product or a discount per catagory.

    so almighty enfold users :D are you up to it ;)

    http://www.ledfinity.nl/home

    #341637

    Hi c3computers!

    You can try addin following code to Functions.php file in Appearance > Editor

    add_filter('woocommerce_get_price', 'custom_wholesaler_price', 10, 2);
    function custom_wholesaler_price($price, $product) {
        if ( $current_user->ID) {
        $user_roles = $current_user->roles;
        $user_role = array_shift($user_roles);
        if ($user_role == 'wholesale') {
                $price = $_product->get_price_excluding_tax();
            }
        }
    else {
        return $price;
    }
    }
    

    Please note that i have not tested the code, it may or may not work. In that case, please try to use a plugin like this one – http://codecanyon.net/item/woocommerce-prices-by-user-role/8562616

    Best regards,
    Yigit

    #359680

    Hi!

    Ive tried. but i did not get it to work for me.

    I am already using the plugin that you sugested to create custom roles and set per product prices for the created roles.

    But the shop still shows all the prices including tax. Ive managed to show the incl and excl tax prices at the shop now trougt a php edit.
    (check the shop @ http://www.ledfinity.nl)

    #359689

    But i want to show only one price per user role :)

    #359697

    Hi!

    Have you tried contacting Woo team? :)

    Best regards,
    Yigit

    #659402

    Hey

    I’m looking for the same trick and I found this

    it works for me

    /**
     * Apply a different tax rate based on the user role.
     */
    function wc_diff_rate_for_user( $tax_class, $product ) {
    	if ( is_user_logged_in() && current_user_can( 'administrator' ) ) {
    		$tax_class = 'Zero Rate';
    	}
    	return $tax_class;
    }
    add_filter( 'woocommerce_product_tax_class', 'wc_diff_rate_for_user', 1, 2 );

    => Woo Page

    #659784

    Hi,

    Great, thanks for sharing @Veesibility :-)

    Regards,
    Rikard

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.