In WooCommerce is possible to display only price including tax or excluding tax in products loop and in single product page. Also if one product is on sale, Woocommerce display regular price like crossed out price and sale price. This is by default.
I found many working snippet to customized price for my needs, but some override also what I like to preserve: for example, I loose regular price crossed out if sale price is defined.
I’m looking for a clear code that allow me to:
- Show both regular and sale price, for simple and variable products
- Show price with tax and without tax with additional custom text (incl. tax; excl. tax)
This for products loop and single product page as well.
Thanks for any suggestions.
2
Answers
I find a solution perfect to my needs. This code does what I asked for in my original request, like in Druvi answer (thanks Druvi).
Additionals features:
add custom text before sale price.
if the product has a "noleggio" (rental) tag it shows custom text, if it has a "vendita" (purchase) tag it shows other text.
if the product on sale has date sale from/to, it shows the expiration date in products loop and single product page.
Hope can help someone else.
Add text for regular price, sale price and for specific tags:
Add custom text with sale dates after sale price in Woocommerce Single product:
This code should be added to your theme’s functions.php file
And Display prices with and without tax along with custom text: