-
AuthorPosts
-
October 24, 2014 at 7:35 pm #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 ;)
October 27, 2014 at 6:06 pm #341637Hi 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,
YigitNovember 28, 2014 at 5:43 pm #359680Hi!
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)November 28, 2014 at 5:49 pm #359689But i want to show only one price per user role :)
November 28, 2014 at 6:06 pm #359697July 11, 2016 at 4:24 pm #659402Hey
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
July 12, 2016 at 12:25 pm #659784 -
AuthorPosts
- You must be logged in to reply to this topic.