Liquid as Primary Template Language


Liquid is an open-source template language for flexible web apps.

A Liquid template defines how to transform JSON output and supports more complex JSON transformations, such as iterations, control flows, variables, and so on.

The Liquid templating language makes it simple to write dynamic page templates for an e-commerce project.

Virto Commerce uses Liquid to perform advanced Object (JSON) transformations in:

Liquid template basic

In your Liquid template, you can use features of Liquid and access to all C# properties.


Objects tell Liquid where to show content on a page. Objects and variable names are denoted by double curly braces: {{ and }} .

{{ customer_order.number }}

In this case, Liquid is rendering the content of an object called customer_order.number ,


Tags create the logic and control flow for templates. They are denoted by curly braces and percent signs: {% and %} .

The markup used in tags does not produce any visible text. This means that you can assign variables and create conditions and loops without showing any of the Liquid logic on the page.

{% if customer_order.numbre %}
  Order Number - {{ customer_order.number }}
{% endif %}
{% for line_item in customer_order.number %}
Name: {{ }} 
Price:{{ line_item.placed_price | round: 2 }} 
Quantity: {{ line_item.quantity }}
{% endfor %}

Tags can be categorized into three types:


Filters change the output of a Liquid object. They are used within an output and are separated by a | .

{{ line_item.placed_price | round: 2 }} 

More details about Liquid filters you can find here.

Multiple filters can be used on one output. They are applied from left to right.


{% for line_item in customer_order.items %}
Name: {{ }} 
Price:{{ line_item.placed_price | round: 2 }} 
Quantity: {{ line_item.quantity }}
{% endfor %}
Parcels tracking numbers:
{% for shipment in customer_order.shipments %}
{{ shipment.number}}
{% endfor %}