Custom object (JSON) fields

Defining a field as a custom object allows you to enter field values as JSON objects. As long as you adhere to valid JSON syntax, you are free to define anything you like in your very own structure.

Lets say you have defined a JSON field with this content:

{
  "make": "Audi",
  "name": "RS6" 
}

Using this custom object in Liquid is straightforward:

{% assign car = product.metafields.accentuate.car_specs %}

<p>My car is a {{ car.make }} {{ car.name }}</p>

If you need the custom field as a client-side Javascript variable, use the JSON filter:

</script>
  let car = {{ product.metafields.accentuate.car_specs | json }}
  alert('My car is a ' + car.make + ' ' + car.name);
</script>
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us