久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在 WooCommerce 3 中提供免費送貨時隱藏特定的統一

Hide specifics Flat Rates when Free Shipping is available in WooCommerce 3(在 WooCommerce 3 中提供免費送貨時隱藏特定的統一費率)
本文介紹了在 WooCommerce 3 中提供免費送貨時隱藏特定的統一費率的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

在 WooCommerce 3 中,我有以下運輸選項(設置):

In WooCommerce 3, I have these shipping options (settings):

  1. 免運費:free_shipping:1 - 最低訂單金額設為 $50.
  2. 正常運輸 flat_rate:3 - 金額 $5.
  3. 快遞flat_rate:5 - 金額$10.
  1. Free Shipping: free_shipping:1 - Minimum order amount is set at $50.
  2. Normal Shipping flat_rate:3 - Amount $5.
  3. Express Shipping flat_rate:5 - Amount $10.

我希望 快遞 選項始終可用(如圖所示).

I would like Express Shipping option to be always available (shown).

但是當免費送貨可用時(意味著客戶在購物車中的金額超過 50 美元),我只想隱藏正常送貨.

But when Free shipping is available (meaning that the customer has more than $50 in the cart) I would like to hide Normal Shipping only.

因此,當免費送貨可用(和隱藏)時,可用的運費將為正常送貨 和快遞.

So when Free shipping is NOT available (and hidden), the available shipping rates will be Normal Shipping and Express Shipping.

這可能嗎?我怎樣才能在 WooCommerce 3 上獲得這個?

Is that possible? How can I get this on WooCommerce 3?

推薦答案

基于 WooCommerce 官方代碼段,做了一些小改動,當免費送貨可用時,您將只能隱藏您的第一個統一費率:

Based on the official WooCommerce snippet code, making some light changes, you will be able to hide only your first flat rate when free shippings is available:

add_filter( 'woocommerce_package_rates', 'conditionally_hide_shipping_methods', 100, 2 );
function conditionally_hide_shipping_methods( $rates, $package ) {
    // HERE yours 2nd flat rate "Express Shipping" (that you never hide) in the array:
    $flat_rates_express = array( 'flat_rate:5', 'flat_rate:12', 'flat_rate:14' );

    $free = $flat2 = array();
    foreach ( $rates as $rate_key => $rate ) {
        // Updated Here To 
        if ( in_array( $rate->id, $flat_rates_express ) )
            $flat2[ $rate_key ] = $rate;
        if ( 'free_shipping' === $rate->method_id )
            $free[ $rate_key ] = $rate;
    }
    return ! empty( $free ) ? array_merge( $free, $flat2 ) : $rates;
}

代碼位于活動子主題(或主題)的 function.php 文件或任何插件文件中.

在 WooCommerce 3 上測試并有效.

Tested on WooCommerce 3 and works.

刷新運輸緩存:
1) 首先清空您的購物車.
2) 此代碼已保存在您的 function.php 文件中.
3) 進入運輸區域設置并禁用一個統一費率"(例如) 和保存".然后重新啟用統一費率"和保存".大功告成,可以進行測試了.

Refresh the shipping caches:
1) First empty your cart.
2) This code is already saved on your function.php file.
3) Go in a shipping zone settings and disable one "flat rate" (for example) and "save". Then re-enable that "flat rate" and "save". You are done and you can test it.

這篇關于在 WooCommerce 3 中提供免費送貨時隱藏特定的統一費率的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Cannot use #39;Object as class name as it is reserved Cake 2.2.x(不能使用 Object 作為類名,因為它是保留的 Cake 2.2.x)
Session is lost after an OAuth redirect(OAuth 重定向后會話丟失)
Pagination Sort in Cakephp 3.x(Cakephp 3.x 中的分頁排序)
CakePHP Shared core for multiple apps(CakePHP 多個應用程序的共享核心)
Login [ Auth-gt;identify() ] always false on CakePHP 3(在 CakePHP 3 上登錄 [ Auth-identify() ] 始終為 false)
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 87 bytes)(致命錯誤:允許的內存大小為 134217728 字節已用盡(嘗試分配 87 字節))
主站蜘蛛池模板: 亚洲国产成人在线视频 | 国产精品日韩欧美 | 欧美九九九 | 欧美激情精品久久久久久 | 91精品国产91久久综合桃花 | 国产精品爱久久久久久久 | 国产一区二区三区四区区 | 九九九久久国产免费 | 国产精彩视频 | 国产精品欧美一区喷水 | 免费国产视频 | 国产精品美女在线观看 | 免费超碰| 在线视频91 | 久久精品二区亚洲w码 | 精品人伦一区二区三区蜜桃网站 | 国产成人精品午夜 | 成人网av| 超碰97免费观看 | 欧美视频在线播放 | www.色.com| eeuss国产一区二区三区四区 | 亚洲视频三 | 毛片免费视频 | 国产精品日韩欧美一区二区三区 | jlzzjlzz国产精品久久 | 欧美国产视频一区二区 | 99国产精品视频免费观看一公开 | h视频免费观看 | 久久久婷婷 | 成人精品 | 国户精品久久久久久久久久久不卡 | 国产精品一区二区三级 | 欧美成人视屏 | 国产在线精品一区二区三区 | 欧美久久久久久 | 美国黄色毛片 | 日韩精品人成在线播放 | 国产一区二区成人 | 精品久久久久久久 | 亚洲欧美日韩激情 |