Per unit of metafield fees

Last updated: September 23, 2026

A Per unit of metafield fee charges a rate for every unit of something you store in a product or variant metafield: fee = rate × the metafield number × quantity. Example: 0.05 per pouch, metafield custom.pouches_per_can = 20, three cans = 3.00. Products without the metafield contribute 0.

When to use it

Use it when the fee is set per unit of something Shopify has no field for: pouches per can, grams of sugar per bottle, grams of plastic per package, milliliters of liquid per cartridge. You store that number once per product or variant, and the fee follows it.

Set it up

  1. Create the metafield. In your Shopify admin, go to Settings > Metafields and metaobjects, choose Products or Variants, and add a definition with the Integer or Decimal type, for example custom.pouches_per_can. See Metafields in FlexiFees for the accepted types and the Storefronts access option.
  2. Fill in the values on the products or variants that carry the fee.
  3. Create the fee. Set Fee type to Per unit of metafield and enter the rate per unit.
  4. Choose the metafield under Metafield that supplies the number: pick Product metafield or Variant metafield, then pick the definition from the list or type its namespace and key.
  5. Choose Per product fee or Cart fee, add conditions, and publish.
FlexiFees fee form with fee type Per unit of metafield, 0.05 per unit, variant metafield custom.pouches_per_can

How the amount is calculated

ScopeCalculationExample
Per product feeRate × metafield number × quantity, for each matching product, added into one line0.05 × 20 pouches × 3 cans = 3.00
Cart feeRate × metafield number × quantity, summed over every product in the cart (fee lines excluded)0.05 × 20 pouches × 1 can = 1.00

Details worth knowing

  • Numbers only. The metafield must hold a number, a money amount, or a unit value such as a weight. Empty or text values count as 0. Unit values are read as stored, without conversion.
  • Zero means no fee. If no matching product carries the metafield, the total is 0 and no fee line is added.
  • Product or variant. Use a variant metafield when sizes differ (a 10-pack and a 20-pack of the same product); a product metafield when all variants share the value.
  • Fee limits. A minimum and maximum are available; on a per-product fee they apply to the fee's total.
  • Need more than one rate? A Formula can combine mf("custom.pouches_per_can") with a fixed amount or a percentage.
The first cart with a new amount. Calculated fees produce amounts Shopify has not seen before. The first time a new amount appears, Shopify can take a few seconds, occasionally up to about a minute, to accept the new fee line; FlexiFees retries automatically, and the same amount is instant from then on. Fixed fees are prepared when you save and appear immediately.

Related

Questions

What happens if a product has no value in the metafield?

It contributes 0. If no matching product has a value, no fee line is added.

Which metafield types work?

Number (integer or decimal), money, and unit types such as weight. Text values count as 0.

Can I use it as a cart fee?

Yes. As a cart fee the rate × metafield number × quantity is summed over every product in the cart.

Start free trial on Shopify