WooCommerce Cart - Conditional Items categories validation
问题 We have an exclusive category X and others regular categories Y . What I would like: When someone orders anything from category X , other category items cannot be added to cart and should display a warning category Y products should not be mixed with X . How could I achieve that? I got this code from other post, but its outdated and not satisfactory: <?php // Enforce single parent category items in cart at a time based on first item in cart function get_product_top_level_category ( $product