Liquid filters for product feeds
Liquid filters modify the output of strings, numbers, variables, and arrays in your product feed. They are placed within {{ }}
brackets and separated by a |
(pipe) symbol.
Why use modifiers?
- Optimize feed data: format text, remove unnecessary details, and ensure consistency.
- Improve readability: make product attributes easier to understand for customers.
- Ensure platform Compatibility: adjust data to meet marketplace requirements.
String & HTML filters
These filters help format text values in your feed.
lowercase
Converts text to lowercase.
Example
{{ product.name | lowercase }}
Input: Dash Digital Watch
Output: dash digital watch
uppercase
Converts text to uppercase.
Example
{{ product.name | uppercase }}
Input: Dash Digital Watch
Output: DASH DIGITAL WATCH
replace
Replaces a word or phrase.
Example
{{ product.name | replace: 'Digital', 'Analog' }}
Input: Dash Digital Watch
Output: Dash Analog Watch
append
Adds text at the end.
Example
{{ product.name | append: ' - Best Choice' }}
Input: Dash Digital Watch
Output: Dash Digital Watch - Best Choice
prepend
Adds text at the beginning.
Example
{{ product.name | prepend: 'Best Choice - ' }}
Input: Dash Digital Watch
Output: Best Choice - Dash Digital Watch
capitalize
Adds text at the beginning.
Example
{{ product.color | capitalize }}
Input: dark red
Output: Dark red
escape
Escapes HTML characters.
Example
{{ product.description | escape }}
Input: <p>This is a <strong>great</strong> product! <a href="https://example.com">Check it out</a>.</p>
Output: <p>This is a <strong>great</strong> product! <a href="https://example.com">Check it out</a>.</p>
nl2br
Replaces newlines (\n
) with <br>
tags.
Details
{{ product.short_description | nl2br }}
Input:
This is the first line.
This is the second line.
This is the third line.
Output: This is the first line.<br>This is the second line.<br>This is the third line.
remove
Removes a specific word.
Details
{{ product.name | remove: 'Digital' }}
Input: Dash Digital Watch
Output: Dash Watch
stripHtml
Removes all HTML tags.
Details
{{ product.description | stripHtml }}
Input: <p>This is a <strong>great</strong> product!</p> <p>It has <a href="https://example.com">amazing features</a>.</p>
Output: This is a great product! It has amazing features.
newline_to_br
Converts \n
to <br>
.
Details
{{ product.description | newline_to_br }}
Input: This is a great product!
It has amazing features.
Enjoy the best experience ever.
Output: This is a great product! It has amazing features.
truncate
Truncates text to a specific character length.
Details
{{ product.name | truncate: 15 }}
Input: Dash Digital Watch
Output: Dash Digital Wa
truncatewords
Truncates text to a specific number of words.
Details
{{ product.name | truncatewords: 2 }}
Input: Dash Digital Watch
Output: Dash Digital
plain
Converts text to a plain format, removing styles.
Details
{{ product.description | plain }}
Input: <p>This is a <strong>great</strong> product!</p> <p>It has amazing <em>features</em> and comes with a <a href="#">warranty</a>.</p>
Output: This is a great product! It has amazing features and comes with a warranty.
ifEmpty
Returns a default value if the field is empty.
Details
{{ product.color | ifEmpty: 'Multicolor' }}
Input: " "
Output: "Multicolor"
html_entity_decode
Convert HTML entities to their corresponding characters.
Details
{{ product.color | ifEmpty: 'Multicolor' }}
Input: I'll "walk" the <b>dog</b> now.
Output: I'll "walk" the <b>dog</b> now.
html2plain
Converts any text into a plain, clean format by removing unnecessary elements like HTML tags, excessive spaces, and template placeholders.
Details
{{ product.color | ifEmpty: 'Multicolor' }}
Input: <b>Hello</b> World! {{block type="cms/block"}}
.
Output: Hello World!
clean
Removes invalid and non-printable UTF-8 characters from a string, ensuring it contains only valid, readable text.
Details
{{ product.color | ifEmpty: 'Multicolor' }}
Input: Hello\xF0\x28\x8C\x28World!
Output: HelloWorld!
Date & JSON filters
These filters modify date formats and convert objects into JSON.
dateFormat
Returns a default value if the field is empty.
Details
{{ product.created_at | dateFormat: 'd.m.Y H:i' }}
Input: 2016-02-18 10:11:12
Output: 18.02.2016 10:11
json
Converts an object or array to JSON format.
Details
{{ product.gallery | json }}
Input: ['image1.jpg', 'image2.jpg', 'image3.jpg']
Output: ["image1.jpg", "image2.jpg", "image3.jpg"]
Number filters
These filters help you manipulate and format numerical data in your feed.
ceil
Rounds the number up to the nearest integer.
Details
{{ product.weight | ceil }}
Input: 1.423
Output: 2
floor
Rounds the number down to the nearest integer.
Details
{{ product.weight | floor }}
Input: 1.423
Output: 1
round
Rounds the number to the nearest integer or a specified number of decimals.
Details
{{ product.weight | round: '2' }}
Input: 1.423
Output: 1.42
{{ product.weight | round }}
Input: 1.423
Output: 1
numberFormat
Formats a number using a specified format (similar to the PHP number_format
function).
Details
{{ product.price | numberFormat: '2', '.', ',' }}
Input: 1000.54321
Output: 1,000.54
Price & currency filters
These filters help you format prices and handle currency conversions.
price
Formats the product price to the default format.
Details
{{ product.price | price }}
Input: 100.4200
Output: 100.42
convert
Converts a price from the base currency to the specified currency.
Details
{{ product.price | convert: 'EUR' }}
Input: 100
Output: 92.28
inclTax
Adds tax to the product price.
Details
{{ product.price | inclTax | price }}
Input: 100
Output: 120 (if tax rate is 20%)
exclTax
Removes tax from the product price.
Details
{{ product.price | exclTax | price }}
Input: 120
Output: 100 (if tax rate is 20%)
Mathematical operations
These filters help perform basic arithmetic operations on numbers.
plus
Adds a specified value to the number.
Details
{{ product.price | plus: '2' }}
Input: 100
Output: 102
minus
Subtracts a specified value from the number.
Details
{{ product.price | minus: '2' }}
Input: 100
Output: 98
times
Multiplies the number by a specified value.
Details
{{ product.price | times: '2' }}
Input: 100
Output: 200
divided_by
Divides the number by a specified value.
Details
{{ product.price | divided_by: '2' }}
Input: 100
Output: 50
modulo
Returns the remainder after dividing by a specified value.
Details
{{ product.price | modulo: '2' }}
Input: 100
Output: 0
Array filters
These filters allow you to manipulate and access elements within an array.
first
Returns the first element in the array.
Details
{{ product.images | first }}
Input: ['image1.jpg', 'image2.jpg', 'image3.jpg']
Output: image1.jpg
last
Returns the last element in the array..
Details
{{ product.images | last }}
Input: ['image1.jpg', 'image2.jpg', 'image3.jpg']
Output: image3.jpg
join
Joins all elements in an array into a single string using a specified separator (glue).
Details
{{ product.images | join: ', ' }}
Input: ['image1.jpg', 'image2.jpg', 'image3.jpg']
Output: image1.jpg, image2.jpg, image3.jpg
count
Returns the number of elements in the array.
Details
{{ product.images | count }}
Input: ['image1.jpg', 'image2.jpg', 'image3.jpg']
Output: 3
select
Selects values for a specified key from the array.
Details
{{ product.options | select: 'color' }}
Input: [{ "color": "red" }, { "color": "blue" }]
Output: ['red', 'blue']
URL filters
These filters allow you to return URLs with different security protocols and base URLs.
secure
Returns a secure URL using https://
.
Details
{{ product.url | secure }}
Input: www.example.com/product
Output: https://www.example.com/product
unsecure
Returns an unsecure URL using http://
.
Details
{{ product.url | unsecure }}
Input: www.example.com/product
Output: http://www.example.com/product
mediaSecure
Returns a media URL using the secure base URL for user media files.
Details
{{ product.image | mediaSecure }}
Input: image1.jpg
Output: https://www.example.com/media/image1.jpg
mediaUnsecure
Returns a media URL using the unsecure base URL for user media files.
Details
{{ product.image | mediaUnsecure }}
Input: image1.jpg
Output: http://www.example.com/media/image1.jpg
Image filters
These filters allow you to manipulate image properties.
resize
Resizes an image to a specified width and height.
Details
{{ product.image | resize: '300x300' }}
Input: image1.jpg
Output: Resized image to 300px x 300px.