Custom Liquid filters

Filters are simple methods that modify the output of numbers, strings, variables, and objects. They are placed within an output tag {{ }} and are denoted by a pipe character |. In addition to the standard filters, Stockeo also provides custom filters.

json_parse, parse_json

Allows parsing string in a format compliant with JSON file requirements into an object. It enables access to individual fields within the object using dot or bracket notation.

Usage example: Assume that individual product nodes don't contain category names, but only a category_id.

<?xml version="1.0" encoding="UTF-8"?>
<shop>
    <categories>
        <category>
            <id>101</id>
            <name>Electronics</name>
        </category>
        <category>
            <id>102</id>
            <name>Clothing</name>
        </category>
        <category>
            <id>103</id>
            <name>Home and Garden</name>
        </category>
    </categories>
    <products>
        <product>
            <name>Wireless Headphones</name>
            <sku>ELEC-001</sku>
            <category_id>101</category_id>
        </product>
        <product>
            <name>Sports T-Shirt</name>
            <sku>SPORT-002</sku>
            <category_id>103</category_id>
        </product>
    </products>
</shop>

If you want to add categories as tags, you can create a formula that creates an object with key-value pairs, so-called dictionary variable. In this case, keys are categories ids, and values - their names. With the formula below, the category name will be found by its ID:

Last updated