显示含税和不含税和税额的Woocommerce产品价格 [英] Display Woocommerce product price with and without tax and tax amount
问题描述
我正在将WooCommerce用于WordPress,并且列出了不含税的商品.
I am using WooCommerce for WordPress and I'm listing items excluding Tax.
我需要在产品页面(如在结帐页面中)分别显示价格(不含税),税款和PRICE +税款.
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.
我该怎么做?
推荐答案
WooCommerce v3.0.0及更高版本
从WooCommerce 3.0版开始,函数 woocommerce_price()已弃用,方法 get_price_includes_tax()也已弃用.相反,您应该使用 wc_get_price_includes_tax :
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 ) ); ?>
WooCommerce v3.0.0之前的版本
您需要修改模板. 请勿使用WooCommerce模板覆盖系统修改核心WooCommerce模板,而是将其复制到您的主题.有关此方面的帮助,请参考WooCommerce文档,以使用模板替代系统.
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.
在price.php
模板中,您将在需要价格的位置添加以下代码,包括税金(VAT):
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() ); ?>
注意:您修改的price.php
模板应位于wp-content/themes/[your theme folder]/woocommerce/single-product/price.php
Note: the price.php
template that you modify should be located here in wp-content/themes/[your theme folder]/woocommerce/single-product/price.php
这篇关于显示含税和不含税和税额的Woocommerce产品价格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!