Shopify themes, liquid, logos, and UX
Hi 🙂 hope somebody here can help me out.
I am new to shopify, and I am trying to create metafields for my product variation. More specific, trying to get it to show a description for each product variation.
I have spend a long time and now it finally shows up on the page with the following liquid code:
{%assign current_variant = product.selected_or_first_available_variant%} {{current_variant.metafields.custom.varient_description}}
But the problem now is:
1) I do not know how to get the code to reloade and change the text for the variant, when you click to select a new variant. The only time the code above reloads is when you refresh the browser. How do I do it?
2) How do I get it to not show text, if the metafield data is not filled out on a product variation?
Thanks in advance!
1) Liqiud code only runs on Shopify servers, and visitors browser receives a rendered HTML file which can then be updated by the theme Javascript code.
So, to update this field on your page you need to add some JS code to do it to your theme and this will depend on what theme you have.
2) you can do it like this:
{% assign current_variant = product.selected_or_first_available_variant %}
{% assign value = current_variant.metafields.custom.varient_description | strip %}
{% unless value == blank %}
{{ value }}
{% endunless %}
If you don't feel like coding you may consider an App for this: https://apps.shopify.com/dynamic-variant-description
Oh thank you Tim. I am supposed to put that under the product–code file then?
Hey Community! As we jump into 2025, we want to give a big shout-out to all of you wh...
By JasonH Jan 7, 2025Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024