久久久久久久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)
主站蜘蛛池模板: 亚洲一区二区三区在线免费 | 中文字幕在线观看精品 | 久久草在线视频 | 欧美jizzhd精品欧美巨大免费 | 久久男人| 狠狠做六月爱婷婷综合aⅴ 国产精品视频网 | 亚洲成人蜜桃 | 欧美啪啪 | 亚洲专区在线 | 最新国产精品精品视频 | 91av导航| 丁香五月缴情综合网 | 看亚洲a级一级毛片 | 久久久久国产精品一区二区 | 中文字幕日本一区二区 | 日韩精品免费视频 | 日韩在线一区二区三区 | 欧美一级高潮片免费的 | 国产亚洲精品美女久久久久久久久久 | 成人综合在线视频 | 91精品久久久久久久久久 | 一区二区三区电影网 | 国产精品成人一区二区 | 欧美高清性xxxxhd | 欧美亚洲视频 | 九九激情视频 | 欧美一区二区在线播放 | 日韩综合在线 | 日本午夜视频 | 精品国产一二三区 | 日韩欧美国产成人一区二区 | 91精品国产高清久久久久久久久 | 午夜免费观看体验区 | 久久精品国产清自在天天线 | 91av精品 | 久久亚洲一区二区 | 日韩成人在线播放 | 日韩在线精品 | 日韩成人在线播放 | 亚洲免费视频在线观看 | 西西裸体做爰视频 |