How to select the current variant using a variant ID

New Member
2 0 1

Hello Shopifiers,

When loading my product page, one of the sizes (M, L, XL) of my product is pre-selected. After clicking on a button located on the product page, I would like to change this selected size by using the variant ID corresponding to another size.

How can I do this?

Thank you!