Ecommerce Shopify WordPress Discussion

Fetching Metafields Shopify Liquid

I'm trying to fetch metafields in main-product.liquid file of dawn theme to display some custom fields. This metafield is applied on variants {% assign metafield = product.metafields namespace.key| json %} Value: {{ metafield.value }} This code is not fetching metafields. Is there anything wrong with the liquid code
Assuming your product has metafields, then you could use the code: {% assign metafield = product.metafields.namespace.key | json %} Value: {{ metafield }} Note here that a key has a value. So in your experiments you may also try something like this: {% assign metafield = product.metafields.namespace.key %} Value: {{ metafield.value | json }} But you should note that since your value may have been originally stored as JSON, there is no point in running it through the json filter. You can just see that the value you got was json and therefore your JS code will consume it fine. Example? {% assign metafield = product.metafields.namespace.key %} Value: {{ metafield }} There are some, shall we say, inconsistencies when using Metafields that you can expose to yourself in 2 minutes of testing!

December 30, 2023

TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.