在Woocommerce 3.5中的购物车表上删除装运估计消息

Chr*_*Rea 2 php wordpress templates cart woocommerce

在最新版本的WooCommerce中,购物车中显示一条消息,指出运费仅是估计值。

https://www.screencast.com/t/2hSd7B27I

当某人使用统一费率送货并且根本不计算送货时,这毫无意义。请注意,我也没有激活计算运费。我试图用css隐藏消息,但是它当然没有要定位的类。

有谁知道如何关闭此功能?

Luk*_*Luk 7

现在您可以使用woocommerce_shipping_estimate_html过滤器。

例如。:

function shipping_estimate_html()
{
    return null;
}
add_filter('woocommerce_shipping_estimate_html', 'shipping_estimate_html');
Run Code Online (Sandbox Code Playgroud)


Loi*_*tec 5

这是Woocommerce 3.5版以来的新功能:您将需要通过您的主题(如本链接中所述)覆盖模板文件cart/cart-shipping.php

从第46到行58,您将替换以下内容:

<?php if ( is_cart() ) : ?>
    <p class="woocommerce-shipping-destination">
        <?php
        if ( $formatted_destination ) {
            // Translators: $s shipping destination.
            printf( esc_html__( 'Estimate for %s.', 'woocommerce' ) . ' ', '<strong>' . esc_html( $formatted_destination ) . '</strong>' );
            $calculator_text = __( 'Change address', 'woocommerce' );
        } else {
            echo esc_html__( 'This is only an estimate. Prices will be updated during checkout.', 'woocommerce' );
        }
        ?>
    </p>
<?php endif; ?>
Run Code Online (Sandbox Code Playgroud)

这样:

<?php if ( is_cart() ) : ?>
    <p class="woocommerce-shipping-destination">
        <?php
        if ( $formatted_destination ) {
            $calculator_text = __( 'Change address', 'woocommerce' );
        }
        ?>
    </p>
<?php endif; ?>
Run Code Online (Sandbox Code Playgroud)

您完成了……再也没有烦人的通知了。


小智 2

如果您的模板没有 cart-shipping.php 文件,则此 css 修改对我有用:

.cart-totals-inner .woocommerce-shipping-destination {
display: none; }
Run Code Online (Sandbox Code Playgroud)