【问题标题】:How to get total shipping fee in checkout page?如何在结帐页面获得总运费?
【发布时间】:2018-12-27 01:36:24
【问题描述】:

每当运费总价为 0 时,我想删除结帐页面中的运费行。 Check this

现在这是我得到的代码。 此代码允许隐藏运输行,使用运费我可以创建条件将其隐藏在结帐页面上。谢谢

function disable_shipping_calc_on_cart($show_shipping) {
if(is_checkout()){
return false;
}
return $show_shipping;
}
add_filter( 'woocommerce_cart_ready_to_calc_shipping', 'disable_shipping_calc_on_cart', 99 );

【问题讨论】:

  • 你能正确阅读这个问题吗@GufranHasan?这个问题很具体。
  • 好的,您可以添加此过滤器以在总计为 0 时隐藏运费。woocommerce_cart_shipping_method_full_label

标签: php wordpress


【解决方案1】:

请在functions.php 中添加此过滤器woocommerce_cart_shipping_method_full_label

add_filter( 'woocommerce_cart_shipping_method_full_label', 'add_free_shipping_label', 10, 2 );
    function add_free_shipping_label( $label, $method ) {
        if ( is_checkout() && $method->cost == 0 ) {
            echo '<style>tr.shipping{display:none;}</style>';
        }
        return $label;
    }

Reference

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-05-11
  • 2014-11-02
  • 2017-02-27
  • 2015-03-05
  • 2016-06-15
  • 2018-03-03
相关资源
最近更新 更多