Skip to main content

Variables Reference

Optional Feature

Variables (and the formulas they use) are an optional feature not available to all customers. If you're interested in using variables for advanced pricing logic or BOM calculations, please contact us to enable this functionality.

Variables are named calculations that extract or compute values from the product configuration. They act as intermediate values that can be reused across pricing patterns, BOM definitions, and other formula-enabled fields.

For business context on where these are configured, see Guide to Setting Up Pricing and Custom Fields.

Overview​

Variables let you:

  • Extract values from options for reuse
  • Perform calculations and transformations
  • Build complex conditional logic
  • Keep patterns clean and maintainable

Where Variables Are Defined​

Variables are defined in Product Admin → Pricing/Codes → Variables.

Once defined, they can be used in any formula-enabled field:

  • Pricing patterns
  • Price code quantities
  • BOM item fields (name, code, quantity)
  • BOM custom fields (Text type)
  • Bundle fields
info

Variables are only available in formula-enabled fields (backend-processed). String-only fields like SKU, rules, and 2D images cannot reference variables.

Variable Structure​

Each variable has two properties:

PropertyDescription
NameIdentifier used to reference the variable (e.g., HAS_LINING)
PatternExpression that computes the value (string or formula)

Referencing Variables​

Use the #variable suffix:

{VARIABLE_NAME#variable}

Example:

=IF({HAS_LINING#variable}="true", "LINED", "UNLINED")

Creating Variables​

Simple Extraction​

Extract a value directly from an option:

Name: COLOR_CODE
Pattern: {chooseyourcolor#code}

Conditional Logic​

Use formulas for true/false flags:

Name: HAS_LINING
Pattern: =IF({lining#code}="YES", "true", "false")

Character Counting​

Count characters for pricing tiers:

Name: EMBOSSING_CHAR_COUNT
Pattern: =IF({embossing#inputValue}="", 0, COUNT_CHAR({embossing#inputValue}))

Multi-Condition Checks​

Combine multiple conditions:

Name: NEEDS_SPECIAL_HANDLING
Pattern: =IF(
OR(
{HAS_LINING#variable}="true",
{HAS_POCKETS#variable}="true"
),
"true",
"false"
)

Text Transformations​

Extract or format text:

Name: MATERIAL_PREFIX
Pattern: =LEFT({material#code}, 3)

Name: PADDED_COLOR_CODE
Pattern: =TEXT({color#bom}, "00")

Variable Dependencies​

Variables can reference other variables, enabling layered calculations:

# First variable - extract base info
Name: SIZE_FORMAT
Pattern: {sizeSelector#code}

# Second variable - uses first variable
Name: IS_LARGE_FORMAT
Pattern: =IF(OR({SIZE_FORMAT#variable}="a4", {SIZE_FORMAT#variable}="xl"), "true", "false")

# Third variable - uses previous variables
Name: BASE_CODE
Pattern: =IF({IS_LARGE_FORMAT#variable}="true", "LG", "SM")
Circular References

Avoid circular references where Variable A references Variable B which references Variable A. This will cause evaluation errors.


Real-World Examples​

Example 1: Character Count Pricing​

Charge different rates based on embossing character count:

Name: CORNER_CHAR_COUNT
Pattern: =IF({embossingCorner#inputValue}="", 0, COUNT_CHAR({embossingCorner#inputValue}))

Name: EMBOSSING_TIER
Pattern: =IF({CORNER_CHAR_COUNT#variable}>10, "LONG", IF({CORNER_CHAR_COUNT#variable}>3, "MED", "SHORT"))

Pricing Pattern:

=IF({CORNER_CHAR_COUNT#variable}>0, CONCATENATE("EMB-", {EMBOSSING_TIER#variable}), "")

Example 2: Size-Dependent Logic​

Different behavior for different product sizes:

Name: SIZE_FORMAT
Pattern: {sizeSelector#code}

Name: IS_A5_A6
Pattern: =IF(OR({SIZE_FORMAT#variable}="a5", {SIZE_FORMAT#variable}="a6"), "true", "false")

Name: IS_A4
Pattern: =IF({SIZE_FORMAT#variable}="a4", "true", "false")

Name: AVAILABLE_FEATURES
Pattern: =IF(
{IS_A5_A6#variable}="true",
"basic",
IF({IS_A4#variable}="true", "full", "standard")
)

Example 3: Multi-Field Selection​

Select from multiple optional input fields:

Name: EMBOSSING_A4_COUNT
Pattern: =IF({embossingA4#inputValue}="", 0, COUNT_CHAR({embossingA4#inputValue}))

Name: EMBOSSING_A6_COUNT
Pattern: =IF({embossingA6#inputValue}="", 0, COUNT_CHAR({embossingA6#inputValue}))

Name: EMBOSSING_STD_COUNT
Pattern: =IF({embossingStd#inputValue}="", 0, COUNT_CHAR({embossingStd#inputValue}))

Name: ACTIVE_EMBOSSING_TEXT
Pattern: =IF(
{EMBOSSING_A4_COUNT#variable}>0,
{embossingA4#inputValue},
IF(
{EMBOSSING_A6_COUNT#variable}>0,
{embossingA6#inputValue},
IF({EMBOSSING_STD_COUNT#variable}>0, {embossingStd#inputValue}, "")
)
)

Example 4: Feature Flags​

Build feature codes based on configuration:

Name: HAS_LINING
Pattern: =IF({lining#code}="NONE", "false", "true")

Name: HAS_POCKETS
Pattern: =IF({pockets#code}="NONE", "false", "true")

Name: FEATURES_CODE
Pattern: =IF(
{HAS_LINING#variable}="true",
IF({HAS_POCKETS#variable}="true", "LP", "L"),
IF({HAS_POCKETS#variable}="true", "P", "")
)

Example 5: Complex Pricing Pattern​

Assemble a complete pricing code:

Name: BASE_PREFIX
Pattern: =IF({productLine#code}="PREMIUM", "P", "S")

Name: SIZE_CODE
Pattern: {size#code}

Name: NEEDS_A_SUFFIX
Pattern: =IF(AND({finish#code}="MATTE", {color#code}<>"BLACK"), "true", "false")

Name: FULL_CODE
Pattern: =CONCATENATE(
{BASE_PREFIX#variable},
{SIZE_CODE#variable},
"_",
TEXT({coverColor#bom}, "00"),
IF({NEEDS_A_SUFFIX#variable}="true", "_A", ""),
{FEATURES_CODE#variable}
)

Pricing Pattern:

{FULL_CODE#variable}

Result: "Pa4_05_ALP"

Example 6: BOM Quantity Calculation​

Calculate component quantities:

Name: PANEL_COUNT
Pattern: =IF({configuration#code}="DOUBLE", 2, 1)

Name: WIDTH_CM
Pattern: {width#inputValue}

BOM Quantity Pattern:

=({PANEL_COUNT#variable} * {WIDTH_CM#variable}) / 100

Example 7: Conditional BOM Code​

Generate BOM item codes:

Name: HAS_POCKETS
Pattern: =IF({pockets#code}="NONE", "false", "true")

Name: POCKET_TYPE
Pattern: =IF({HAS_POCKETS#variable}="true", {pockets#code}, "")

BOM Code Pattern:

=IF(
{HAS_POCKETS#variable}="true",
CONCATENATE("PKT-", {POCKET_TYPE#variable}, "-", TEXT({pocketColor#bom}, "00")),
""
)

Debugging Variables​

Pricing Debugger​

Located in Product Preview → Pricing Debugger:

  • View all pricing variables
  • See input patterns and resolved output values
  • Verify calculations for current configuration

BOM Debugger​

Located in Product Preview → BOM Debugger:

  • View all BOM variables
  • See input patterns and resolved output values
  • Check how variables affect BOM items
tip

Always test variables with multiple product configurations to ensure they handle all edge cases correctly.


Best Practices​

Use Clear Names​

✓ HAS_LINING
✓ EMBOSSING_CHAR_COUNT
✓ SIZE_FORMAT
✓ BASE_PRICE_CODE

✗ VAR1
✗ X
✗ TEMP

Break Down Complex Logic​

Instead of one massive formula:

# Hard to read and maintain
Pattern: =IF(AND(OR({a#code}="X",{a#code}="Y"),{b#code}="Z",NOT({c#code}="W")),...)

Use multiple variables:

Name: IS_TYPE_XY
Pattern: =IF(OR({a#code}="X", {a#code}="Y"), "true", "false")

Name: MEETS_CONDITION_B
Pattern: =IF({b#code}="Z", "true", "false")

Name: NOT_EXCLUDED
Pattern: =IF(NOT({c#code}="W"), "true", "false")

Name: FINAL_CHECK
Pattern: =IF(AND({IS_TYPE_XY#variable}="true", {MEETS_CONDITION_B#variable}="true", {NOT_EXCLUDED#variable}="true"), ...)

Always Handle Empty Values​

=IF({field#inputValue}="", 0, COUNT_CHAR({field#inputValue}))
=IF({field#inputValue}="", "", CONCATENATE("PREFIX-", {field#inputValue}))

Use Consistent Boolean Strings​

Variables store strings. Use consistent values:

✓ "true" / "false"
✗ "yes" / "no" / "TRUE" / "1"

Then compare consistently:

=IF({MY_FLAG#variable}="true", ...)

See Also​