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?
Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024In today’s interview, we sat down with @BSS-Commerce to discuss practical strategies f...
By JasonH Nov 13, 2024