Functions for rules and optimisations

How to access to the functions list from the interface? When creating a rule or optimisation or in an attribute's tooltip > "Need function?" link

Note: Dollar signs "$" always frame an attribute name. Being a semi-automatic entry, the second dollar sign is automatically added after the attribute name in the function.

1. Text functions

  • UPPER: Turn all the characters into capitals

Syntax: UPPER($text_field)

Example: I want all the characters sent to the channel field "title" to be in capital letters.

  • LOWER: Turn all the characters into lower-case

Syntax: LOWER($text_field)

Example: I want all the characters sent to the channel field "title" to be in lower-case.

function-lower2.png

  • UPPERWORD: Capitalizes the first letter in a text string and any other letters in text that follow any character other than a letter

Syntax: UPPERWORD($text_field)

Example: I want the first letter of each word to be a capital, in the channel field "title".

function-upperword2.png

  • UPPERSENTENCE: Capitalizes the first letter of each sentence

Syntax: UPPERSENTENCE($text_field)

Example: I want each sentence to begin with a capital, in the channel field "title".

function-uppersentence2.png

  • TRUNC: Limit the number of characters

Syntax: TRUNC($text_field,number of characters)

Example: I want to limit my description to 2,000 characters.

function-trunc.png

  • SMARTTRUNC: Limit the number of characters without cutting off the last word

Syntax: SMARTTRUNC($text_field,number of characters)

Example: I want to limit my description to 2,000 characters without cutting off the last word.

function-smarttrunc.png

function-trunc.png

  • TAIL: Retrieve the last characters of a text string according to the number of characters you specify

Syntax: TAIL($text_field,number of characters)

This function is useful to isolate the last characters of a string and use them as value in my catalogue.

Example: I want to get the last 4 characters of my product type.

function_TAIL.png

  • SPLIT : Divide the content of the values around a character

Syntaxe : SPLIT($text_field,separator, field number)

This function is useful to isolate a part of the text of a string starting from the left of the string in order to isolate this part of text and use it as a value in my catalogue.

Exemple : I want to isolate the the value Plug&Play in the "product_type" field. 

  • $text_field = Plug&Play, SPLIT($text_field, &, 1) => Plug

SPLIT_1.png

  • $text_field = Plug&Play, SPLIT($text_field, &, 2) => Play

SPLIT_2.png

Use quotation mark when using the pipe character as separator.
ex: SPLIT($shortTitles$,"|",1)

  • STRIPHTML: Remove the HTML tag

Syntax: STRIPHTML($html_text_field)

Example: I want to remove the html tags from my description.

striphtml.png

  • DECODEHTML: Decodes special characters from HTML elements.

Syntax: DECODEHTML($html_text_field)

Example: The brands in my catalogue are encoded in HTML (ex: "Pull & Bear") and I want to decode them (ex: "Pull & Bear").

decodehtml.png

  • URLENCODE: Encode the values to send in a URL

Syntax: URLENCODE($text_field)

Example: I want to add the title of my products in the tracking of my URL products.

function-urlencode2.png

  • CATEGORYLEVEL

This function is useful if you have a breadcrumb categorization, ie if you have several levels of categories in the same line.

Ex : Home > Fashion > Shoes > Nike shoes

The function then allows you to select a level and extract it to use it as a final category with your channel in Lengow.

2020-03-03_15h33_30.png

Syntax : CATEGORYLEVEL(2)

With this syntax we get the second value of my category, "Fashion" thanks to the function.

Other syntax : CATEGORYLEVEL(-1)

Here I retrieve the last level of categorization, ie "Nike shoes" thanks to the value "-1" called in the function.

Other syntax : CATEGORYLEVEL(-2)

Allows me to retrieve the penultimate level, ie "Shoes".

Note: There is no need to "call" the catalogue category using the $ symbol because Lengow automatically retrieves the values of the category mapped during the mapping Lengow step.

2. Mathematical functions

  • ROUND: Round a number up/down and define the number of decimals

Syntax: ROUND(number to round up/down,number of figures desired after the decimal point)

Round up/down the number, to the nearest tenth, hundredth...of a decimal number, cutting down to the stated rank then:

  • if the following number is 5, 6, 7, 8 or 9, you increase the last figure of the cut number by 1.
  • if the following number is 0, 1, 2, 3 or 4, you keep the cut number.

To round up to a whole number, mark "0" as "the number of figures desired after the decimal point" or mark ROUND(numbertoround).

Example:

  • To round a price to two figures after the decimal point: ROUND($field_price,2) > If my price is "14.1576" in my product catalogue, it becomes "14.16".

function-round.png

  • To remove decimals of quantity values: ROUND($field_quantity,0) or ROUND($field_quantity) > If my quantity is "4.000" in my product catalogue, it becomes "4".

function-round-sansparametre.png

  • ROUNDUP: To round up to the nearest whole number

Syntax: ROUNDUP(number to round up to the nearest whole number)

Example: I want to round my price up to the nearest whole number:

function-roundup.png

  • ROUNDDOWN: To round down to the nearest whole number:

Syntax: ROUNDDOWN(number to round down to the nearest whole number)

Example: I want to round my price down to the nearest whole number:

function-rounddown.png

  • FORMAT_NUM: Display a price in a format that you can manage to the decimal digit of your choice 

Syntaxe : FORMAT_NUM($price$,decimal digit wanted,"separator wanted")

  • Decimal separator accepted: a point or a comma

Exemple : I want to display a price with two decimal digits

Fonction_Format_NUM.png

You can couple this function with the other mathematical functions.

To do so, check the step "Concatenate several functions". 

The function "ROUND" rounds a price by allowing you to choose the precision, but does not allow you to keep the "0" to have a fixed number of digits after the decimal separator.
FORMAT_NUM allows you the display of this "0".
  • CALC: Perform a calculation

  • Divide: CALC(number1/number2)
  • Multiply: CALC(number1*number2)
  • Addition: CALC(number1+number2)
  • Subtraction: CALC(number1-number2)

"number1" and "number2" can be replaced by "$my_field"

With the assistance of brackets, any calculation can be performed. The function performs the calculations in order of priority.

Example: I want to calculate the reduction percentage of my reduced products.

function-calc1.png

I want to increase my sales price by 10%, round it up to the nearest whole number, and subtract 10 cents.

function-calc4.png

I want to reduce my sales price by 15% and add my shipping costs increased by 5%.

function-calc3.png

  • CURRENCYCONV: Convert a price in another currency

Syntax: CURRENCYCONV(price,iso_code)

Example: I want to convert a price into GBP.

function-currencyconv.png

Conversion rates are based on the European Central Bank (ECB) and are updated once a day.

3. Concatenate several functions

Combine as many functions as you like whilst playing with the brackets!

Example: I want to increase my sale price by 10% and round the result by two figures after the decimal point

Example: I want to limit my description to 2,000 characters and write the text in capitals.

function-truncupper.png

Example: I want to increase my sales price by 10% and convert it into euros.

function-currencyconvcalc.png

Example: The text of my descriptions is in upper-case letters. I want the first letter of each phrase to be an capital letter, whereas all the other letters will be lowercase letters.

capture-decran-2017-07-27-a-105135.png

Example: I want to round to two digits after the comma, the percentage of the product promotion, calculated from the stricked through price and reduced price from my catalog.

rule2.png

In this example "Full_price" is the field which contains the price before the promotion and "Prix_Promo" is the field which contains the reduced price (product price during the promotion).

Example: I want to round down the price plus 20% and add the decimal .99 to apply a psychological price.

2020-04-16_17h27_03.png

In this example, "price" is the products catalogue field which contains the product selling price.

-

Articles in this section

Our Support hours:
9 a.m. to 6:30 p.m. CET Monday through Friday