Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
WooCommerce Single Product Page Price Display Excl VAT per Role
/// Display Excluding VAT for role bedrijf on single product page
function edit_price_display() {
global $product;
if(is_singular('product') && is_user_logged_in() && current_user_can( 'bedrijf' )) {
$price = $product->price;
$price_excl_tax = $price + round($price / ( 21 / 100 ), 2);
$price_excl_tax = number_format($price_excl_tax, 2, ",", ".");
$price = number_format($price, 2, ",", ".");
$display_price = '<span class="price">';
$display_price .= '<span class="amount">€ ' . $price_excl_tax .'<small class="woocommerce-price-suffix"> excl BTW</small></span>';
$display_price .= '</span>';
} else {
echo $price;
}
}
add_filter('woocommerce_get_price_html', 'edit_price_display', 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.