0
votes

I am using woocoommerce V3.0.9, and have tax settings enabled. I set Prices entered with tax as Yes, I will enter prices inclusive of tax and Display prices in the shop as Including Tax and Additional tax classes as Reduced Rate Zero Rate.

Also, while adding product i added product prices including tax. But on product detail page the prices are showing without tax. For example i added product price 135.90 while adding product including Tax and on product detail page its showing me price 123.55 excluding Tax but it should show 135.90 as i have set the setting to show prices including tax.

On checkout page, i am getting product price 123.55 + 12.35 Tax = 135.90 as product total price which is working fine.

But i want to show the actual price including tax on product detail page so that customer knows the original price before adding product to cart.

Can anyone help me how i can get this working.

Thanks in advance.

1
I checked system status and there is no issue with it.dev tester

1 Answers

0
votes

Before check that your WooCommerce Tax general settings match with your needs.

As 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 price.php just after:

global $product;

Replace the code with:

?>
<div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<?php
    $simple_product_price = $product->get_price_html(); // price without VAT
    $simple_product_total = $product->get_price_including_tax();  // price with included VAT
    $simple_product_vat = $simple_product_total - $simple_product_price; // VAT price amount
?>
    <p class="price"><?php echo $simple_product_price; /* without VAT */ ?></p> (formatted)
    <p class="price-vat"><?php echo $simple_product_vat; /* VAT */ ?></p>
    <p class="price-and-vat"><?php echo $simple_product_total; /* 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.

Woocommerce Reference Link: https://docs.woocommerce.com/wc-apidocs/class-WC_Product.html