删除woocommerce购物车(按国家/地区估算)税务文本

时间:2018-05-10 08:58:04

标签: php wordpress woocommerce cart tax

我在wordpress中建立一个网站,当我转到购物车时,这种情况不断涌现

"(估计为澳大利亚)"在TAX之后,然后给出项目税的价值。

我在这里检查了另一个问题并回答同样的问题,但他们对我的代码有不同的代码。我尝试了一些不同的东西,但无法弄清楚。

这是我在谷歌浏览器上检查购物车时的代码。

<tr class="tax-total">
    <th>Tax <small>(estimated for Australia)</small></th>
    <td data-title="Tax">
       <span class="woocommerce-Price-amount amount">
       <span class="woocommerce-Price-currencySymbol">$</span>109.80</span> 
    </td>
</tr>

有人可以为我找出过滤器修补程序吗?

2 个答案:

答案 0 :(得分:1)

该行为的负责任函数是wc_cart_totals_order_total_html() ...但希望您可以使用以下代码挂钩函数更改它:

add_filter( 'woocommerce_cart_totals_order_total_html', 'filtering_cart_totals_order_total_html', 20, 1 );
function filtering_cart_totals_order_total_html( $value ){
    $value = '<strong>' . WC()->cart->get_total() . '</strong> ';

        // If prices are tax inclusive, show taxes here.
    if ( wc_tax_enabled() && WC()->cart->display_prices_including_tax() ) {
        $tax_string_array = array();
        $cart_tax_totals  = WC()->cart->get_tax_totals();

        if ( get_option( 'woocommerce_tax_total_display' ) == 'itemized' ) {
            foreach ( $cart_tax_totals as $code => $tax ) {
                $tax_string_array[] = sprintf( '%s %s', $tax->formatted_amount, $tax->label );
            }
        } elseif ( ! empty( $cart_tax_totals ) ) {
            $tax_string_array[] = sprintf( '%s %s', wc_price( WC()->cart->get_taxes_total( true, true ) ), WC()->countries->tax_or_vat() );
        }

        if ( ! empty( $tax_string_array ) ) {
            $value .= '<small class="includes_tax">' . sprintf( __( '(includes %s)', 'woocommerce' ), implode( ', ', $tax_string_array ) ) . '</small>';
        }
    }
    return $value;
}

代码进入活动子主题(或活动主题)的function.php文件。经过测试并正常工作。

你会得到:

enter image description here

而不是:

enter image description here

根据这个答案,这是Woocommerce 3.2+的更新略有不同:Remove "estimated for {country}" text after tax amount in Woocommerce checkout page

答案 1 :(得分:0)

您可以通过编辑主题的WooCommerce购物车模板文件来完成此操作。我猜在cart.php中有硬编码。

或者,如果您想要更简单的解决方案,只需使用CSS隐藏它。

此代码隐藏&#34;(估计为{country})&#34;部分:

.tax-total th small {display:none!important}

这个隐藏

.tax-total {display:none!important}
相关问题