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

根據(jù)重量和最小購物車數(shù)量免費(fèi)送貨

Free shipping depending on weight and on minimal cart amount(根據(jù)重量和最小購物車數(shù)量免費(fèi)送貨)
本文介紹了根據(jù)重量和最小購物車數(shù)量免費(fèi)送貨的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

限時送ChatGPT賬號..

使用 WooCommerce,我需要獲得超過 250 的免費(fèi)送貨服務(wù),但購物車中包含的重型產(chǎn)品除外.

With WooCommerce, I need to have Free Shipping over certain amount of 250 except the heavy products that are included in the cart.

有人知道我該怎么做嗎?

Does anyone know what i should do?

謝謝.

推薦答案

此自定義代碼將保留免費(fèi)送貨方式,并在購物車金額達(dá)到250時隱藏其他送貨方式 并且如果產(chǎn)品不重(此處小于 20 公斤)……如果訂單少于 250 公斤,則不允許免費(fèi)送貨,您可以在 woocommerce 中進(jìn)行設(shè)置(見文末).

This custom code will keep free shipping method and will hide other shipping methods when the cart amount is up to 250 and if products are not heavy (less than 20 kg here)… To not allow Free shipping for orders less than 250, you can set this in woocommerce (see at the end).

首先,您必須確保在每個重型產(chǎn)品中設(shè)置了重量(對于簡單或可變產(chǎn)品(在每個變體中).這里的購物車小計是不含稅(并且您可以輕松地將其更改為包括稅金).

First you will have to sure that the weight is set in each heavy product (for simple or variables products (in each variations). The cart subtotal here is Excluding taxes (and you can change it to Including taxes easily).

然后是 woocommerce_package_rates 過濾器鉤子中的自定義鉤子函數(shù):

Then here is that custom hooked function in woocommerce_package_rates filter hook:

add_filter( 'woocommerce_package_rates', 'conditionally_hide_other_shipping_based_on_items_weight', 100, 1 );
function conditionally_hide_other_shipping_based_on_items_weight( $rates ) {

    // Set HERE your targeted weight (here is 20 kg) <== <== <== <== <==
    $targeted_product_weight = 20;
    
    // Set HERE your targeted cart amount (here is 250)  <== <== <== <== <==
    $targeted_cart_amount = 250;
    // For cart subtotal amount EXCLUDING TAXES
    $passed = WC()->cart->subtotal_ex_tax >= $targeted_cart_amount ? true : false;
    // For cart subtotal amount INCLUDING TAXES (replace by this):
    // $passed = WC()->cart->subtotal >= $targeted_cart_amount ? true : false;
    $light_products_only = true; // Initializing

    // Iterating trough cart items to get the weight for each item
    foreach( $package['contents'] as $cart_item ){
        // Getting the product weight
        $product_weight = $cart_item['data']->get_weight();

        if( !empty($product_weight) && $product_weight >= $targeted_product_weight ){
            $light_products_only = false;
            break;
        }
    }

    // If 'free_shipping' method is available and if products are not heavy
    // and cart amout up to the target limit, we hide other methods
    $free = array();
    foreach ( $rates as $rate_id => $rate ) {
        if ( 'free_shipping' === $rate->method_id && $passed && $light_products_only ) {
            $free[ $rate_id ] = $rate;
            break;
        }
    }

    return ! empty( $free ) ? $free : $rates;
}

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

Code goes in function.php file of your active child theme (or theme) or also in any plugin file.

此代碼經(jīng)過測試,適用于簡單和可變的產(chǎn)品......

This code is tested and it works for simple and variable products…

您還必須在 WooCommerce 設(shè)置中設(shè)置 >送貨,對于每個送貨區(qū)域和 免費(fèi)送貨" 方法,您的最低訂購量:

You Will also have to in WooCommerce settings > Shipping, for each shipping zone and for the "Free Shipping" method your minimum order amount:

您需要刷新運(yùn)輸緩存數(shù)據(jù):在woocommerce運(yùn)輸設(shè)置中禁用、保存和啟用、保存當(dāng)前運(yùn)輸區(qū)域的相關(guān)運(yùn)輸方式.

You will need to refresh shipping cached data: disable, save and enable, save related shipping methods for the current shipping zone, in woocommerce shipping settings.

這篇關(guān)于根據(jù)重量和最小購物車數(shù)量免費(fèi)送貨的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

Add programmatically a downloadable file to Woocommerce products(以編程方式將可下載文件添加到 Woocommerce 產(chǎn)品)
Get today#39;s total orders count for each product in Woocommerce(獲取今天 Woocommerce 中每種產(chǎn)品的總訂單數(shù))
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 簡單產(chǎn)品中添加一個將更改價格的選擇字段)
Add custom columns to admin products list in WooCommerce 3(在 WooCommerce 3 中將自定義列添加到管理產(chǎn)品列表)
Customizing checkout quot;Place Orderquot; button output html(自定義結(jié)帳“下訂單按鈕輸出html)
主站蜘蛛池模板: 亚洲人成一区二区三区性色 | 怡红院免费的全部视频 | 一区免费视频 | 人人性人人性碰国产 | 九色在线| 在线观看国产wwwa级羞羞视频 | 成年网站在线观看 | 欧美日韩国产综合在线 | 伊人久久精品一区二区三区 | 午夜欧美a级理论片915影院 | 久久久久无码国产精品一区 | 色精品 | 欧美激情一区二区三区 | 九九免费在线视频 | 免费黄色的网站 | 观看毛片 | 日产久久 | 日韩一区在线播放 | 日韩精品在线看 | 伊人精品久久久久77777 | 国产美女一区二区 | 男女网站免费观看 | 精品国产一区二区国模嫣然 | 国产综合视频 | 国产一区二区影院 | 日韩精品久久久久 | 久久久久久久亚洲精品 | 精品久久久久久久久久久院品网 | 激情五月激情综合网 | 中文在线一区二区 | 久在线观看 | www国产成人免费观看视频,深夜成人网 | 视频一区二区中文字幕 | 国产精品免费一区二区三区 | 日韩一区二区三区在线视频 | 91综合网 | 久久国产欧美日韩精品 | 欧美久久一区二区三区 | 国产欧美日韩在线 | 国产精品欧美一区二区 | 黄色免费在线网址 |