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

如何刪除 woocommerce 錯誤您不能將另一個“產品名

How to remove woocommerce error You cannot add another “PRODUCT NAME” to your cart(如何刪除 woocommerce 錯誤您不能將另一個“產品名稱添加到您的購物車)
本文介紹了如何刪除 woocommerce 錯誤您不能將另一個“產品名稱"添加到您的購物車的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

在我的網站woocommerce設置中,刪除添加到卡片ajax和通知;當用戶(訪問者)將產品添加到購物籃進行購買時,點擊購物籃后重定向并顯示消息將產品添加到購物籃中的卡片成功

in my website woocommerce settings, remove add to card ajax and notice; and when users (visitors) add a product to basket for buy, redirect after click to basket and show message add product to card successful in basket

但是當產品選項處于活動狀態(啟用)時,我想單獨出售選項.用戶反復嘗試將產品添加到購物籃.收到以下消息:不能將另一個產品名稱"添加到您的購物車.我的問題是如何使用functions.php 刪除此woocommerce 錯誤您不能將另一個產品名稱"添加到您的購物車.

but when in product option active (enable) I want to sell alone option. users try for add product to basket for repeatedly. receive below message: cannot add another "PRODUCT NAME" to your cart. my question is How to use functions.php for remove this woocommerce error You cannot add another "PRODUCT NAME" to your cart.

重復單擊購物車中的添加到購物車按鈕后,購物車中會顯示新消息您之前將產品名稱"添加到您的購物車.所以現在你可以付款了.

and new message show in basket after repeat click add to cart button in basket you previously "PRODUCT NAME" to your cart. so now you can pay.

一般:

  1. 刪除無法添加另一個...消息并在點擊后停止重定向到產品頁面.

  1. remove cant add another ... message and stop redirect to product page after click.

顯示新的自定義消息.點擊后進入購物籃.

show new custom message. after click and go to basket.

非常感謝大家

推薦答案

這是一個經過測試且有效的解決方案,用于刪除您不能添加另一個"消息.

背景:Woocommerce 并未公開對其所有通知的直接掛鉤.購物車錯誤實際上被硬編碼到 class-wc-cart.php 中作為拋出的異常.

Background: Woocommerce does not expose direct hooks to all of its notices. The cart errors are actually hardcoded into class-wc-cart.php as thrown Exceptions.

當生成錯誤異常時,它們會被添加到通知列表中,我們可以使用這些方法訪問、解析和更改:

When Error Exceptions are generated, they get added to a list of Notices that we can access, parse, and alter using the methods:

  • wc_get_notices() 將所有通知作為數組返回
  • wc_set_notices() 可讓您直接設置通知數組
  • wc_get_notices() returns all notices as an array
  • wc_set_notices() lets you set the notices array directly

為了訪問通知并更改它們,您需要掛鉤一個將在 woocommerce 生成其通知后觸發的操作,但在頁面顯示之前.您可以通過以下操作實現:woocommerce_before_template_part

In order to access the notices and alter them, you need to hook an action that will fire after woocommerce has generated its notices, but BEFORE the page is displayed. You can do that with the action: woocommerce_before_template_part

這里是完整的工作代碼,專門刪除了您不能添加另一個"通知:

Here is complete working code that specifically removes "You cannot add another" notices:

add_action('woocommerce_before_template_part', 'houx_filter_wc_notices');

function houx_filter_wc_notices(){
        $noticeCollections = wc_get_notices();

        /*DEBUGGING: Uncomment the following line to see a dump of all notices that woocommerce has generated for this page */
        /*var_dump($noticeCollections);*/

        /* noticeCollections is an array indexed by notice types.  Possible types are: error, success, notice */
        /* Each element contains a subarray of notices for the given type */
        foreach($noticeCollections as $noticetype => $notices)
        {
                if($noticetype == 'error')
                {
                        /* the following line removes all errors that contain 'You cannot add another'*/
                        /* if you want to filter additiona errors, just copy the line and change the text */
                        $filteredErrorNotices = array_filter($notices, function ($var) { return (stripos($var, 'You cannot add another') === false); });
                        $noticeCollections['error'] = $filteredErrorNotices;
                }
        }

        /*DEBUGGING: Uncomment to see the filtered notices collection */
        /*echo "<p>Filtered Notices:</p>";
        var_dump($noticeCollections);*/

        /*This line overrides woocommerce notices by changing them to our filtered set. */
        wc_set_notices($noticeCollections);
}

旁注:如果您想添加自己的通知,可以使用 wc_add_notice().您必須閱讀 woocommerce 文檔以了解它是如何工作的:WooCommerce 文檔上的 wc_add_notice

Side note: If you wanted to add your own notice, you can use wc_add_notice(). You'll have to read the woocommerce documentation to see how it works: wc_add_notice on WooCommerce docs

這篇關于如何刪除 woocommerce 錯誤您不能將另一個“產品名稱"添加到您的購物車的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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)
主站蜘蛛池模板: 成人免费视频网站 | 91精品国产综合久久精品图片 | 亚洲一区二区视频在线观看 | 激情亚洲| 天天久久 | 午夜色婷婷 | 另类二区 | 国产高清在线精品一区二区三区 | 美国一级片在线观看 | 亚洲一区二区视频在线观看 | 国产精品国产三级国产aⅴ入口 | 国产精品免费在线 | 日韩在线视频免费观看 | 99精品九九 | 日韩精品视频一区二区三区 | 久草院线 | 久久一日本道色综合久久 | 婷婷福利 | 欧美一级免费 | 亚洲精品在线免费看 | 亚洲精品18 | 夜久久 | 一级毛片免费视频 | 国产精品日韩欧美一区二区三区 | 日韩视频在线免费观看 | 日韩av在线中文字幕 | 武道仙尊动漫在线观看 | 精品久久久网站 | 性生生活大片免费看视频 | 国产农村一级片 | 国产精品福利网站 | 亚洲啪啪 | 国产精品成人久久久久 | 国产精品伦一区二区三级视频 | 国产激情视频网 | 一区二区三区在线免费观看 | 欧美日韩电影一区二区 | 亚洲婷婷六月天 | 黄色精品 | 99久久精品一区二区毛片吞精 | 午夜网址 |