"This" Object Fields

The "this" object can be accessed on Product detail/item.liquid, list/item.liquid and attribute layout files. It contains the properties of the current Product and contains further relevant objects e.g. Price.

The entire "this" object can be outputted on the page for reference:

{{this | json}}


The following fields are available:

Field Name: Name
Liquid Tag: {{this.name}}
Description: The Product's name

Field Name: Item Slug
Liquid Tag: {{this.slug}}
Description: The part of the URL for this Product's Detail Page which refers directly to this Product

Field Name: Creation Date
Liquid Tag: {{this.create_date}}
Description: The date the Product was created in Admin.

Field Name: Last Edit Date
Liquid Tag: {{this.last_edit_date}}
Description: The date this Product was last edited in Admin.

Field Name: Release Date
Liquid Tag: {{this.release_date}}
Description: The date this Product is scheduled for release, or was first released on the Site. (A Product will not appear in the list if it has not been released.)

Field Name: Expiry Date
Liquid Tag: {{this.expiry_date}}
Description: The date this Product will be no longer visible on the Site. (A Product will not appear in the list if it has expired.)

Field Name: Enabled
Liquid Tag: {{this.enabled}}
Description: A "true" or "false" boolean value. If "false", the Product will not appear in the list.

Field Name: Category Array
Liquid Tag: {{this.category_array}}
Description: An array of ids of categories associated with this Product.

Field Name: Description
Liquid Tag: {{this.Description}}
Description: A description of the Product.

Field Name: Image
Liquid Tag: {{this.Image}}
Description: This is the main image for the Product, but more can be added with Custom Field Sets.

Accessing Custom Field Sets

Custom Field Set data linked to Products is available in Product detail/item.liquid, list/item.liquid and attribute layout files.

Any Custom Field Sets that have been associated with the product will be stored under:

{{this.cfs_data}}

You can output the above liquid in the item.liquid file to see all of Custom Field Sets associated with the Product. Each of these will have the key "cfs_1", "cfs_2" etc.

For example, a developer has created just one Custom Field Set to store information about the Guarantee on the Product.

The field can be accessed via:

{{this.cfs_data.cfs_1.Guarantee}}

See more information about Custom Field Sets here.

The Price Object

The Price object contains all the information you need to display the Product's price in the format you want. It is available in Product detail/item.liquid, list/item.liquid and attribute layout files.

Field Name: Price ID
Liquid Tag: {{this.price.id}}
Description: The unique ID of this Product's price.

Field Name: Product ID
Liquid Tag: {{this.price.product_id}}
Description: The unique ID of the Product this Price belongs to.

Field Name: Currency
Liquid Tag: {{this.price.currency}}
Description: The currency code for the currency used by this Product e.g. "GBP".

Field Name: Price Charge
Liquid Tag: {{this.price.price_charge}}
Description: The price of the Product as an integer e.g. for the price "£200.00" this field will display "20000"

Field Name: Display Price
Liquid Tag: {{this.price.price_display}}
Description: If the optional field Display Price was filled out when the Product was created, this will show that price as an integer, else, it will output null. This could be for example the RRP or price before tax.

Field Name: Currency Symbol
Liquid Tag: {{this.price.currency_symbol}}
Description: The HTML entity for the currency symbol. e.g. "£" outputted on the page will display "£" when HTML is rendered.

Field Name: Price Display Formatted
Liquid Tag: {{this.price.price_display_formatted}}
Description: If the optional field Display Price was filled out when the Product was created, this will show that price as an decimal number, else, it will output null. This could be for example the RRP or price before tax.

The Inventory Object

The Inventory object contains the fields related to the current Inventory of this Product. It is available in Product detail/item.liquid, list/item.liquid and attribute layout files.

Field Name: Inventory ID
Liquid Tag: {{this.inventory.id}}
Description: The unique ID of the object containing the Product's Inventory.

Field Name: Enabled
Liquid Tag: {{this.inventory.enabled}}
Description: A "true" or "false" boolean, defaults to true.

Field Name: Product ID
Liquid Tag: {{this.inventory.product_id}}
Description: The unique ID of the Product this Inventory Object belongs to.

Field Name: Quantity
Liquid Tag: {{this.inventory.quantity}}
Description: The number of products in the inventory.

Field Name: Inventory Type
Liquid Tag: {{this.inventory.inventory_type}}
Description: The type of Inventory. Currently, only "Global" is available.

Field Name: Display Type
Liquid Tag: {{this.inventory.display_type}}
Description: This stores the policy on what to do when the Inventory reaches zero. Either the Product can not be ordered, or it should be hidden from view.

The Attributes Object

These are available once Attributes have been added against the Product in Admin and you are inside a detail/item.liquid file or an Attribute layout file.

You can access the Attributes Object via the following liquid output:

{{ this.product_attribute_options }}


Inside the Attribute Layout

Output Options for this Layout

Inside the Attribute Layout, you can access just the Options for that specific Attribute:

{{ product_attribute_options }}

Output this Attribute's Name

You can also access the name of the Attribute this Layout is currently displaying:

{{this_attribute.properties.name}}

Looping Over Attribute Options and Accessing Option Fields


As explained in the Attributes Layout Doc, we recommend you loop over the object and access the fields via the "option" liquid variable.

<select name="attr1" class="form-control" data-attribute-control="{{product_attribute_id}}" onchange="s_e_update_price()">
  {% for option in product_attribute_options %}
    <option value="{{option.id}}" data-attribute-price-control="{{option.price_raw}}">{{option.name}} this.price.currency_symbol}}{{option.price}})</option>
  {% endfor %}
</select>

Assuming the above example liquid forloop has been implemented, you can access the fields in the table below. Remember the "option" liquid variable can be renamed, so if you have done this, replace "option" with the name you have given the variable. The Object contains Attribute Options and each of these contains information on the Attribute it is linked with.

Field Name: Attribute Option ID
Liquid Tag: {{ option.id }}
Description: The unique ID of this Attribute Option

Field Name: Attribute Option Name
Liquid Tag: {{ option.name }}
Description: The name of this Attribute Option

Field Name: Attribute Option Price
Liquid Tag: {{ option.price }}
Description: The price of this Attribute. Note- this price is added to the Product Price when this Attribute is selected, it does not replace the Product Price.

Field Name: Attribute Option Stock
Liquid Tag: {{ option.stock }}
Description: This is not yet available.

Field Name: Attribute ID
Liquid Tag: {{ option.product_attribute.id }}
Description: The Unique ID of this Attribute

Field Name: Attribute Name
Liquid Tag: {{ option.product_attribute.name }}
Description: The Name of the Attribute e.g. Size or Colour

Field Name: Attribute
Liquid Tag: {{ option.product_attribute.product_id }}
Description: The Unique Product ID that this Attribute is associated with.

Related Articles

Did this answer your question?