在 WooCommerce 中应用零税时仅显示不含增值税的产品价格

问题描述 投票:0回答:1

我的 woocommerce 产品页面上显示的价格显示为 ex。增值税及公司当所选国家/地区的税率为 20% 时,增值税没问题,但是当我选择税率为 0% 的国家/地区时,我的价格显示含税和不含税的金额相同。即 15.00 不含增值税和 15.00 含增值税。当所选国家/地区税率为 0% 时,如何隐藏含增值税金额?

我已将 Price.php 文件更新为最新的 woocommerce 版本,但定价保持不变。

<?php if ( $price_html = $product->get_price_html() ) : ?>

    <span class="price-excvat"><?php echo wc_price( wc_get_price_excluding_tax( $product ) ); ?> Exc. VAT</span><br />

    <span class="price-incvat"><?php echo wc_price( wc_get_price_including_tax( $product ) ); ?> Inc. VAT</span>

<?php endif; ?>
php wordpress templates woocommerce product-price
1个回答
0
投票

尝试以下方法仅显示 0 税费的含增值税价格(已更新)

<?php if ( $price_html = $product->get_price_html() ) : ?>

<?php 
    $price_excl_tax = wc_get_price_excluding_tax( $product ); 
    $price_incl_tax = wc_get_price_including_tax( $product ); 

    if ( $price_excl_tax !== $price_incl_tax ) : ?>

    <span class="price-cvat"><?php echo wc_price( wc_get_price_excluding_tax( $product ) ); ?> Exc. VAT</span><br />

    <span class="price-incvat"><?php echo wc_price( wc_get_price_including_tax( $product ) ); ?> Inc. VAT</span>

    <?php else : ?>

    <span class="price-zerovat"><?php echo wc_price( wc_get_price_including_tax( $product ) ); ?></span>

    <?php endif; ?>

    <span class="price-incvat"><?php echo wc_price( wc_get_price_including_tax( $product ) ); ?> Inc. VAT</span>

<?php endif; ?>

应该可以。

© www.soinside.com 2019 - 2024. All rights reserved.