Only one product per cart

By

/**
 * Hook: Empty cart before adding a new product to cart WITHOUT throwing woocommerce_cart_is_empty
 */
function func_empty_cart_before_add( $cart_item_data ) {
 
    global $woocommerce;
    $woocommerce->cart->empty_cart();
    return true;
}
add_filter( 'woocommerce_add_to_cart_validation', 'func_empty_cart_before_add' );

Enable WooCommerce Add to card behaviour