Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
969 views
in Technique[技术] by (71.8m points)

php - Show the tax line when rate is 0% in Woocommerce

I’m updating to the latest version of WooCommerce from a very old version. I have noticed that when using the option “Display tax totals: Itemized”, the Tax name is not displayed anymore in the Sub Total line included in Cart page, Checkout page and in any customer e-mail, invoice, etc.

The reason appears to be that if the Tax rate is set to 0.0000%, the new version of WooCommerce automatically hides that line after the Sub Total, look below:

No Tax Name

If I set rates to 1.0000% or whatever, it appears. This exactly the way I want things to be displayed, look below:

Tax Name displayed

The problem is that I need that information to be displayed, the VAT rates in my store are always 0% due to a VAT extemption regime (see screenshot), but depending on the customer country I need to write what Tax extemption is being used, and I’m using the Tax name for that.

My Tax rates right now

Any ideas to force the displaying of the Tax name even if the rate is set at 0.0000%?

If that is not possible, how can I create a shortcode with the Tax name so I can use it at least in my order invoice, emails, etc.?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The solution is very simple, just one line. It will display tax line, even if the tax rate is 0%. Try this:

add_filter( 'woocommerce_cart_hide_zero_taxes', '__return_false' ); 

And optionally for orders:

add_filter( 'woocommerce_order_hide_zero_taxes', '__return_false' );

Code goes in function.php file of your active child theme (or active theme). Tested and works.

enter image description here

And

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...