Fields & Variables
    • PDF

    Fields & Variables

    • PDF

    Article summary

    As the Fields and Variables navigation areas contain related elements, you will find information and examples for both areas here.

    Fields

    This section contains question and answer fields as well as operators with which you can retrieve or change the value of a specific field (e.g. a product).

    • Select a question: Element to call up a specific question in the questionnaire.

    • Select an answer: Element to retrieve a specific answer from the questionnaire.

    • get-of: Enables referencing to specific objects or properties (attributes) of objects.

    • Set-of-to: Enables the property of objects to be set to a specific value.


    Variables

    Variables are used to store a value that can change (i.e. is variable).

    • get: Expression with which the value of a variable is accessed.

    • set-to: Expression with which the value of a variable is influenced or a new variable is generated.

    ⚠️ Note on the configuration of the following examples

    The following examples show exemplary rules. In order to display the result of a rule (i.e. the content of a created field) on the result page, the field must always also be configured via the Result Page workbench navigation item. For the sake of clarity, we do not show this step in the examples. Please refer to the related article.


    Example 1: Creating / changing variable values

    In this example, the value of the variable product_count is set to the value 5 (see the number field "1" from the navigation point Math). Here, the variable can be an attribute from the product data.

    If the product_count variable does not yet exist (i.e. is not part of the product data), it is created automatically when the element is used. You can freely choose the name of the variable. Avoid spaces in of the name.


    Example 2: Accessing variable values

    In this example, the value of the user-defined variable product_count is queried. According to example 1, the result of the query in this case would be 5.


    Example 3: Create / change product attributes

    In the following example, we look at the creation of the number attribute.

    Rule: All products from the list of product data are checked in a loop. The user-defined attribute number  is created and set to the numerical value 1 for all products recommended on the result page.

    • for each: Loop operator that loops through and checks all elements of a group.

    • product: User-defined name. It is important that the same name is used for a specific variable both in for-each and in the set-of-to element (here in the example: product).

    • get-products: The platform uses this element to access the list of product recommendations.

    • set-number-of-product-to: Command with which a specific value is assigned to the user-defined number field.

    • "1": Number field with the fixed value 1. The value can be adjusted by editing the field.

    1. Open the Loop navigation item and drag the for-each-item element into the workspace.

    2. Click in the item field and type in product.

    3. Switch to the Variables navigation item and drag the get element next to for-each-product. Enter products in the empty field (so that the loop runs through all products).

    4. Switch to the Fields navigation item and drag the set-of-to element next to the do element.

    5. Type the name of the attribute you want to create into the first empty field (example: number).

    6. Enter the same expression in the second empty field as in the for-each element (example: product).

    7. Switch to the navigation point Math and drag the element "1" next to set-number-of-product-to.


    Example 4: Assigning a calculated value to product attributes

    In the following example, we imagine that if you buy more than 5 brushes, one brush is free. If you enter 6 brushes, 7 brushes will be displayed on the results page.

    Rule:

    All products from the list of product data are checked in a loop.

    IF the number of brushes required is greater than 5, THEN the Number attribute is filled with the value from the calculation [Number of brushes] + 1.

    Configuration as video:


    Example 5: Delete products with a specific attribute from the recommendation

    In the following example, we want to ensure that all products containing the value white ("weiß") in the attribute color ("Farbe") are removed from the recommendation. The attribute color is part of the imported product data.

    Rule:

    All products from the list of product data are checked in a loop.

    IF the product attribute color contains the value white ("contains"), THEN all products that contain this value are removed from the recommendation (in other words: no more recommendations for white color appear on the results page).

    1. Open the Loop navigation item and drag the for-each-item element into the workspace.

    2. Click in the item field and type in product.

    3. Switch to the Variables navigation item and drag the get element next to for-each-product. Enter products in the empty field (so that the loop runs through all products).

    4. Switch to the Logic navigation point and drag the do-if element next to the do element.

    5. Drag the contains element next to the if element.

    6. Switch to the Fields navigation item and drag the get-of element next to the contains element. In the free field, enter the name of the attribute that the platform should search for the value (example: color).

    7. Switch to the Variables navigation point and drag the get element next to the get-of element. Enter the same value in the free field as in the loop element (example: product).

    8. Switch to the navigation point Text and drag the element My text below the element get-color-of-get product. Type in the value you are looking for (example: "weiß", which means white).

    9. Switch to the navigation point Post Processor and drag the element remove-recommendation next to the element do.

    10. Right-click to copy the element get-products from the first line and paste it next to remove-recommendation.


    Was this article helpful?

    What's Next