Skip to main content
Skip table of contents

Price Management | Formatters

UnitPrice and PackPrice are formatted using the set formatting rule (in the CS language).

You can also use formatters, which can be appended to the attribute name with '|', to format the output. These can also be concatenated:

CODE
{Field|Formatter1()|Formatter2()|...

Formatter

Example

Parameters

Descriptions

date_format

PHP
{ValidFrom|date_format("Y-d-m")}

Date format

The formatter formats the date using the provided formatting parameters analogue to the PHP function.

number_format

PHP
{PackPrice|number_format()}

Number format

The formatter formats a numerical value in the current CS language.

number_format_raw

PHP
{UnitPrice|number_format_raw()}

 

The "number_format" formatter is used by default for the "UnitPrice" and "PackPrice" fields.

Therefore, the formatter "number_format_raw" is available that reverses the standard formatting.

currency_format

PHP
{UnitPrice|currency_format()}

Example result: CHF 12.34

 

PHP
{PackPrice|currency_format('Label')}

Example result: 12.34 Swiss francs

Label or symbol

This formatter is available for the "UnitPrice" and "PackPrice" fields only.

If you do not select a parameter, the "Symbol" parameter is used by default.

If you use the label, it is always placed at the end.

By checking the "Currency" field, the formatter tries to find a CS currency with the same name.

If it finds a currency, the currency is placed either before or after the price, depending on the setting.

If it does not find a suitable currency, the value from the field is used.

If there is no currency in the field, only the price is returned.

replace

PHP
{Unit|replace('["Stueck", "Stück"]', "Piece")}

This function replaces all occurrences of "piece" and "item" by "Pc".

 

This formatter replaces values.

The function requires at least two parameters: Search pattern and replacement.

Optionally, you can specify "true" as the third parameter to replace values irrespective of upper and lower case.

Multiple replacements are possible by specifying arrays in JSON notation as the search pattern or replacement. In this case, use different quotation marks than those surrounding the JSON string.

translate

PHP
{SalesOrganisation|translate()}

Translation

This formatter translates the value from the specified field into the applicable data language if a translation is available.

calc

PHP
{UnitPrice|calc(DIVISION,3)|calc(MULTIPLICATION,10)}

ADDITION

SUBSTRACTION

DIVISION

MULTIPLICATION

The operations are performed from left to right. You can also use several operations.

It is important to place the formatter for the calculations before the other formatters.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.