【问题标题】:Show only free shipping when over x amount issue in Woocommerce在 Woocommerce 中超过 x 数量问题时仅显示免费送货
【发布时间】:2018-01-06 20:30:38
【问题描述】:

如果可以免费送货,我会尝试隐藏“统一费率”。

add_filter( 'woocommerce_package_rates', 'hide_other_shipping_when_free_is_available', 100, 2 );

function hide_other_shipping_when_free_is_available( $rates, $package ) {

    $free = array();
    foreach ( $rates as $rate_id => $rate ) {
        if ( 'free_shipping' === $rate->method_id ) {
            $free[ $rate_id ] = $rate;
            break;
        }
    }
    return ! empty( $free ) ? $free : $rates;
}

我找到了以下 sn-p 并添加到我的 functions.php 中,但它并没有隐藏统一运费选项。

【问题讨论】:

    标签: php wordpress woocommerce cart shipping


    【解决方案1】:

    此代码仍然适用于 woocommerce 版本 2.6+(也适用于 3.2.x)

    缺少的部分是,一旦您将代码保存在 function.php 文件中,您需要刷新运输缓存数据:

    在 woocommerce 运输设置中禁用、保存和启用、保存当前运输区域的相关运输方式。

    【讨论】:

      猜你喜欢
      • 2014-04-14
      • 1970-01-01
      • 2019-05-31
      • 2013-04-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-05
      • 2015-08-14
      相关资源
      最近更新 更多