How do Filters work in Notifications/Popups?

Understanding Filters: Modifying Variable Outputs in Notifications and Pop-ups

How Do Filters Work In Notifications/Popups?
Filters In Template In ToastiBar - Sales Popup App

Filters are tools used to modify the output of variables within notifications or pop-ups. They are applied by inserting them after the variable and are denoted by a pipe character (|). The filters available in this context are:

  1. mask: This filter is used to mask or hide certain information. When applied, it obscures the content of the variable, providing a level of privacy or security.

    Syntax: {{ variable | mask: mask_char, start_count, end_count }}
    Example: {{ first_name | mask: *, 1, 1 }} will output a masked version of the first_name variable, with the first character revealed, the last character revealed, and the rest masked with the * character. For instance, if the first_name is “Robert,” the output would be R****t.

  2. upcase / uppercase: These filters convert the variable’s output to uppercase. This can be useful for standardizing the appearance of text.

    Syntax: {{ variable | upcase }} OR {{ variable | uppercase }}
    Example: If the variable contains the text “Boston” or “boston” then {{ city | upcase }} OR {{ city | uppercase }} will output “BOSTON” as it converts all the characters in the variable to uppercase.

  3. downcase / lowercase: These filters convert the variable’s output to lowercase. Similar to the uppercase filters, they help standardize text appearance.

    Syntax: {{ variable | downcase }} OR {{ variable | lowercase }}
    Example: If the variable contains the text “United States” or “UNITED STATES” then {{ country | downcase }} OR {{ country | lowercase }} will output “united states” as it converts all the characters in the variable to lowercase.

  4. fallback: This filter is used to provide a fallback value in case the variable is empty or undefined. It allows you to set a default value that will be used if the original variable lacks content.

    Syntax: {{ variable | fallback: Default Value }}
    Example: If the variable is defined and has a value, the expression will output the value of the variable. If the variable is undefined or null, it will fall back to the specified “Default Value” and display that instead. For instance, {{ first_name | fallback: Someone }} will display the value of the variable first_name. If first_name is blank, undefined, or null, it will fall back to “Someone” and display that as the output.

  5. truncate: This filter cuts down the length of a value of variables to a set maximum character count, which is useful for displaying concise text snippets. It maintains readability by intelligently trimming excess characters and optionally adding an ellipsis (…) to denote truncation.

    Syntax: {{ variable | truncate }}
    When the character count is not mentioned, then it will consider 30 characters.

    Syntax: {{ variable | truncate: character_count }}
    Example: {{ first_name | truncate: 3 }} will output a truncated version of the first_name variable, limiting it to a maximum of 3 characters. If first_name is “William” the output would be “Wil…”.

You can use two or more filters on a single variable as well. For example,
{{ variable | mask: *, 1, 1 | upcase | fallback: Default Text }}

Let’s break down the specified filters for each type of notification:

  • Sales Notification:
    Variables: first_name, city, province, country, product_with_link, product, and pos_location_name
  • Cart Notification:
    Variable: item
  • Product Reviews Notification:
    Variables: first_name, location, product_with_link, and product
  • Low Inventories Notification:
    Variable: product_title

Filters allow for dynamic and customizable presentation of information based on specific requirements or preferences.

Please make sure to click on the Save button after making any changes.