Assigning a variant / returning variant object based off variant.id

Hey All,

I’m trying to assign a variant based off the variant.id / return the variant object based off something. I see that typically the way to do this is ‘product.selected_variant’ however, if I understand correctly this is contingent upon the URL (and with this page I’m not on the product page. If somehow the users could input the variant.id in the {% schema %} even better.

Background of the project is I’m working on a product recommendations quiz, and for the ‘quiz results / product comparison’ page I want to have 2 static selected variants to compare to the variant that is filtered / calculated by logic (still haven’t figured out how I’m going to pass in that variant.id either). Why I need to assign the variant is because I have a metafield data that is stored on a variant basis that I’m displaying to compare the variants.

Let me know! I’d prefer to do it with liquid if possible too and not run too much JS logic.

Thanks!