2017-03-03 233 views
2

什么是最高的方式来设置统一费率运费高达一定的美元金额,然后免费送货超过美元金额?我想这样设置:如果购物车的价格低于50美元,购物车中的所有商品均可享受15美元的运费,超过50美元的订单免运费。谢谢!Woocommerce统一费率和免费送货

+0

可能是这个任务离子代码+答案可以把你放在正确的方式(即使不是真的一样的问题):http://stackoverflow.com/questions/42396787/shipping-calculated-on-the-items-weight-and-cart-量 – LoicTheAztec

回答

0

您可以通过以下方式

  • 配置在WooCommerce区
  • 配置的免运费最低订购量$ 50
  • 使用下面的代码片段隐藏统一费率,如果扁率达到此车总金额超过$ 50

    add_filter('woocommerce_package_rates', 'hide_flat_rate_based_on_cart_total', 10, 3); 
    function hide_flat_rate_based_on_cart_total($available_shipping_methods, $package){ 
        $price_limit = 50; 
        if(WC()->cart->get_total() > $price_limit){ 
         foreach($available_shipping_methods as $method_key => $method){ 
          if (strpos($method->method_id, 'flat_rate') !== false) { 
           unset($available_shipping_methods[$method_key]); 
          } 
         } 
        } 
        return $available_shipping_methods; 
    } 
    
相关问题