Product Templates - Custom Formula Logic

Tyler MacDonald Updated by Tyler MacDonald

This article is a collection of tables and examples to lay out what is available to you with respect to ...

  • System Formulas
  • System Variables
  • Example Use of System Variables
  • Arithmetic Operators
  • Comparison Operators
  • Math Methods
  • Example use of Modifiers
Exercise caution when using the information below. The idea is to be able to create some small customization within your calculations. Our support staff will not be able to debug or support code issues that are beyond a few lines long.

System Formulas

System formulas are built into shopVOX and work in your product template. You cannot edit a System Formula, but you can select it as an option and work with it inside of your Product Template. The following is a list of system formulas.

Formal Type

Formula

Area

(Width*Height)

Area_in_sqyd

Width_in_yards*Height_in_yards

Cylindrical_Surface_Area

(2*3.14159)(radius+height)

Cylindrical_Surface_Are_in_sqyd

((2*3.14159)(radius+height))/9

Cyl.Vol

3.14159*(radius*radius)*height

Fixed

'Fixed' in conjunction with a 'Fixed Quantity value'

For example, a fixed Quantity of 4, with a material of grommets.

This means the number 4 will always show up as the quantity required

Even if you attempt to override it

Height

Height

Height_in_yards

Height_in_yards

Length_in_yards

Length_in_yards

Perimeter

2*(Width+Height)

Perimeter_in_yards

2*(Width_in_yards+Height_in_yards)

Volume

Width*Height*Depth

Width

Width

Width_in_yards

Width_in_yards

System Variables

There are some basics system variables that can be used in your custom formulas

Variable

Description

svLineItem_qty

Returns the Quantity being enter, into the Quantity box of a product

svItem_sheet_width

Returns the Width of a specific material being selected

svItem_sheet_height

Returns the Height of a specific material being selected

Reference_System Variables

Access the sheet width and height of another system variable by leveraging the "Reference" field.

Variable

Description

reference_sheet_width

Returns the Width of a reference material being selected. Simply put a "reference" in front of _sheet_width

reference_sheet_height

Returns the Height of a reference material being selected. Simply put a "reference" in front of _sheet_height

Example use of System Variable

Here are some basic ideas for how you use a system variable as a custom formula

Example Code

Description

(svItem_sheet_width*svItem_sheet_height)/144

Calculating the total square feet of a roll or sheet

Math.floor(svItem_sheet_width/Width)

Returns the number of units across against a materials width

Math.floor(svItem_sheet_height/Height)

Returns the number of units down against a materials height

Math.ceil(Width/svItem_sheet_width)

Returns the number of panels across if the object is larger than the material being selected

Math.ceil(Height/svItem_sheet_height)

Returns the number of panels down if the object is larger than the material being selected

Example use of Reference_System Variable

Here are some basic ideas for how you use a system variable as a custom formula

Example Code

Description

(reference_sheet_width*reference_sheet_height)/144

Calculating the total square feet of a referenced roll or sheet. Replace "reference" with your own reference

Math.floor(reference_sheet_width/Width)

Returns the number of units across against a referenced materials width. Replace "reference" with your own reference

Math.floor(reference_sheet_height/Height)

Returns the number of units down against a referenced materials height. Replace "reference" with your own reference

Math.ceil(Width/reference_sheet_width)

Returns the number of panels across if the object is larger than the referenced material being selected. Replace "reference" with your own reference

Math.ceil(Height/reference_sheet_height)

Returns the number of panels down if the object is larger than the referenced material being selected. Replace "reference" with your own reference

Arithmetic Operators

Operator

Name

Description

Example

+

Addition

Adds together two values

x + y

-

Subtraction

Subtracts one value from another

x - y

*

Multiplication

Multiplies two values

x * y

/

Division

Divides one value by another

x / y

%

Modulus

Returns the division remainder

x % y

++

Increment

Increases the value of a variable by 1

++x

--

Decrement

Decreases the value of a variable by 1

--x

Comparison Operators

Operator

Name

Example

==

Equal to

x == y

!=

Not equal

x != y

>

Greater than

x > y

<

Less than

x < y

>=

Greater than or equal to

x >= y

<=

Less than or equal to

x <= y

?

Ternary Operator

Math Methods

Math Function

Description

Example

Math.round(x)

Rounds x to the nearest integer - Below .5 rounds down above .5 rounds up

Math.round(2.5) returns 3

Math.round(2.4) returns 2

Math.abs(x)

Returns the absolute value of x

Math.abs(-2) returns 2

Math.ceil(x)

Returns x, rounded upwards to the nearest integer

Math.ceil(2.1) returns 3

Math.ceil(2.999) returns 3

Math.exp(x)

Return the Euler's number e raised to the power of a double value.

Here, e is an Euler's number, and it is approximately equal to 2.718281828459045

Math.exp(1) returns 2.718

Math.exp(5) returns 148.413

Math.floor(x)

Returns x, rounded downwards to the nearest integer

Math.floor(2.1) returns 2

Math.floor(2.999) returns 2

Math.max(x,y,z,...)

Returns the number with the highest value

Math.max(5,1,8,3,2) returns 8

Math.min(x,y,z,...)

Returns the number with the lowest value

Math.min(5,1,8,3,2) returns 1

Math.pow(x,y)

Returns the value of x to the power of y

Math.pow(2,2)returns 4

Math.pow(5,3) returns 125

Math.trunc(x)

Returns the integer part of a number (x)

Math.trunc(2.718281828459045) returns 2

Example use of Modifiers

Please refer to the article Product Templates - Interface and Formulas Explained. A modifier is technically a variable that you have created in your system. It is either Numeric or Boolean.

Modifier

Example code with Modifier

Description

Double_Sided

(Boolean)

(Double_Sided)?2:1;

When using the built in System Formula for Area. This statement checks to see if the Double_Sided Boolean Checked? If yes multiply by two if not multiply by 1

Double_Sided

(Boolean)

(Double_Sided)?((Width*Height)/144)*2:(Width*Height)/144;

When using a Custom Formula for Area. This statement checks to see if the Double_Sided Boolean is checked. If yes, multiply by two if not, multiply by 1

Grommets_Spacing

(Numeric)

Math.ceil(((Width+Height)*2)/Grommets_Spacing)

When using a Custom Formula for Perimeter and dividing by the Grommets_Space. Rounded up to the nearest integer

Publishing Your Product

When you're satisfied with your product, you must publish it to make it available for use in Quotes, Sales Orders, or Invoices.

You can identify if your product is in "Draft" mode by the tag underneath the title.

To publish a product, go to the blue action button and select "Publish Product."

If you need to unpublish it later, select the blue action button again and choose "Convert to Draft."

Learn more about products from the links below. Products are where we using the logic in this document, to customize our calculations.

What are Products?

Adding Your Own Products

Product Templates - Interface and Formulas Explained

How did we do?

Product System Formula - with Filter

Product Template - Add New Defualt Items Configuration Window

Contact