Pricing formulas (work out the price from your cost)

Set up a markup rule so Brainerce fills in a product's price from the cost you paid. Covers the formula language, which products a formula covers, what happens when two formulas fit, and why a formula sometimes does nothing.

A pricing formula is a markup rule. You tell Brainerce what you paid for an item (the Cost Price), and the formula works out what to charge for it (the Base Price). A shop that always sells at cost plus 40% plus 10 for packaging writes that once as cost * 1.4 + 10, and never does the sum by hand again.

You can have as many formulas as you like, each covering a different part of your catalogue: one markup for jewellery, a thinner one for electronics, a different one again for a particular supplier's brand.

What pricing formulas do not do

This is the part people get wrong, so it is worth being blunt about.

A formula fills in a price while you are entering a product. It is a calculator, not a live pricing engine.

  • Turning a formula on does not change the price of anything you already sell. Existing products keep the prices they have.
  • Editing or deleting a formula does not re-price past products either. The number it worked out was written into the product as an ordinary price, and it stays there until you change it.
  • Nothing is recalculated at the checkout. Customers pay the Base Price stored on the product, exactly as if you had typed it yourself. Discounts, vouchers and VAT are applied on top by their own separate rules.
  • Formulas do not follow your supplier's cost. If a cost changes, you have to edit the cost, and the price is recalculated only if you have asked for it (see Auto-fill when you edit cost in the products table below).

If what you want is "everything in this category goes up 5% tonight", that is a bulk price edit, not a formula.

Where to find pricing formulas

Formulas live next to the products table that uses them.

  1. Go to Products.
  2. Open the settings menu at the top of the table and choose Product Settings.
  3. The Pricing Formula section holds both the behaviour setting and the list of your formulas.

There is no separate Pricing Formulas page in the sidebar.

Creating a formula

  1. In Product Settings, in the Pricing Formula section, click Add Formula.
  2. Give it a name you will recognise later, such as "Standard markup" or "Supplier X, thin margin". The name is what appears in the confirmation message when the formula is used.
  3. Write the expression, for example cost * 1.4.
  4. Set the scope if this formula should only cover part of your catalogue. Leave the scope empty and it covers everything.
  5. Check the Preview strip at the bottom, then Save.

A new formula is switched on as soon as you save it.

The preview uses a fixed sample VAT rate of 17%

The preview strip works your expression out against the sample cost you type, with tax_rate fixed at 0.17 and is_taxable fixed at 1. It is a sanity check on the arithmetic, not a rehearsal of your shop.

If your shop's VAT rate is not 17%, and your expression mentions tax_rate, the preview number will not match what the Calculate button later produces. The real calculation uses your shop's own rate.

What you can write in a formula

Three values are available to you, and nothing else:

WriteMeaning
costThe Cost Price you paid for the item
tax_rateYour shop's VAT rate as a decimal, so 17% VAT is 0.17
is_taxable1 when the product charges VAT, 0 when it is exempt

You can use +, -, *, /, % (remainder) and ^ (power), brackets, and these functions: min, max, abs, round, floor, ceil, sqrt, pow.

Some worked examples:

  • cost * 1.4 charges cost plus 40%.
  • cost * 1.4 + 10 adds a flat 10 for packing on top of the markup.
  • round(cost * 1.5) rounds to a whole number.
  • max(cost * 1.3, cost + 15) takes 30% markup or 15, whichever is more.
  • cost * (1 + tax_rate * is_taxable) adds VAT only to products that charge it.

Things the formula box will refuse

  • Comparisons and "and" / "or" are switched off. Something like cost > 100 ? cost * 1.2 : cost * 1.5 will not save. You can use the ? : choice operator, but only on a plain number, as in is_taxable ? cost * 1.17 : cost. Use min and max for the "whichever is bigger" cases instead.
  • Any other word is rejected. Only cost, tax_rate and is_taxable exist. There is no weight, no quantity, no margin, and no random numbers.
  • Nothing longer than 2,000 characters.
  • A formula that can produce a negative price will not save. Brainerce tries your expression on a few sample costs, including a cost of zero, before letting you keep it. cost - 50 fails, because a 30-cost item would come out at minus 20.

Choosing which products a formula covers

The Scope part of the formula decides which products it applies to. You can narrow it by:

  • Categories
  • Brands
  • Tags
  • Product Type (Simple or Variable in the dashboard; see Formulas and kits below)
  • Tax Status (taxable only, or non-taxable only)

Leave every one of them empty and the formula covers all products. That is the right shape for a single house markup.

Within one dimension the match is "any of". A formula scoped to two categories covers a product that is in either of them. Across dimensions it is "all of": a formula scoped to a category and a brand only covers products that are in that category and carry that brand.

A scope pointing at something you deleted matches nothing

Scope is matched against the exact category or brand you picked. If that category or brand is later deleted, the formula stays in the list, still shows as on, and quietly stops covering anything at all. Nothing tells you when that happens.

If a formula has stopped working for no obvious reason, open it and check that the categories, brands and tags in its scope still exist. Re-saving a formula whose category or brand has been deleted is refused with a message naming what is missing, so opening it and pressing Save is a quick way to find out.

The same is true of a deleted tag, and tags are the worse case: when you save a formula, Brainerce checks that the categories and brands in its scope still exist and refuses the save if they do not, but it does not check the tags. A formula scoped to a tag you later delete saves and shows as on, with nothing at all to tell you it has stopped matching.

Renaming a category, brand or tag is safe. Only deleting one breaks a formula's scope.

When two formulas both fit: the most specific one wins

Only one formula is ever used for a product. Brainerce picks it like this:

  1. The most specific formula wins. Specificity is a count of how many scope boxes you filled in: categories, brands, tags, product type and tax status, one point each. A formula narrowed by category and brand (2 points) beats a shop-wide formula with no scope at all (0 points).
  2. If two formulas are equally specific, the higher Priority wins. Priority is a number from 0 to 1000 that you set yourself. It is only a tie-break, and it cannot make a broad formula beat a narrower one.
  3. If they are still tied, the one edited most recently wins.

The practical consequence: you cannot override a narrow formula by giving a broad one a high priority. To carve out an exception, make the exception narrower than the rule it should beat.

A formula with Product Type set to Any counts as unrestricted on that dimension and matches every type, including kits.

The sort order of the formula list is only for your convenience while reading it. Sorting the list by priority does not change which formula wins.

Switching a formula off

Each formula in the list has a switch. A switched-off formula never applies to anything. It is skipped entirely when Brainerce decides which formula fits, so the next most specific one that is still on takes over.

That makes the switch the safe way to test a change: turn the old formula off rather than deleting it, and turn it back on if the new one behaves badly. Deleting a formula cannot be undone.

The Tax Status filter, and why it can look broken

Tax Status lets a formula cover only taxable products, or only exempt ones. It is useful when your markup differs between the two.

If VAT is switched off for your shop, a formula set to "Taxable only" will never match anything. With tax off, Brainerce treats every product as non-taxable, so a taxable-only formula has nothing to bite on. It saves without complaint and silently does nothing. Either turn VAT on in your tax settings, or leave Tax Status as Any.

For the same reason, tax_rate is 0 in your expressions when VAT is off, so cost * (1 + tax_rate) is just cost.

The VAT rate a formula uses

tax_rate is your shop's first configured VAT rate, the oldest one you set up. It is not chosen by the customer's country or region. If you have several rates for different places, do not rely on tax_rate to pick the right one.

Using a formula on a single product

On the product form, the Cost Price field has a calculator button next to it, labelled Calculate from cost.

  1. Type the Cost Price.
  2. Click the calculator.
  3. Brainerce finds the formula that fits this product and fills in the Base Price, telling you which formula it used.

The button stays greyed out until there is a cost to work from.

On a saved product, the product's stored details win

This one catches people out. When you press Calculate on a product that has already been saved, Brainerce ignores the categories, brands, tags and type currently selected in the form and reads them from the saved product instead.

So if you add a category in the form and press Calculate before saving, the formula is chosen as though that category were not there. Save the product first, then press Calculate, and you get the formula you expected.

On a brand new product that has not been saved yet there is nothing stored to read, so what is in the form is used, and everything behaves the way it looks.

"No formula matches this product"

That message means every formula was either switched off or scoped to something this product is not. The usual causes, in the order they usually turn out to be:

  • The product is missing the category, brand or tag the formula is scoped to.
  • The formula is switched off.
  • The formula is scoped to a category or brand that no longer exists.
  • The formula is set to "Taxable only" and VAT is off for the shop.
  • You have no shop-wide fallback formula, only narrow ones.

A formula with an empty scope, left on, is a good safety net: it means Calculate always produces something.

"Formula produced a negative price"

The formula matched, but at this particular cost it works out below zero, so nothing is filled in. Check the expression for a subtraction that is too large for a cheap item.

Auto-fill when you edit cost in the products table

Beyond the calculator button, the products table can run formulas for you when you edit a cost inline. Product Settings, in the Pricing Formula section, has a Behavior setting with three choices:

  • Off. Editing a cost in the table changes only the cost. Formulas run only when you press the Calculate button on the product form.
  • Auto-fill when price is blank (the default). Editing a cost fills in the price only if the product has no price yet. A price you typed yourself is never overwritten.
  • Always recompute from cost. Every cost edit rewrites the price, even over a price you set by hand.

Always recompute is the one to be careful with. If you have hand-set prices on some products, this setting replaces them the moment you touch their cost. The message that appears names the formula that did it, so you can spot it, but there is no bulk undo.

This setting applies to inline cost edits in the products table. It does not re-price anything on its own, and it changes nothing until you edit a cost.

Formulas and kits

A formula only reaches a kit that is on Fixed price. A formula fills in the Base Price, and a kit charges its Base Price only when its pricing mode is Fixed price. On the two contents-based modes, What the contents cost and Contents, less a discount, the kit costs what its contents cost and Base Price is ignored, so the number your formula worked out is thrown away. Nothing warns you: the formula appears to have run, the cost is saved, and the kit goes on selling at whatever its contents add up to. Check a kit's pricing mode in its contents dialog before you rely on a formula for it. See Kits.

For kits that are on Fixed price, a formula behaves exactly as it does on a simple product: it fills in the Base Price as you enter the cost.

The simplest way to cover kits is to leave Product Type as Any. An unrestricted Product Type matches every type, kits included, so your general markup already applies to them.

The Product Type list in the dashboard offers only Any, Simple and Variable. There is no Kit option in that dropdown yet, so a kits-only formula cannot be created from the formula dialog. If you need a markup that applies to kits and nothing else, ask an AI assistant to create it (see Letting an AI assistant manage your formulas below). A formula created that way is listed, switched off and deleted from the dashboard like any other.

Letting an AI assistant manage your formulas

An AI assistant can list, create, edit and switch off pricing formulas for you, and work a price out from a cost. Ask in plain language, for example "add a 45% markup formula for the Ceramics category" or "what would a cost of 80 sell for on this product". Both routes work:

  • The assistant built into the dashboard. No setup needed.
  • An outside AI assistant connected to your shop, such as Claude or ChatGPT. See Connect an AI assistant.

An assistant can also do the two things the formula dialog cannot: set a formula's Product Type to Kit, and check an expression before you commit to it.

A Kit-scoped formula still only reaches kits on Fixed price. An assistant can create it, but it has no effect on a kit set to What the contents cost or Contents, less a discount, because those work the price out from the contents and ignore Base Price entirely. See Formulas and kits above.

Everything on this page applies to what an assistant does too. It is still filling in prices as products are entered, and it still cannot re-price products you already sell.