• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: If product A is in cart, remove from cart any items in category B, C and D

Resolved: If product A is in cart, remove from cart any items in category B, C and D

0
By Isaac Tonny on 17/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

I tried various snippets to achieve what I need but I’m failing miserably.
I need products contained within categories B, C & D removed from the cart if a product in category A is present/added. At this point, I would be happy with just removing products in categories B, C & D if a specific product ID is present/added.
I think the code from Remove other products if certain product category is present on WooCommerce checkout answer code is close, but I just can’t seem to adapt it for my needs.

Answer:

You need to loop first to detect any “Category A” product in the cart. If there is one, then loop again to find any product from other target categories to remove.
This edit should do it.

If you have better answer, please add a comment about this, thank you!

php woocommerce wordpress
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: How to compare two text files and and change the sign of the data in powershell?

27/03/2023

Resolved: Java Virtual Machines deleted

27/03/2023

Resolved: PyCharm cannot see my newly compiled .pyc see on import

27/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.