Skip to main content
One attribute type is a formula. Formulas enable you to calculate new information using functions. Formulas can refer other attributes within the same context, e.g. stock items, or listings.

Formula type

You can create formulas with numbers, strings, mathematical operators, parentheses, references to other attributes, and functions. Functions are powered by Formula.js.

Referencing other attributes

You can use data from other attributes inside formulas.
We use $attribute_name syntax to refer to other attributes from the same context (table in Admin). Both system attributes (such as $created_at and $usage_hours) and custom attributes you have defined (e.g. $color) are available.

Example

You can use formulas to calculate a residual value for a stock item by utilizing the purchase price, age in months and usage hours.Lets say the maximum age for an item is 10 years and/or 1000 usage hours. You could use a formula like this:$purchase_price * (1-($age_in_months / 120)) * (1-($usage_hours / 1000))This formula takes into account both age and usage hours and results in residual value of 0 as soon as either attribute reaches the defined maximum.You could also create another formula attribute for a resell price, for example:$residual_value * 2

Functions