prices in my shop are displayed with tax and also I'm using {price_excluding_tax} suffix to display also price excluding tax. But there is a problem with variable products... The shop shows only prices including tax (and the old price in case of promotion) but it doesn't shows the price excluding tax. Prices for both variable products are the same. I tried to use this code:
https://tomjesch.com/display-woocommerce-products-with-and-without-tax/
But it doesn't work properly - it shows prices, but does not react to any price change in the woocommerce admin panel. So, it works fine only when adding a new product.
Thanks in advance...
My code:
function edit_price_display() {
$product = WC_Product( get_the_ID() );
$regular_price = $product ->regular_price;
$price = $product->price;
$price_incl_tax = $price + round( $price * ( 23 / 100 ), 2 );
$price_incl_tax = number_format( $price_incl_tax, 2, ",", "" );
$price = number_format( $price, 2, ",", "" );
$display_price = '<ins><span class="woocommerce-Price-amount amount">';
$display_price .= ' '.$price_incl_tax .'<span class="woocommerce-Price-currencySymbol"> zł</span>';
$display_price .= '</span></ins> ';
$display_price .= '<small class="woocommerce-price-suffix">(netto: <span class="woocommerce-Price-amount amount">'.$price .' <span class="woocommerce-Price-currencySymbol">zł</span></span>)</small>';
$display_price .= '';
$display_regular_price ='<del><span class="woocommerce-Price-amount amount">'.$regular_price .'<span class="woocommerce-Price-currencySymbol"> zł</span></span></del>';
if($product->is_on_sale()) {
echo $display_regular_price;
}
echo $display_price;
}
add_filter('woocommerce_variable_price_html', 'edit_price_display');