久久久久久久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)
主站蜘蛛池模板: 亚洲精品在线播放 | 中文字幕一区在线观看视频 | 男女视频在线免费观看 | 亚洲精品一级 | 三区四区在线观看 | 国产中文字幕在线 | 国产精品久久久久久久免费大片 | 精品无码三级在线观看视频 | 中文字幕亚洲视频 | 亚洲区一区二 | 不卡av电影在线播放 | 日韩在线不卡视频 | 成人在线视频一区 | 91黄在线观看 | 毛片网站在线观看视频 | 一级毛片在线播放 | 国产精品久久久亚洲 | 国产精品成人一区二区 | 美女黄18岁以下禁止观看 | 久久久亚洲精品视频 | 国产成人艳妇aa视频在线 | av黄色在线 | 国产视频中文字幕 | 精品一区二区在线观看 | 国产激情91久久精品导航 | 黑人中文字幕一区二区三区 | 中文字幕爱爱视频 | 综合久久综合久久 | 欧美成人精品激情在线观看 | 久久精品一区二区三区四区 | 婷婷激情综合 | 日韩一区中文字幕 | 国产精品区二区三区日本 | 九九久久精品 | 中文字幕高清一区 | 天堂一区二区三区 | 日韩一区在线观看视频 | 欧美成人精品激情在线观看 | 狠狠爱一区二区三区 | www国产成人免费观看视频,深夜成人网 | 欧美夜夜 |