I sell both tangible and virtual products in my WooCommerce store, and am I having a hard time figuring out what to do when someone from outside the US tries to order a tangible product. I've looked around, and most solutions tend to be all or nothing. I'll sell my virtual products to anyone and anywhere, but I need to prevent people from outside the US from checking out if they have a tangible product in their cart.
Right now, if someone from outside the US tries to checkout with a tangible product, they just get a message in the shipping section that says "There are no shipping options available. Please ensure that your address has been entered correctly, or contact us if you need any help." but otherwise they are able to checkout. Anyone have any ideas or suggestions?
Based on Disable shipping for specific products based on country in Woocommerce, the following code will avoid add to cart for physical products or will remove physical cart items if customer shipping address is outside a specific country (USA here):
Code goes in functions.php file of your child theme (or in a plugin). Tested and works.