Here’s how to limit your WooCommerce Cart to just 1 product.
This simple PHP snippet can be used for many applications – for example, your store only allows to buy one product at a time, or max one subscription. Here’s the quick fix – just copy/paste in your functions.php!

PHP Snippet: Limit the Cart to One Product – WooCommerce
/** * @snippet WooCommerce Max 1 Product @ Cart * @how-to Get CustomizeWoo.com FREE * @author Rodolfo Melogli * @compatible WC 3.7 * @donate $9 https://businessbloomer.com/bloomer-armada/ */ add_filter( 'woocommerce_add_to_cart_validation', 'bbloomer_only_one_in_cart', 99, 2 ); function bbloomer_only_one_in_cart( $passed, $added_product_id ) { wc_empty_cart(); return $passed; }