pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

根據重量和最小購物車數量免費送貨

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

問題描述

限時送ChatGPT賬號..

使用 WooCommerce,我需要獲得超過 250 的免費送貨服務,但購物車中包含的重型產品除外.

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?

謝謝.

推薦答案

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

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).

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

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 過濾器鉤子中的自定義鉤子函數:

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.

此代碼經過測試,適用于簡單和可變的產品......

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

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

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

您需要刷新運輸緩存數據:在woocommerce運輸設置中禁用、保存和啟用、保存當前運輸區域的相關運輸方式.

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.

這篇關于根據重量和最小購物車數量免費送貨的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

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)
主站蜘蛛池模板: 小型UV打印机-UV平板打印机-大型uv打印机-UV打印机源头厂家 |松普集团 | 吉祥新世纪铝塑板_生产铝塑板厂家_铝塑板生产厂家_临沂市兴达铝塑装饰材料有限公司 | 捆扎机_气动捆扎机_钢带捆扎机-沈阳海鹞气动钢带捆扎机公司 | 合肥地磅_合肥数控切割机_安徽地磅厂家_合肥世佳电工设备有限公司 | 炒货机-炒菜机-炒酱机-炒米机@霍氏机械 | 活性炭-果壳木质煤质柱状粉状蜂窝活性炭厂家价格多少钱 | 太阳能发电系统-太阳能逆变器,控制器-河北沐天太阳能科技首页 | 全国冰箱|空调|洗衣机|热水器|燃气灶维修服务平台-百修家电 | 【星耀裂变】_企微SCRM_任务宝_视频号分销裂变_企业微信裂变增长_私域流量_裂变营销 | 奥运星-汽车性能网评-提供个性化汽车资讯 | 无锡网站建设_企业网站定制-网站制作公司-阿凡达网络 | bng防爆挠性连接管-定做金属防爆挠性管-依客思防爆科技 | 防水套管-柔性防水套管-刚性防水套管-上海执品管件有限公司 | 小型手持气象站-空气负氧离子监测站-多要素微气象传感器-山东天合环境科技有限公司 | CE认证_FCC认证_CCC认证_MFI认证_UN38.3认证-微测检测 CNAS实验室 | 东莞猎头公司_深圳猎头公司_广州猎头公司-广东万诚猎头提供企业中高端人才招聘服务 | 复合土工膜厂家|hdpe防渗土工膜|复合防渗土工布|玻璃纤维|双向塑料土工格栅-安徽路建新材料有限公司 | 液压压力机,液压折弯机,液压剪板机,模锻液压机-鲁南新力机床有限公司 | 成都顶呱呱信息技术有限公司-贷款_个人贷款_银行贷款在线申请 - 成都贷款公司 | 双效节能浓缩器-热回流提取浓缩机组-温州市利宏机械 | 七维官网-水性工业漆_轨道交通涂料_钢结构漆| 首页_中夏易经起名网| 电镀整流器_微弧氧化电源_高频电解电源_微弧氧化设备厂家_深圳开瑞节能 | 成都亚克力制品,PVC板,双色板雕刻加工,亚克力门牌,亚克力标牌,水晶字雕刻制作-零贰捌广告 | 东亚液氮罐-液氮生物容器-乐山市东亚机电工贸有限公司 | 上海办公室装修,写字楼装修—启鸣装饰设计工程有限公司 | 消防设施操作员考试报名时间,报名入口,报考条件 | 太空舱_民宿太空舱厂家_移动房屋太空舱价格-豪品建筑 | 深圳激光打标机_激光打标机_激光焊接机_激光切割机_同体激光打标机-深圳市创想激光科技有限公司 深圳快餐店设计-餐饮设计公司-餐饮空间品牌全案设计-深圳市勤蜂装饰工程 | 盐城网络公司_盐城网站优化_盐城网站建设_盐城市启晨网络科技有限公司 | 石英陶瓷,石英坩埚,二氧化硅陶瓷-淄博百特高新材料有限公司 | 篷房[仓储-婚庆-展览-活动]生产厂家-江苏正德装配式帐篷有限公司 | 高防护蠕动泵-多通道灌装系统-高防护蠕动泵-www.bjhuiyufluid.com慧宇伟业(北京)流体设备有限公司 | 环讯传媒,永康网络公司,永康网站建设,永康小程序开发制作,永康网站制作,武义网页设计,金华地区网站SEO优化推广 - 永康市环讯电子商务有限公司 | 世界箱包品牌十大排名,女包小众轻奢品牌推荐200元左右,男包十大奢侈品牌排行榜双肩,学生拉杆箱什么品牌好质量好 - Gouwu3.com | 旅游规划_旅游策划_乡村旅游规划_景区规划设计_旅游规划设计公司-北京绿道联合旅游规划设计有限公司 | RTO换向阀_VOC高温阀门_加热炉切断阀_双偏心软密封蝶阀_煤气蝶阀_提升阀-湖北霍科德阀门有限公司 | 潍坊大集网-潍坊信息港-潍坊信息网 | 武汉天安盾电子设备有限公司 - 安盾安检,武汉安检门,武汉安检机,武汉金属探测器,武汉测温安检门,武汉X光行李安检机,武汉防爆罐,武汉车底安全检查,武汉液体探测仪,武汉安检防爆设备 | 成都顶呱呱信息技术有限公司-贷款_个人贷款_银行贷款在线申请 - 成都贷款公司 | 信阳网站建设专家-信阳时代网联-【信阳网站建设百度推广优质服务提供商】信阳网站建设|信阳网络公司|信阳网络营销推广 |