Shopify » Custom objects (JSON)

A Shopify JSON field works similar to the ACF JSON type, albeit without the restrictions regarding outermost arrays. The type allows you to enter field values as raw JSON. As long as you adhere to valid JSON syntax, you are free to define anything you like in your very own structure. Being a Shopify data type returning a Metafield object, the value property returns the actual value in Liquid. So, if you have a JSON field with this content:

  "make": "Audi",
  "model": "RS6" 

you can use it directly in Liquid:

{% assign car = product.metafields.accentuate.specs.value %}

<p>My car is the brand new {{ car.make }} {{ car.model }}</p>

If you need the custom field as a client-side JavaScript variable, you can do this:

  let car = {{ product.metafields.accentuate.specs.value }}
  alert('My car is the brand new ' + car.make + ' ' + car.model);

Last updated