Skip to content
English
  • There are no suggestions because the search field is empty.

Write a pricing formula

A pricing formula lives on the product's Pricing tab (Settings > E-Commerce > Products > the product > Pricing). Split it into named formula sections that are added together, build each one from the variables listed in the sidebar, and use ? : conditions, floor, ceil and round where you need them. This page covers the building blocks; How Allmoxy prices a product explains what happens to the result.

Applies to: shops writing or editing product pricing. Needs the Manage Catalog permission.

In this article

Formula sections

The product Pricing tab with a formula section

  1. Open the product and click the Pricing tab.
  2. Give the first section a Section Name (for example Base Price) and type its formula. A section can be as simple as 27.75.
  3. Click Add Formula Section for each further piece: upcharges, oversize, hardware. Keep each section about one thing; the price is the sum of all of them, and the test tools show each section's result separately.
  4. Set a Minimum Price if the product should never go below a figure, and the Per Item Price Precision (how many decimals the item price keeps).
  5. Click Save and Exit.

If a section uses a name Allmoxy doesn't recognise, the save is refused with an invalid token message and nothing is stored, so fix the name and save again. Use Format to tidy a long formula and Expand Editor to see more of it.

Variables: where the numbers come from

The sidebar lists everything this product's formulas can use. Put the cursor where you want it and click a name to insert it.

The Product Variables panel in the Pricing tab sidebar

  • Product variables are the product's attributes by formula name: width, height, wood_type. A number attribute gives its value; a checkbox gives 1 when ticked and 0 when not.
  • Option columns appear as attribute.column, for example wood_type.price or door_style.upcharge. The value is that column of whichever option the customer chose. Adding a column to a dropdown attribute is how you price by option; see Price by dropdown option.
  • Part variables are parts.<part>.<value>, such as parts.panel.Qty or parts.panel.Width, and give what that part's formula works out for this item. Use them when the price depends on material, such as square feet of panel.
  • Proxy variables are shared formulas from Settings, used as proxyvar.<name>. See Proxy variables.
  • quantity is the item quantity.

A square-foot price with a per-wood rate looks like: ((height * width) / 144) * wood_type.price_per_sqft.

Conditions (if this, then that)

Write a condition as test ? value if true : value if false:

wood_type.is_premium == 1 ? 15 : 0

Compare with ==, !=, <, >, <= and >=, and combine tests with && (both) and || (either):

((height * width) / 144) > 3.5 ? (((height * width) / 144) - 3.5) * wood_type.oversize_price : 0

This charges the oversize rate only on the square footage above 3.5.

Checkbox attributes are 1 or 0, so hinge_drilling == 1 ? 4.50 : 0 adds $4.50 when the box is ticked.

Several tiers chain conditions. Open a parenthesis for each tier and close them all at the end, with as many closing as opening:

(drawer_height <= 4 ? 10 : (drawer_height <= 6 ? 12 : (drawer_height <= 8 ? 14 : 16)))

Put each tier on its own line for readability; line breaks don't change the result.

Rounding: floor, ceil and round

Wrap the part of the formula you want rounded in parentheses after the function:

  • round(x) rounds to the nearest whole number (.5 and up goes up).
  • floor(x) always rounds down.
  • ceil(x) always rounds up.

For decimals, scale first and divide after. To round to cents: round((height * width / 144) * wood_type.price * 100) / 100. To round up to the nearest 5 cents: ceil(x * 20) / 20.

The sidebar lists these as Round, Floor and Ceiling; what you type is round, floor and ceil.

Minimum price and comments

Add Formula Section, Minimum Price and Per Item Price Precision at the bottom of the Pricing tab

  • Minimum Price at the bottom of the Pricing tab is the lowest price the formula may return for one item. Use it for a minimum charge per item rather than building the floor into the formula.
  • Comments go anywhere inside a formula between /* and */, for example /* oversize rate */. They're stripped before the formula is worked out, so use them freely to label sections.

Things to know

  • Formula names are permanent. Renaming an attribute's display name is safe; its formula name never changes, so formulas keep working.
  • Save to check. Pricing formulas are checked when you save, and Allmoxy tries each section with sample values. A section that can never produce a number is refused.
  • Blank numbers count as 0 and an unselected dropdown makes the price show as "-" until the customer picks an option. Give attributes sensible defaults.
  • Test before you publish. Test and fix a pricing formula shows how to see each section's result with real values.

Related articles