最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - Show prices with tax in Woocommerce Mini Cart

programmeradmin0浏览0评论
Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 4 years ago.

Improve this question

I set up my tax configuration to show prices excluding tax in Cart and Checkout. However I noticed that the prices displayed in the Minicart widget also exclude tax.

So in mini-cart.php I modified the following filter:

$product_price = apply_filters( 'woocommerce_cart_item_price', WC()->cart->get_product_price( $_product ), $cart_item, $cart_item_key );

To:

$product_price = apply_filters( 'woocommerce_cart_item_price', wc_get_price_including_tax( $_product ), $cart_item, $cart_item_key );

In the filter I use wc_get_price_including_tax() to display the product price with tax.

The price in the Mini Cart now includes tax. However I’m not sure if it’s correct. What is the right way to do it?

Using that solution I have a few issues:

– For example the price is displayed 290.5, it should be 290.50$. How can I keep the two decimals and the currency symbol? (In the Woocommerce configuration the decimals are set to "2").

– Last question, how can I display the subtotal with tax included? Right now the subtotal is tax excluded.

Any help would be much appreciated, thank you!

发布评论

评论列表(0)

  1. 暂无评论