Calculator Unit Price Calculation

Automatically Add Option Values: #

  • When Automatically Add Option Values is Checked, the application will add all values for all options within the calculator together and set the products price.

    When Automatically Add Option Values is Unchecked, you can write your own custom formula for the calculator. Any option that is part of the calculator, will be available for use in the calculation. The value returned from this calculation will be the unit price of your product.


Unit Price #

Unit price means the price of a single unit (quantity of 1) of your product.

Shopify prices products on a per UNIT basis, not on a multiple product basis.

This means if you want to sell 1,000 units for $1,667 total, the unit price of these items would need to be $1.667.

You cannot price a product for units smaller than 0.01 and the unit price of 1.667 is impossible to achieve. The unit price must be either $1.66 or $1.67. That means the final price must be either $1,660 or $1,670.

If you want to sell large number of units at a very specific price you should:

  • Sell as a bundle with a quantity of 1 and describe the real quantity in a calculator option.
  • Price on a Per UNIT basis instead.

Calculation is Total Price Not Unit Price #

This checkbox tells the calculator you have calculated a total price in the Unit Price Calculator field instead of a Unit Price. You should really avoid doing this whenever possible. Typically, you want to check this box if you have included product_quantity in your unit price calculation field.

When this is checked, the calculator will divide the calculated price by the quantity to determine the actual unit price. The issues described above may occur.

If you do not check “Calculation is Total Price Not Unit Price”, you may find the items added to cart are very expensive compared to what you expect. Each unit will be priced at the value you expected for all units.

Display Total Price instead of Unit Price #

Typically you will include product_quantity in the Unit Price Calculation because you actually want to display the total price for all units not because you want to actually price each unit this way.

Checking “Display Total Price instead of Unit Price” lets you show the total price and while still calculating the unit price of a product. By calculating the unit price, you have more control over the proper pricing of your product and guarantees that what you display to users is the same as the price actually added to cart.

This is the recommended approach when calculating pricing.

Mathematical Expressions #

You can use any of the following mathematical expressions in a calculation:

SymbolDescription
+Addition
Subtraction
*Multiplication
/Division
( )Open and close parenthesis
All Functions below are only available for Elite Plan only
math.round(x,n)Round a value towards the nearest integer.

x = Number to be rounded
n = Number of decimals.

https://mathjs.org/docs/reference/functions/round.html
math.abs(x)Calculate the absolute value of a number.

x = Number for which to get the absolute value

https://mathjs.org/docs/reference/functions/abs.html
math.ceil(x,n)Round a value towards plus infinity.

x = Number to be rounded
n = Number of decimals.

https://mathjs.org/docs/reference/functions/ceil.html
math.exp(x)Calculate the exponential of a value.

x = Number to exponentiate

https://mathjs.org/docs/reference/functions/exp.html
math.pow(x, y)Calculates the power of x ^ y.

x = The base
y = The exponent

https://mathjs.org/docs/reference/functions/pow.html
math.sqrt(x)Calculate the square root of a value.

x = Value for which to calculate the square root.

https://mathjs.org/docs/reference/functions/sqrt.html
math.square(x)Compute the square of a value, x * x

x = Number for which to calculate the square

https://mathjs.org/docs/reference/functions/square.html

All Formulas will follow BEDMAS.

Brackets – First Priority
Exponents – Second Priority
Division – Third Priority
Multiplication – Third Priority
Addition – Fourth Priority
Subtraction – Fourth Priority

Calculation Variables allow you to insert other options, lookup tables and product variables in to the formula.

Option Variables #

Example column shows how an option named “size” would be included in a calculation or formula.

VariablesExampleDescription
Dropdown
Text
Paragraph
Email
File Upload
sizereturns value or calculated formula value
Single Select
Swatch
Radio
Button
sizereturns value or calculated formula value
Multi Select
Swatch
Radio
Button
size
size.selectedcount
returns value or calculated formula value
returns the number of items selected
Numbersize
size.inputvalue
returns value or calculated formula value
returns user input number
Datenoneno value or calculation available for date options
Instructionnoneno value available for Instruction options but it can calculate a formula and display inline.
Measurementsize
size.input1
size.input2
returns the number found in associated pricing table
returns user input number for input 1
returns user input number for input 2
Pricing Tablessizetable[ ]
sizetable[ 25, 55 ]
sizetable[size.input1,size.input2]
sizetable[variable, 20]
sizetable[variable, variable]
sizetable[6*variable, 30]
returns the number found in the pricing table (sizetable) based on the values provided in the brackets [ ]
Can accept another option variable or calculation as inputs.
Shopify Product Priceproduct_pricereturns the price of the selected product from Shopify. This will be the price of the default variant or the price of the selected variant
Shopify Product Quantity
or
OPC Quantity Option
product_quantityreturns the quantity in the product page quantity selector
Shopify Metadata metadata01
metadata02
metadata03
metadata04
metadata05

metadata01
metadata02
metadata03
metadata04
metadata05
returns the value set from the option block settings. could be any product meta data.
Variant Metadata


variant.<key>

where <key> is the variant metadata identifier in Shopify
Returns selected variant metadata value


Writing a calculation formula #

To write a formula enter a combination of variables, mathematical expressions and your own number inputs.


Mathematical Arguments #

A calculation formula must use mathematically arguments between each variable. Buttons to add these arguments are included with each calculation / formula field.

The following are example of INVALID calculation:

  • product_price dimensions[ length, width ]
  • product_quantity 100
  • width height

Each of the examples above have multiple variables or constants without any valid mathematical expression between them. The calculator has no idea what you are asking for by this and nor would your grade 9 math teacher. The calculation will fail.

To fix the calculations above add a mathematical argument between the variables:

  • product_price + dimensions[ length, width ]
  • product_quantity * 100
  • width * height