代码之家  ›  专栏  ›  技术社区  ›  Mateusz Kulesza

在购物篮中隐藏没有价格的交付方式| Woccommerce|WCFM Marketplace

  •  0
  • Mateusz Kulesza  · 技术社区  · 1 年前

    我是新手,正在寻求帮助。

    我想在我的购物车中隐藏没有列出价格的送货方式。

    function ts_hide_shipping_without_prices( $rates ) {
        foreach ( $rates as $rate_id => $rate ) {
            // Check if the cost is zero and the method is not free
            if ( 0 == $rate->cost && 'free_shipping' !== $rate->method_id ) {
                unset( $rates[ $rate_id ] );
            }
        }
        return $rates;
    }
    
    add_filter( 'woocommerce_package_rates', 'ts_hide_shipping_without_prices', 100 );
    

    我有下面的代码,但它也隐藏了免费送货,因为它也没有价格。我不想要! 我希望下面的代码绕过免费送货。免费送货应该一直显示。

    0 回复  |  直到 1 年前