[ad_1]
Heya everyone.
I am wondering if anyone knows of a plugin or functionality that can remove products from the cart and checkout page based on a customers shipping state/province (not the country) that they choose.
i.e. John has product A and product B in the cart table if John selects the province “XA” then product B should be removed from the table.
[ad_2]
You should be preventing them from being added to the cart in the first place, but you can use any of several ways to do this using existing hooks.
Shipping class is a common one, product category another. You want to use wc()->cart->remove_cart_item() in your conditional statement that checks the cart contents