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!

WooCommerce: only allow 1 product in the cart

PHP Snippet: Limit the Cart to One Product – WooCommerce

 * @snippet       WooCommerce Max 1 Product @ Cart
 * @how-to        Get FREE
 * @author        Rodolfo Melogli
 * @compatible    WC 3.7
 * @donate $9
add_filter( 'woocommerce_add_to_cart_validation', 'bbloomer_only_one_in_cart', 99, 2 );
function bbloomer_only_one_in_cart( $passed, $added_product_id ) {
   return $passed;

Leave a Reply