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

根據 Woocommerce 3 中的運輸類別過濾運輸方法

Filter Shipping method based on shipping class in Woocommerce 3(根據 Woocommerce 3 中的運輸類別過濾運輸方法)
本文介紹了根據 Woocommerce 3 中的運輸類別過濾運輸方法的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我一直在搜索代碼以過濾除本地提貨以外的任何送貨方式.

I have been searching for code to filter out any shipping methods other than local pick up, on checkout, when a product that has a specific shipping class selected (Only pickup, ex.) is in the cart (among other products).

我只發(fā)現過時的代碼并且在 WC3+ 上不起作用.

I only found code that was outdated and does not work on WC3+.

推薦答案

以下是在啟用特定運輸類別的產品時過濾掉除本地取件以外的任何運輸方式的方法:

Here is the way to filter out any shipping methods other than local pick up, when a product that has a specific shipping class enabled:

add_filter( 'woocommerce_package_rates', 'custom_shipping_rates', 100, 2 );
function custom_shipping_rates( $rates, $package ) {

    $shipping_class = 64; // HERE set the shipping class ID
    $found = false;

    // Loop through cart items Checking for the defined shipping method
    foreach( $package['contents'] as $cart_item ) {
        if ( $cart_item['data']->get_shipping_class_id() == $shipping_class ){
            $found = true;
            break;
        }
    }

    if ( ! $found ) return $rates; // If not found we exit

    // Loop through shipping methods
    foreach( $rates as $rate_key => $rate ) {
        // all other shipping methods other than "Local Pickup"
        if ( 'local_pickup' !== $rate->method_id && $found ){

            // Your code here
        }
    }

    return $rates;
}

代碼位于活動子主題(或活動主題)的 function.php 文件中.經測試有效

Code goes in function.php file of your active child theme (or active theme). Tested and works

然后在 StackOverFlow 使用 woocommerce_package_rates 搜索最近的答案 將允許您完成代碼.

Then in StackOverFlow searching for recent answer with woocommerce_package_rates will allow you to finish your code.

這篇關于根據 Woocommerce 3 中的運輸類別過濾運輸方法的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

Add programmatically a downloadable file to Woocommerce products(以編程方式將可下載文件添加到 Woocommerce 產品)
Get today#39;s total orders count for each product in Woocommerce(獲取今天 Woocommerce 中每種產品的總訂單數)
Add Custom registration fields in WooCommerce and phone field validation issue(在 WooCommerce 和電話字段驗證問題中添加自定義注冊字段)
Add a select field that will change price in Woocommerce simple products(在 Woocommerce 簡單產品中添加一個將更改價格的選擇字段)
Add custom columns to admin products list in WooCommerce 3(在 WooCommerce 3 中將自定義列添加到管理產品列表)
Customizing checkout quot;Place Orderquot; button output html(自定義結帳“下訂單按鈕輸出html)
主站蜘蛛池模板: 日韩在线精品视频 | 国产在线一区二区 | 久草免费在线视频 | 一区二区三区久久久 | 一区二区三区不卡视频 | 国产精品久久久久久中文字 | 91精品国产综合久久婷婷香蕉 | 亚洲精品一区二区二区 | 国产成人精品一区二区三区 | 亚洲精品第一 | 欧美成人精品一区二区男人看 | 日韩毛片播放 | 国产精品成人一区二区三区夜夜夜 | 激情一区二区三区 | 一区二区三区欧美 | 国产一区二区在线看 | 中文字幕在线网 | 综合二区| 日本一道本视频 | 91精品久久久久久久久久 | 日韩国产中文字幕 | 成人小视频在线观看 | 亚洲成人999 | 国产视频三级 | 三级av网址| 欧美成人a∨高清免费观看 色999日韩 | 粉嫩一区二区三区国产精品 | 国产成人在线视频 | 草草视频在线观看 | 四季久久免费一区二区三区四区 | 亚州精品天堂中文字幕 | 久久久久一区二区 | 特黄毛片 | 一二区成人影院电影网 | 成人在线a | 国产目拍亚洲精品99久久精品 | 日韩视频―中文字幕 | 精品国产一级 | 久久国产成人 | 亚洲www啪成人一区二区麻豆 | 99资源站 |