Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display Woocommerce product price with and without tax and tax amount

I am using WooCommerce for WordPress and I'm listing items excluding Tax.

I need to show separately the Price (without tax), the Tax and the PRICE + Tax on the product page (like in checkout page).

I have not been able to find a plugin that does this.

How can I do this?

like image 535
Nuri Akman Avatar asked May 14 '16 14:05

Nuri Akman


People also ask

How do I display tax in WooCommerce?

Enabling Taxes To access the tax settings screens, they first need to be enabled. Go to: WooCommerce > Settings > General. Select the Enable Taxes and Tax Calculations checkbox. Save changes.

How do I show product price in WooCommerce?

Go to WooCommerce → Settings → Variation Prices and select the 'Custom' format for your variation prices. In the field that appears below, enter the required format for how you would like to display the variation prices.

How do I hide Taxes in WooCommerce?

Under the WooCommerce menu, go to Role Based pricing > Tax Options. Under the tax options you can see different user roles and the tax class associated to it, and also the tax type to show hide tax in shop/ cart page.


1 Answers

WooCommerce v3.0.0 and Later
As of WooCommerce version 3.0, the function woocommerce_price() is deprecated, as is the method get_price_including_tax(). Instead, you should use wc_get_price_including_tax:

<?php echo wc_price( wc_get_price_including_tax( $product ) ); ?>

Prior to WooCommerce v3.0.0
You need to modify a template. Do not modify the core WooCommerce template, but rather make a copy of it to your theme, using the WooCommerce template override system. For help with that, refer to the WooCommerce docs on using the template override system.

In the price.php template, you will add this bit of code where you want the price, including tax (VAT):

<?php echo woocommerce_price( $product->get_price_including_tax() ); ?>

Note: the price.php template that you modify should be located here in wp-content/themes/[your theme folder]/woocommerce/single-product/price.php

like image 91
random_user_name Avatar answered Oct 07 '22 12:10

random_user_name