問題描述
我正在使用 WooCommerce for WordPress,我列出的商品不含稅.
I am using WooCommerce for WordPress and I'm listing items excluding Tax.
我需要單獨顯示價格(不含稅)、稅和價格+稅在產(chǎn)品頁面(如結(jié)帳頁面).
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 版開始,函數(shù) woocommerce_price() 已棄用,方法 get_price_include_tax() 也是如此.相反,您應(yīng)該使用 wc_get_price_including_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 模板覆蓋系統(tǒng)將其復(fù)制到您的主題中.如需這方面的幫助,請參閱有關(guān)使用模板覆蓋系統(tǒng)的 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
模板應(yīng)該位于 wp-content/themes/[您的主題文件夾]/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
這篇關(guān)于顯示含稅和不含稅的 Woocommerce 產(chǎn)品價格和稅額的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!