【问题标题】:Display "excl. VAT" in Woocommerce product-subtotal在 Woocommerce 产品小计中显示“不包括增值税”
【发布时间】:2021-01-02 06:22:14
【问题描述】:

在 Woocommerce 中,当您选择在结帐时显示包含增值税的价格时,Woocommerce 会在 td.product-subtotal 之后添加一个 .tax_label,在总计之后添加一个 .includes_tax。对于增值税为 0% 的国家/地区的客户,不显示任何内容,我需要将 tax_label 和 includes_tax 显示为“excl.增值税”。因此,在 td.product-subtotal 单元格中应该有添加“excl.VAT”的小计价格,在 order-total.td 中应该有添加“excl.VAT”的总价。

add_filter( 'woocommerce_cart_hide_zero_taxes', '__return_false' );

上面的过滤器没有做我想要的,因为它没有将“excl.VAT”添加到 td.product-subtotal。

【问题讨论】:

    标签: php wordpress woocommerce


    【解决方案1】:

    如果您谈论的是购物车小计,则有一个过滤器可以过滤 woocommerce_cart_subtotal

    <?php
    add_filter( 'woocommerce_cart_subtotal', 'filter_woocommerce_cart_subtotal', 10, 3 );
    function filter_woocommerce_cart_subtotal( $cart_subtotal, $compound, $instance ) {
      if( ! empty( $cart_subtotal ) ) {
        return $cart_subtotal . ' - excl. VAT';
      };
    }; ?>
    

    未经测试,但应该可以工作。

    【讨论】:

    • @amainediary 即使对于税收不是 0% 的国家/地区,它也会显示出来......但我实际上让它与 if ($cart->get_subtotal_tax() == 0) 一起使用。现在我仍然需要在订单总数单元格中显示它。你知道是否也有过滤器吗?
    猜你喜欢
    • 2012-08-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-02
    相关资源
    最近更新 更多