A custom field is field you can define for orders, order item, invoices, invoice items , products etc to store any additional information.
You can access custom fields related to an order, invoice, or customer_bill_to in liquid in custom forms.
Here are the fields available for custom fields.
field_name: Name of the custom field.
id: An id for the custom field.
You will always get the custom fields related to an object as a list of array.
Here is an example how you would address the custom fields related to an order and then output the value of the custom field by calling the liquid filter method custom_field_data passing in the custom field and the id of the order.
{% for field in order.public_custom_fields_list %}
{{field.field_name}}: {{field | custom_field_data: order.id}}
{% endfor %}
To show a specific custom field only
{% for field in order.public_custom_fields_list %}
{% if field.field_name == 'My Custom Field Name' %}
{{field | custom_field_data: order.id}}
{{field | custom_field_data: order.id}}
{% endif %}
{% endfor %}
{% endfor %}
Comments and Suggestions
0 comments
Please sign in to leave a comment.
Related articles