Here’s how to limit your WooCommerce Cart to just one product at a time.
This simple solution can be used for many applications. For example, your store may only allow to buy one subscription at a time.
On this same website, for example, customers can only purchase one product at a time so it’s easier for me to manage invoicing and payments, given that I switch PayPal and Stripe accounts based on what’s inside the cart.
Here’s the quick fix – enjoy!

PHP Snippet: Limit the Cart to Max One Product – WooCommerce
Note: technically speaking, the code below will force the product added to cart to replace whatever is in the cart, hence will only allow one product in the cart.
/**
* @snippet WooCommerce Max 1 Product @ Cart
* @how-to Get CustomizeWoo.com FREE
* @author Rodolfo Melogli
* @compatible WCooCommerce 7
* @donate $9 https://businessbloomer.com/bloomer-armada/
*/
add_filter( 'woocommerce_add_to_cart_validation', 'bbloomer_only_one_in_cart', 9999 );
function bbloomer_only_one_in_cart( $passed ) {
wc_empty_cart();
return $passed;
}
Mini-Plugin: Business Bloomer WooCommerce Only Allow 1 Product in the Cart
You don’t feel confident with coding? You don’t want to purchase yet another bloated, expensive plugin? Great!
Business Bloomer WooCommerce Only Allow 1 Product in the Cart is a mini WooCommerce plugin, without the usual hassles. One feature. Lifetime license. No annoying subscriptions. 1 plugin file. A few lines of code. No banners. No up-sells. No WP notifications. Use it on as many websites as you like. Lifetime support. 1-page documentation. Super simple admin dashboard.
Screenshot of the settings:

Quick demo:
As you can see the settings are pretty straight forward. Select the add to cart behavior from the dropdown, and the error message in case you choose the “Deny” behavior. Simple!