Remove item with $product_id - Woocommerce

前端 未结 2 971
礼貌的吻别
礼貌的吻别 2020-12-16 12:28

Made a function where the customer get a product added to the cart when they reach a specific amount.

Example of when customer reaches level 3 and get the

2条回答
  •  离开以前
    2020-12-16 12:54

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

    You are using it like so:

    WC()->cart->remove_cart_item($product_3);
    

    Try this instead:

    WC()->cart->remove_cart_item($cart_item_key);
    

    After updating that line, I think you will able to remove product.

提交回复
热议问题