Dynamically selecting a variant

New Member
1 0 0

Hi There

I'm rather new to Shopify so I'm not sure if I'm just completely missing something obvious.

I want to be able to select a product variant via javascript.

So i have the following:


 Which does select the correct variation but doesn't update the product price on the page.

I've had a look for ways to trigger the function which updates the price and come across the option_selection.js but generally find myself getting a bit lost in all the different forum posts.

I've matched the foo variable to the variant ID I need to select, but not sure where to go from there.

Thanks in advance,