You can use the following filter to remove existing user roles if a user is assigned a new role when purchasing a product:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
|* Remove existing user roles if a user is assigned a new role when purchasing a product|
|add_filter( 'wcmo_remove_existing_roles', '__return_true' );|
This is how to add a snippet.