【问题标题】:Hide one delivery method if another is available Woocommerce如果另一种交付方式可用,则隐藏一种交付方式 Woocommerce
【发布时间】:2018-10-22 12:16:39
【问题描述】:

我有两种免费送货方式。

第一个-在城市,50美元起免费。第二个在城市外,70美元起免费。因此,当客户的订单超过70美元时,所有4种送货方式都是对他可用(城市是付费的,城市是免费的,城外是付费的,城外是免费的)。

对我来说有必要,当有城市免费送货方式时,必须隐藏城市付费送货方式。而当城外有免费送货方式时,则必须隐藏城外付费送货方式。

我为糟糕的英语道歉,我请求你的帮助。

我试过这样,但它不起作用。

function hide_shipping( $rates ) {
    if (isset( $rates['free_shipping:3'] ) ) {
      unset( $rates['flat_rate:1'] );
    }
    if (isset( $rates['free_shipping:9'] ) ) {
      unset( $rates['local_pickup:7'] );
    }
  return $rates;
}
add_filter( 'woocommerce_package_rates', 'hide_shipping', 10, 2 );

【问题讨论】:

    标签: php wordpress woocommerce shipping


    【解决方案1】:

    一切都正确,代码正在运行!我没有注意到自己有错误。我道歉:)

    【讨论】:

    • 好,继续
    猜你喜欢
    • 2022-01-10
    • 2017-06-27
    • 1970-01-01
    • 2017-05-17
    • 2020-03-28
    • 1970-01-01
    • 2020-08-09
    • 1970-01-01
    • 2018-11-09
    相关资源
    最近更新 更多