Basic field types

Accentuate Custom Fields support a wide range of different field type, each with unique characteristics with regard to how you enter values via the editor and to the values they can contain.

Checkboxes

A checkbox can hold two states - checked or unchecked. The metafield value of a checked checkbox is represented as a string value of "true" but an unchecked checkbox will cause the underlying metafield to be deleted rather than contain a value of "false". Accordingly, we can test for it being checked or not this way:

{% if product.metafields.accentuate.backorder %}
  <p>{{ product.title }} can be backordered</p>
{% else %}
  <p>{{ product.title }} can NOT be backordered</p> 
{% endif %}

<input type="checkbox"  {% if product.metafields.accentuate.backorder %} checked {% endif %}>

Numbers

All custom fields are stored as strings - even numeric types like Number to allow for decimal points. Liquid handles this quite nicely with one exception: you cannot do a direct comparison between a number and a string

So this is possible:

<p>We have {{ product.metafields.accentuate.stock | plus: 100 }} in stock</p>

but if you want to do a numeric comparison with field's value beforehand, you need to convert it to a number first, like this:

{% assign in_stock = product.metafields.accentuate.stock | plus: 0 %} 

{% if in_stock < 5 %}
  <p>We are low on stock, but we if we buy more, we have {{ in_stock | plus: 100 }}</p>
{% endif %}

Note the " | plus: 0" which converts the string into a number type in Liquid

Dates

A custom field of type Date can be subject to date filters in Liquid

{{ product.metafields.accentuate.publishdate | date: "%a, %b %d, %y" }}

Text

The value of text based custom fields are represented as you may expect - as metafields with string values matching the value of their respective custom fields

<h3>{{ product.metafields.accentuate.subtitle }}</h3>

Markdown

In a Markdown type field, you can enter text in Markdown syntax, which ACF will render as HTML into the metafield. Both your original Markdown and the rendered HTML are available via properties like this:

<h3>{{ product.metafields.accentuate.my_markdown_title.html }}</h3>  
<p>The title was rendered from this Markdown: "{{ product.metafields.accentuate.my_markdown_title.markdown }}"</p>

Selections

A selection list, where you have opted for a single selection only, is represented as a metafield with its string value matching the selected value

<p>You have selected the value: {{ product.metafields.accentuate.selection }}</p>

Basically, the same thing applies for a selection list, where you have opted for multiple selections, but since we can have multiple value selected at any given time, each value is listed with the "pipe" symbol ("|") as a separator token. You can use Liquid's 'split' filter on the metafield to separate the values - like this:

{% assign selected_values = product.metafields.accentuate.selection | split: '|' %}
{% for selected_value in selected_values %} 
  <p>{{ selected_value }}</p> 
{% endfor %}

Tags

Tags behave similar to selections (see above) with the only difference being that you define the values for every instance of your Shopify object as opposed to the selection lists' predefined options. A tag field, where you have entered only a single value, is represented as a metafield with its string value matching your input and as with selections, if you have entered multiple values, each value is listed with the "pipe" symbol ("|") as a separator token. Again, You can use Liquid's 'split' filter on the metafield to separate the values.

Colors

A Color type gives you a convenient control to select a color and store the result as a string in hex RGB format such as #000000, #e9e9e9, #ffffff etc. Note that you can use Liquid color filters to change or extract properties from these color strings - more info here

<button style="background-color: {{ product.metafields.accentuate.my_color }}">Click</button>
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