Reputation: 393
Woocommerce displays prices without tax added. There is an option to display prices with tax added, but only if you enter them with tax added in the backend.
This project requires showing the price including tax as well as the amount of tax on product category and single pages. The price and tax amount needs to be updated when product variants are selected. It also needs to pull the tax value from the system dynamically, so that when the tax rate is updated in the backend the frontend reflects the change.
<?php
/**
* Single Product Price, including microdata for SEO
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 1.6.4
*/
global $post, $product;
?>
<div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<p itemprop="price" class="price"><?php echo $product->get_price_html(); ?></p>
<?php
$price = $product->get_price();
$vat = number_format( $product->get_price()*0.20, 2, '.', ',');
$pricePlusVat = number_format( $price + $vat, 2, '.', ',');
?>
<p class="rrp"><?php echo $rrp; ?></p>
<p itemprop="price" class="price">
<span class="price-label">Our Price:</span>
<span class="full-price">£<?php echo $pricePlusVat; ?></span>
<br/>
<span class="vat-label">inc. VAT 20% ( £<?php echo $vat; ?> )</span>
</p>
<link itemprop="availability" href="http://schema.org/<?php echo $product->is_in_stock() ? 'InStock' : 'OutOfStock'; ?>" />
</div>
Upvotes: 2
Views: 7302
Reputation: 393
This question was asked a good while ago. This is now actually possible in Woocommerce without an extension, thought the extension given by raison could well be useful in some instances.
Assuming your store is setup to show prices ex vat you can show the price inc vat as wellby using the following.
You need to copy template files from the woocommerce plugin directory to your theme directory.
so for single product page theme/woocommerce/single-peoduct/price.php
<p class="price-incvat"> <?php echo woocommerce_price($product->get_price_including_tax()); ?> Inc VAT</p>
for the loop, eg product categories theme/woocommerce/loop/price.php
<span class="price-incvat"> <?php echo woocommerce_price($product->get_price_including_tax()); ?> Inc VAT</span>
for the cart page theme/woocommerce/cart/cart.php
<?php $row_price_incvat = $_product->get_price_including_tax( $cart_item['quantity'] ); ?>
<span class="price-incvat"> <?php echo wc_price( $row_price_incvat ); ?> Inc VAT</span>
for the checkout page theme/woocommerce/checkout/review-order.php
<?php $row_price_incvat = $_product->get_price_including_tax( $cart_item['quantity'] ); ?>
<span class="price-incvat"> <?php echo wc_price( $row_price_incvat ); ?> Inc VAT</span>
Upvotes: 1
Reputation: 2101
This extension should do the trick: http://codecanyon.net/item/woocommerce-tax-toggle/7796887
Upvotes: 0