javascript WooCommerce - 在产品页面上显示不含税的价格
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10314194/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
WooCommerce - Display Price Without Tax on Product Page
提问by Sativa Diva
I am using WooCommerce & WooShop Theme for Wordpress.
我正在为 Wordpress 使用 WooCommerce 和 WooShop 主题。
I need to display the Product Price EXCLUDING tax on Single Product Page.
我需要在单个产品页面上显示产品价格不含税。
There are 2 functions if I understand correctly:
如果我理解正确的话,有两个功能:
$_product->get_price()
$_product->get_price_excluding_tax()
$_product->get_price()
$_product->get_price_without_tax()
and this is Price.php(Under Single Product)
这是Price.php(在单一产品下)
<p itemprop="price" class="price"><?php echo $product->get_price_html(); ?></p>
which leads to
这导致
'price_html' => '<span class="price">'.$variation->get_price_html().'</span>',
Any ideas?
有任何想法吗?
THANKS!
谢谢!
回答by Michael Giovanni Pumo
I know this question is old, but here's a go for anyone else looking for an answer to using those functions in the proper way.
我知道这个问题很老了,但这里有其他人正在寻找以正确方式使用这些功能的答案的机会。
I found that when I used $_product->get_price_excluding_tax()
it would return the full price.
我发现当我使用$_product->get_price_excluding_tax()
它时会返回全价。
However, after adjusting a setting in WooCommerce, it now appears correctly.
但是,在 WooCommerce 中调整设置后,它现在可以正确显示。
You should tick the box the says "Catalog prices defined including tax".
您应该勾选“已定义的目录价格含税”框。
You also need to make sure that you have a tax rule setup in the 'Tax' tab. I setup one for UK VAT at 20%.
您还需要确保在“税收”选项卡中设置了税收规则。我为英国增值税设置了一个 20%。
Hope that this helps somebody in future.
希望这对将来的人有所帮助。
Thanks, Mikey.
谢谢,米奇。