A Product Field is a custom field defined by a User. The data type may be Text, Number, Date/Time, Yes/No, or List.

Text (String) - The value of the field will be a String.

Number (Decimal) - The value of the field will be a Decimal.

Date/Time (DateTime) - The value of the field will be a DateTime.

Yes/No (Boolean) - The value of the field will be a Boolean (either true or false).

List (Array) - The value of the field will be an Array which may contain Strings or Decimals.

Typically, product fields will be accessed using the custom_fields method of a Product, which returns all custom_fields associated with that product.

Properties

name - String - The name of the product field

key - String - The key of the product field

value - Variable - The value of the product field. This will vary depending upon how the product field was defined and may be any of the data types listed above.

show_on_product - Boolean - Whether or not the product field should appear on a product. If looping through product.custom_fields this property is useful to know whether or not this product field was intended to be displayed for Customers, or if it's used as an internal reference for your company.

Retrieving a Value by Product Field Name

In cases where you know the product field name and need to get the product field value, you may use the following syntax:

{{ product.product_field_name }}

For example, if you had a Yes/No product field named "Guaranteed" and its key was "guaranteed", you would write {{ product.guaranteed }} and a true or false value would be returned.

Did this answer your question?