Price

<?php 

// bomendael
add_filter( 'woocommerce_format_price_range', function($price, $from, $to) {
  if(is_admin()) {
    return sprintf( _x( '%1$s &ndash; %2$s', 'Price range: from-to', 'woocommerce' ), is_numeric( $from ) ? wc_price( $from ) : $from, is_numeric( $to ) ? wc_price( $to ) : $to );
  }
  return '<span class="price_label">Vanaf</span>'.sprintf( _x( '%1$s', 'Price range: from-to', 'woocommerce' ), is_numeric( $from ) ? wc_price( $from ) : $from, is_numeric( $to ) ? wc_price( $to ) : $to );
}, 99, 4 );

add_filter('formatted_woocommerce_price', function($number_format, $price, $decimals, $decimal_separator, $thousand_separator) {
  // preg_replace used from `wc_trim_zeros`
  if(is_admin()) {
    return $number_format;
  }
  return preg_replace( '/' . preg_quote( wc_get_price_decimal_separator(), '/' ) . '0++$/', ',-', $number_format );
}, 10, 5);

add_filter('woocommerce_currency_symbol', function($currency_symbol, $currency) {
  // return $currency_symbol;
  if(is_admin()) {
    return $currency_symbol;
  }
  return '';
}, 10, 2);

function price_html_with_tax($product, $price, $checkSale, $salePrice, $prefix = false) {
  $price_incl_tax = $price + round($price * ( 21 / 100 ), 2);
  $display_price = $prefix . 
    ($product->is_on_sale() && $checkSale ? '<del>'.wc_price(round($salePrice * 1.21, 2)).'</del>' : '') . wc_price($price_incl_tax). 
    ' <small class="woocommerce-price-suffix">Incl. BTW</small>';
  $display_price .= '<br>';
  $display_price .= $prefix .
    ($product->is_on_sale() && $checkSale ? '<del>'.wc_price($salePrice).'</del>' : '') . wc_price($price) .
    ' <small class="woocommerce-price-suffix">Excl. BTW</small>';
  return $display_price;
}

// Replace default price_html with custom ex+inc vat
add_filter('woocommerce_get_price_html', function($price, $product) {
	if($product->is_type('simple') && !is_admin()) {
		$price = wc_get_price_to_display( $product );
		$price = price_html_with_tax($product, $price, true, $product->get_regular_price());
  }
  if($product->is_type('variable') && !is_admin()) {
    $prices = $product->get_variation_prices( true );
    if ( !empty( $prices['price'] ) ) {
			$min_price     = current( $prices['price'] );
			$min_reg_price = current( $prices['regular_price'] );
			$max_reg_price = end( $prices['regular_price'] );
			$price = price_html_with_tax($product, $min_price, $min_reg_price === $max_reg_price, $min_reg_price, 'v.a.');
    }
	}
	return $price;
}, 10, 2);
Last Updated:
Contributors: Niek Vlam, Suite Seven