Can you explain more about it, you want to check when variant changes and add function to it.
Please send me site link, I will help you check where JS is added to the changed variant.
Hope it helps!
I do not want to "check when variant changes and add function to it." I want to write a function that changes which variant is selected without just redirecting to another page on the website.
The production version of the website doesn't have any relevant code to this question currently. I've been working in a copy of the theme.
Please send your site and if your site is password protected, please send me the password. I will check it.