Use price-list logic code
This reference is for administrators who calculate sales prices with custom code. After configuration, the price list returns a numeric price from Expr, Lua, or Tengo code. Select None when the stored base price should remain unchanged.
Choose a strategy
| Strategy | Use | Minimal example |
|---|---|---|
None | No additional calculation. | Leave logic code empty. |
Expression | A short calculation without a statement block. | price * 1.5 |
Lua | Multi-step logic using Lua syntax. | return price * 2 |
Tengo | Multi-step logic using Tengo syntax. | result = price * 3 |
Input values
The code can read these values:
| Value | Meaning |
|---|---|
price | Calculated base price for the requested quantity. |
quantity | Requested quantity. |
product | Product attributes as an object. |
customer | Customer attributes as an object. |
currency | Price-list currency. |
unit | Price unit. |
Only access product or customer attributes that are available in the current pricing context. Handle missing attributes explicitly.
As you type, the editor suggests the available variables and explains each one. You can also open the suggestion list with your browser's standard code completion shortcut.
Return a result
Return one of these values:
- a number,
- a numeric string,
- an object containing
price, - an object containing
amount.
Lua can return the value or assign it to result or price. Tengo must assign the calculated value to result. An expression returns its value directly.
Runtime and errors
Workspace compiles and executes the code on the server. The default execution limit is 50 milliseconds. The configured price-engine mode determines error handling:
| Mode | Compile, runtime, or result error |
|---|---|
| Strict | Price resolution stops with an error. |
| Fallback | Workspace uses the base price and reports a warning. |
The code has no browser or database access. Tengo only exposes the approved standard modules math, text, and times.
Verify the result
Configuration is complete when the selected strategy matches the code and a price resolution returns the expected numeric amount. In a test environment, check a normal quantity, a boundary quantity, missing attributes, and an intentionally invalid value.