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

StrategyUseMinimal example
NoneNo additional calculation.Leave logic code empty.
ExpressionA short calculation without a statement block.price * 1.5
LuaMulti-step logic using Lua syntax.return price * 2
TengoMulti-step logic using Tengo syntax.result = price * 3

Input values

The code can read these values:

ValueMeaning
priceCalculated base price for the requested quantity.
quantityRequested quantity.
productProduct attributes as an object.
customerCustomer attributes as an object.
currencyPrice-list currency.
unitPrice 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:

ModeCompile, runtime, or result error
StrictPrice resolution stops with an error.
FallbackWorkspace 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.