php - Woocommerce 在单个产品页面中显示含增值税和不含增值税的价格?
问题描述
我有一个自己无法找到答案的问题。我想在产品价格旁边显示单个产品页面(在我的情况下,目前显示没有增值税),但我想显示没有增值税和增值税,这样我的客户就可以知道他们真正支付的费用。我在 stackoverflow 中搜索了 asnwer,但没有找到有关该主题的正确答案。谁能给我点从哪里开始。我使用 Woo 3.3.5。我在谷歌上找到了这段代码,但它似乎无法正常工作:
function edit_price_display() {
$product = new WC_Product( get_the_ID() );
$price = $product->price;
$price_incl_tax = $price + round($price * ( 21 / 100 ), 2);
$price_incl_tax = number_format($price_incl_tax, 2, ",", ".");
$price = number_format($price, 2, ",", ".");
$display_price = '<span class="price">';
$display_price .= '<span class="amount">€ ' . $price_incl_tax .'<small
class="woocommerce-price-suffix"> incl BTW</small></span>';
$display_price .= '<br>';
class="woocommerce-price-suffix"> excl BTW</small></span>';
$display_price .= '</span>';
echo $display_price;
}
add_filter('woocommerce_price_html', 'edit_price_display');
解决方案
推荐阅读
- python-3.x - initialdir 参数的 tkinter askdirectory 默认值是什么?
- r - str_match 为不同的输入变量提供具有挑战性的输出
- prolog - Prolog 中的“如果 == null”等价物
- android - 将视频从树莓派流式传输到安卓统一应用程序?
- sql - 从 Oracle SQL 获取唯一值
- ruby - 根据Ruby中的朝向改变位置
- ruby-on-rails - 如何使用 fast_jsonapi 在 Ruby on Rails 中序列化 habtm 关系
- javascript - For 循环暂停,但一次打印出所有数组
- javascript - jQuery坏了?Bootstrap 在 BOOTSTRAP SITE 上无法正常工作,仅使用开发机器访问
- android - 为什么根据使用 Orbitron 字体系列的设备类型(台式机或移动设备),按钮文本上方和下方的空格不一致?