How to get Option 1 variant value within the Option 2 loop

MelonCiroc
New Member
4 0 0

Hello, 
I'm trying to get the Option 1 variant value on the product page, and depending on what is selected, I would like to render a specific header for Option 2.  

MelonCiroc_0-1608282101952.png

 

I would ideally like to do this without deeplinking.  Is there a way to set an outer variable, or use javascript/jquery to get the "is-selected" element?  

0 Likes
r8r
Shopify Expert
2067 242 710

You'll probably have to go through JS here. I usually like to render all elements that might be displayed at any point and hide them upon page load. Depending on what option is selected, I then do the show/hide toggling through JS. Makes sense?

Mario

★ Ja, man kann mich buchen; schreib mir eine Nachricht!
★ Hinterlass gerne ein Like und markiere meine Antwort gegebenenfalls als Lösung. Ich freue ich mich immer über eine Spende an die (Kinder)krebshilfe oder eine kleine Aufmerksamkeit.
Studio Mitte
0 Likes
MelonCiroc
New Member
4 0 0

Hey appreciate the reply, I'm still a little confused and completely new to liquid.  In what file do I put the javascript?  The toggling makes perfect sense but still stumped on how to get the value of the Option 1 selection.

To clarify, I have 2 options, Option 1 can be "iphone" or "iphone charger".  If Option 1 is "iphone",  I want Option 2 to be labeled something, if Option 1 is "charger" then i want option 2 to be labeled something else.  How do I know/get what the value of Option1 is?

0 Likes
r8r
Shopify Expert
2067 242 710

Hi @MelonCiroc 

how do you define the labels for option2? Wouldn’t they need to be defined in the context of option1 as they depend on it? How many different ones are there?

if you’re not a programmer yourself, it’s gonna be hard explaining this to the point where you can build it. I can build that, but I’d need access to the code and depending on the existing code it might exceed what I can offer here pro bono.

Mario

★ Ja, man kann mich buchen; schreib mir eine Nachricht!
★ Hinterlass gerne ein Like und markiere meine Antwort gegebenenfalls als Lösung. Ich freue ich mich immer über eine Spende an die (Kinder)krebshilfe oder eine kleine Aufmerksamkeit.
Studio Mitte
0 Likes