Show the tax line when rate is 0% in Woocommerce

有些话、适合烂在心里 提交于 2019-12-11 10:11:06

问题


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:

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

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.

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.?


回答1:


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.

And



来源:https://stackoverflow.com/questions/50231536/show-the-tax-line-when-rate-is-0-in-woocommerce

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!