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" 
}

JSON objects can be as simple or as complex as you need but must still comply with the general 100kB character limit for Shopify metafields. 

If you need to create an array of JSON objects, either use repeatable fields or define the array as a property within the JSON object. An outer-most array is reserved for ACF's handling of repeatable JSON fields.

So this works well:

{
  "colors": ["Red", "Blue", "Green"]
}

while this will cause ACF to split the values after you save them

["Red", "Blue", "Green"]

Using custom objects in Liquid 

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

<p>My car is the brand new {{ 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 the brand new ' + 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