問題描述
開發了一個功能,讓客戶在達到特定數量時將產品添加到購物車.
Made a function where the customer get a product added to the cart when they reach a specific amount.
客戶達到第 3 級并添加產品的示例.
如果客戶決定刪除項目,那么此聲明是正確的,我希望能夠再次刪除它.
If customer decides to remove item's so this statement is true i want to be able to remove it again.
我無法從購物車中移除產品.任何想法在這里做錯了什么?一直在四處尋找,但沒有找到任何適合我的解決方案.
Am do not manage to remove the product from cart. Any ideas what am doing wrong here? Have been searching around without finding any solution that works for me.
解決方案
在@Rohil_PHPBeginner & 的幫助下@WisdmLabs 我來到了這個為我完成工作的解決方案.
With help from @Rohil_PHPBeginner & @WisdmLabs I came to this solution that did the job for me.
推薦答案
我認為您對 remove_cart_item
的使用不正確.如果您瀏覽文檔,您會發現它接受cart_item_key 作為參數(如評論中提到的 wisdmLabs).
I think you're using remove_cart_item
incorrectly. If you go through the documentation, you will find that it accepts cart_item_key as parameter (as wisdmLabs mentioned in comment).
你是這樣使用它的:
試試這個:
更新該行后,我認為您將能夠刪除產品.
After updating that line, I think you will able to remove product.
這篇關于刪除帶有 $product_id 的項目 - Woocommerce的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!