Variants - Link product options

TyW
Community Manager
Community Manager
418 40 1142

 


Update secondary menus in line with the current selection, to avoid showing unavailable combinations of options when a customer is choosing from multiple menus. In short, you don't want your customers to encounter this:

 

link-01.jpg


When your store's visitors make a selection in the first drop-down, you want the values in the second drop-down right below to be updated to list only those values that are available in combination with their first selection.

 

If a product has three options, you want the same to happen when one selects a value in the second drop-down. You want the values in the third drop-down to be updated to only list values that are available in combination with the two selections made above.

 

This works from top to bottom. Think of the typical "select a country then select a town" scenario. Selecting a country in the first country element updates the second town element to only contain towns found in that country.

 

Shopify does not give you linked options out of the box. It makes all choices in all drop-downs available. For example, all possible sizes will be listed in your Size drop-down and all colors will be listed in your Color drop-down, regardless what combinations exist or are in stock.

 

Linked options can be added to your theme in two steps.

 

  1. From your Shopify admin, go to Online Store > Themes.
  2. Find the theme you want to edit, and then click Actions > Edit code.
  3. Under Snippets, click the link Add a new snippet.
  4. Name your new snippet linked-options.

    link-02.png

  5. In your new snippet file, paste this code hosted on GitHub.
  6. Click Save.
  7. Under Layout, locate the file theme.liquid, and click it to open it in the code editor.
  8. Near the end of the file, right before the closing </body> tag, paste the following code:

    {% render 'linked-options' %}

    link-03.png

  9. Click Save.

TyW | Online Community Manager @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

Replies 59 (59)
VinnyG
Tourist
3 0 1

I am very new to this but i followed the instructions exactly as posted and it is still offering options and showing them as unavailable.  I am using the venture theme if that matters.  Thank you in advance for your assistance.

JayCDD
Tourist
4 0 6

Has anyone been able to find a workaround with this for Themes where it doesn't work? Im currently using the Warehouse theme from Maestroo and it does not work with square icons or drop down list. Please help lol

bsambell
New Member
1 0 0

Is there a solution for those of us that use Venture theme? Please help!

circular78
Tourist
11 0 2

@JayCDD wrote:

Has anyone been able to find a workaround with this for Themes where it doesn't work? Im currently using the Warehouse theme from Maestroo and it does not work with square icons or drop down list. Please help lol


Hi ,

 

I am also looking for answers. Using the same Warehouse theme  as @JayCDD . Hopefully , somebody can help.

cristian_c
Tourist
6 0 11

Hey guys,

I am looking for a solution to this problem for Debut theme.

I really believe this should be solved by Shopify already, i have seen many post on this same subject, and it simply makes no sense to display options that are not available.

Padster
Explorer
49 5 14

Hi there,

 

Unfortunately if doesnt seem to be working on the narrative theme...any ideas!? Any help would be greatly appreciated.

& for everybody else reading this post, theres a great guy on utube outlining this issue & how to make the changes https://www.youtube.com/watch?v=vspWDu_POYA.

 

Regards,

:Paddy

@Padster 

 

 

ndambrosi
Excursionist
14 0 9

I'm searching for this solution for the Debut theme.  Has anyone had any luck or found an app they can recommend to accomplish this? 

Padster
Explorer
49 5 14

Still searching.
How u getting on?

:Paddy

 

ndambrosi
Excursionist
14 0 9

Not yet.   I might check it out and see how it works.

 

For now, I've gone to my translations and I've changed "Unavailable" to "Invalid product combination" as well as labeling the options a little more clearly so the user can understand which sizes in Menu 2 apply to each of the selections from Menu 1.  

samnamiam
New Member
1 0 6
ndambrosi
Excursionist
14 0 9

Yes, this code is working for me!  Thanks so much!

Padster
Explorer
49 5 14

That one didn't work for me...here's a good video talking u thru it tho for any 1  that wants 2 know - https://www.youtube.com/watch?v=vspWDu_POYA.

Going to try a couple other options today....not sure if it some additional code I can see in my product.liquid ...anyone any ideas?

Any Shopify experts?? ; ) ; ) @TyW 

 

{% comment %}

The contents of the product.liquid template can be found in /sections/product-template/
{% endcomment %}

{% section 'product-template' %}
{% section 'product-recommendations' %}

<script>
window.theme = window.theme || {};
window.theme.strings = window.theme.strings || {};

// Override default values of theme.strings for each template.
// Values are used by JavaScript only; Liquid must be updated separately
window.theme.strings.addToCart = {{ 'products.product.add_to_cart' | t | json }};
window.theme.strings.soldOut = {{ 'products.product.sold_out' | t | json }};
window.theme.strings.unavailable = {{ 'products.product.unavailable' | t | json }};
</script>

 

 

 

Padster
Explorer
49 5 14

Hoooraaaaay!!! I've dun it...[applause]

 

So i followed the youtube above then did wot fella described (im using the narrative theme FYI):

 

"For those of you who are having issues with the default variant not loading and requiring the user to select a variant before the script fires:

This is what worked for me on the Shopify Debut Theme.

Find the following code:
Shopify.linkOptionSelectors({{ product | json }});

It is located in the following if statement

{% if product.available and product.options.size > 1 %}
...
Shopify.linkOptionSelectors({{ product | json }});
...
{% endif %}

Simply move it directly outside of the if statement:

{% if product.available and product.options.size > 1 %}
...
// Line removed from here
...
{% endif %}

// Line added here
Shopify.linkOptionSelectors({{ product | json }});

 

& badabing badaboh! 
SKILLz, cash monies dollar dollar bills coming my way (quickly converted to $btc & $doge ; )

Goodluck : P

ps. shopify community is changing some of the html 4 sum reason so dont copy from here...checkout the comments at https://gist.github.com/jonathanmoore/c0e0e503aa732bf1c05b7a7be4230c61 post Mar 14, 2018

jpeltier78
New Member
1 0 0

Performed exactly as expected. Thank you!

danielagsb
Explorer
78 0 17

Hi! has anyone managed to make it work for the boundless theme? Thank you

Padster
Explorer
49 5 14

https://community.shopify.com/c/Shopify-Design/Linking-product-Options-and-Hiding-Sold-Out-Variants-...

 

may be this will help. Something to do with dropdowsn vs swatches etc...

 

Goodluck 😛

Kishori
Shopify Expert
1 0 0

Thank you, this amazingly worked for me in debut theme.

Darren_Murtha
Shopify Partner
4 0 1

I got this to partially work with a 3rd party theme that uses buttons instead of dropdowns.  In the first option, all the buttons change their color to indicate they have been clicked but if I changes to any other value in the first option, the buttons don't light up on the 2nd and 3rd options.   Where should I look? Anyone else encounter this or know what to change?