New Shopify Certification now available: Liquid Storefronts for Theme Developers

Change the product description on variant selection with theme: pipeline

koakaya
New Member
4 0 0

I'm trying to follow this procedure:

https://docs.minionmade.com/shopify/change-description-based-on-variant-selected-in-shopify 

 

But I understand that 

var selectCallback  is not the right way to go with the theme pipeline. 

 

I''m not sure how to fix it.

 

I've added the following lines at the end of product.liquid and it doesn't work.

 

<script>
var selectCallback = function(variant, selector) {

$('.description').css('display', 'none');
$('#' + variant.id).css('display', 'block');

}
</script>

 

For my product description, I was able to add the HTML with my proper product Variant ID

 

<p class="description" id="44036369187116">Description for variant 1</p>
<p class="description" id="44036369219884" style="display: none;">Description for variant 2</p>

 

Any idea how I can fix this?

Replies 2 (2)
Guleria
Shopify Partner
2787 555 795

Hello @koakaya ,

 

 

First thing, this is an old way to add the variant description.  
To add description with variant you can use variant metafield.

 

Once you will add it then within the code you have to call it ( you can call all at same time within the loop ) and then with the help of JS show/hide a/to the selected variant. 


 

-

Need a Shopify developer? Email: guleriathakur43@gmail.com

,
- Skype: navrocks1
- Try GEMPAGES a great page builder
-Advance Search Filter
koakaya
New Member
4 0 0

ok, i've included metafields instead for my variants... but now how do I trigger to display the metafield variant on selection?