Last active
February 26, 2020 02:38
-
-
Save jasperf/5d9876b8cda81d025c230f3e0acf8e37 to your computer and use it in GitHub Desktop.
WooCommerce Single Product Page Price Display Excl VAT per Role
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// 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