Limitar número de productos en los pedidos de WooCommerce

    <?php
    add_filter( 'woocommerce_add_to_cart_validation', 'wc_limit_one_per_order', 10, 2 );
    function wc_limit_one_per_order( $passed_validation, $product_id ) {
    	if ( 31 !== $product_id ) {
    		return $passed_validation;
    	}
    	if ( WC()->cart->get_cart_contents_count() >= 1 ) {
    		wc_add_notice( __( 'This product cannot be purchased with other products. Please, empty your cart first and then add it again.', 'woocommerce' ), 'error' );
    		return false;
    	}
    	return $passed_validation;
    }

    Tienes que cambiar el número 31 por el ID de producto que quieres limitar. Si quieres que sean varios, tienes que cambiar la condición a:

    if ( ! in_array( $product_id, array( 31, 32, 33 ) ) )