Update 2018/2019 (for Woocommerce 3+)
To display price without tax + tax amount + price including tax (on separated lines):
First read "How to override Woocommerce templates via your theme"
1) On single-product/price.php
template file (single product pages).
Replace the code with:
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
global $product;
// Get the prices
$price_excl_tax = wc_get_price_excluding_tax( $product ); // price without VAT
$price_incl_tax = wc_get_price_including_tax( $product ); // price with VAT
$tax_amount = $price_incl_tax - $price_excl_tax; // VAT amount
// Display the prices
?>
<p class="price-excl"><?php echo wc_price( $price_excl_tax ); ?></p>
<p class="tax-price"><?php echo wc_price( $tax_amount ); ?></p>
<p class="price-incl"><?php echo wc_price( $price_incl_tax ); ?></p>
2) On loop/price.php
template file (Shop and archive pages).
Replace the code with:
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
global $product;
if ( $product->get_price_html() ) :
// Get the prices
$price_excl_tax = wc_get_price_excluding_tax( $product ); // price without VAT
$price_incl_tax = wc_get_price_including_tax( $product ); // price with VAT
$tax_amount = $price_incl_tax - $price_excl_tax; // VAT amount
// Display the prices
?>
<span class="price price-excl"><?php echo wc_price( $price_excl_tax ); ?></span><br>
<span class="price tax-price"><?php echo wc_price( $tax_amount ); ?></span><br>
<span class="price price-incl"><?php echo wc_price( $price_incl_tax ); ?></span>
<?php endif ?>
Documentation:
• Template structure and how to override Woocommerce templates via your theme
• wc_get_price_including_tax()
product price function
• wc_get_price_excluding_tax()
product price function
• wc_price()
formatting price function
• wc_get_price_to_display()
product price function
Original answer (before woocommerce 3):
Before check that your WooCommerce Tax general settings match with your needs.
As cale_b suggested, you need to copy from woocommerce the templates
folder inside your active child theme or theme. Then rename it woocommerce
. In this woocommerce
templates folder you will find inside single-product
subfolder the price.php template to edit related to pricing display in single product pages.
In single-product/price.php
template file just after global $product;
,
replace the code with:
?>
<div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<?php
$price_excl = $product->get_price_excluding_tax(); // price without VAT
$price_incl = $product->get_price_including_tax(); // price included VAT
$tax_amount = $price_incl - $price_excl; // VAT price amount
?>
<p class="price"><?php echo woocommerce_price( $price_excl ); /* without VAT */ ?></p> (formatted)
<p class="price-vat"><?php echo woocommerce_price( $tax_amount); /* VAT */ ?></p>
<p class="price-and-vat"><?php echo woocommerce_price( $price_incl); /* With VAT */ ?></p>
<meta itemprop="price" content="<?php echo esc_attr( $product->get_price() ); ?>" />
<meta itemprop="priceCurrency" content="<?php echo esc_attr( get_woocommerce_currency() ); ?>" />
<link itemprop="availability" href="http://schema.org/<?php echo $product->is_in_stock() ? 'InStock' : 'OutOfStock'; ?>" />
</div>
Because the additional prices are unformatted, you may need to mix some other elements with this additionals prices using some woocommerce php functions like:
get_price_suffix( ) // Get the suffix to display after prices > 0.
$currency = esc_attr( get_woocommerce_currency( ) ) // Get the currency code.
get_woocommerce_currency_symbol( $currency ) // Get the currency symbol.
get_tax_class( ) // Returns the tax class.
get_tax_status( ) // Returns the tax status.
Reference: WooCommerce WC_Product class