【问题标题】:Different shipping prices based on sub total woocommerce不同的运费价格基于总 woocommerce
【发布时间】:2022-08-24 19:43:56
【问题描述】:

我需要以下内容。

当用户以低于 350 的价格购买时 - 只允许取货 当订单在 350 - 1000 之间时,将增加 35 的运费 当订单超过 1000 - 免费送货

    标签: php woocommerce


    【解决方案1】:

    超级简单的解决方案。 在运输方式下添加一种运输方式 -> 以 0 为值的统一费率。 然后在主题函数文件中添加:

    add_filter( 'woocommerce_package_rates', 'woocommerce_package_rates', 10, 2 );
    
    function woocommerce_package_rates( $rates, $package ) {
    
    foreach($rates as $key => $rate ) {
        
        if (WC()->cart->subtotal < 350){
        #only pick up
        $new_cost = 0;
        $rates[$key]->cost = $new_cost;
        $rates[$key]->label = 'Pick Up Only';   
    }
    
    else if (WC()->cart->subtotal > 350 && WC()->cart->subtotal < 1000) {
    
        $new_cost = 35;
        $rates[$key]->cost = $new_cost;
        $rates[$key]->label = 'Shipping - Deliver fee';
    }
    else {
        $new_cost = "Free Shipping";
        $rates[$key]->cost = $new_cost;
        $rates[$key]->label = 'Free Shipping Order above R1000';      
    }
            
    }
    
    return $rates;
    
    }
    

    【讨论】:

      猜你喜欢
      • 2019-02-02
      • 2019-01-23
      • 1970-01-01
      • 2019-03-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-25
      • 2021-08-01
      相关资源
      最近更新 更多