Metafield Discounts
Drive discount values, prices, and caps from metafields, attributes, and line properties using linked fields.
Overview
Metafield discounts give you per-product — or even per-line — control over discount values. Instead of entering a single static number, you link the Discount value, Quantity, or Message inputs to a dynamic source that resolves when the function runs.
- Per-product percentages — each product defines its own percent off via a metafield
- Per-product fixed prices — flash-sale prices stored on products
- Custom base pricing — discount percentages computed from wholesale or compare-at prices rather than the regular price
- App-driven discounts — cart line properties or cart attributes set by bundle builder apps drive the discount
- Computed values — an upstream Sum Values or Count Items block feeds a computed number into the discount
This page documents the mechanism — linked fields — and the Advanced settings that unlock base-price overrides.
Linked Fields
Linked fields are the underlying mechanism for all dynamic discount values. Any input with a link icon next to it can be swapped from a static value to a reference that resolves at runtime.
Where You’ll See the Link Icon
- Discount value on the Apply Product Discount block
- Discount message (uses linked string sources)
- Quantity inside the Quantity limit section
- Tier thresholds and values on the Tiers block
- Numeric and string inputs on most other blocks
Supported Sources
- Metafields — product, variant, customer, company, or shop metafields. Numeric types (
number_integer,number_decimal,money) for numeric inputs; string types for message inputs - Cart attributes —
cart.attribute.<key>, set by the storefront, checkout extensions, or apps - Line properties —
properties._keyon individual cart lines, common with bundle builders and product customizers - Upstream node outputs — numeric results from Count Items, Sum Values, Max, or Tiers earlier in the flow
How to Link a Field
Click the link icon
Next to the input you want to drive dynamically
Pick a source
Browse metafields, attributes, line properties, or upstream outputs
For JSON metafields
Select the subfield key inside the JSON object
For metafields with multiple indexes
Choose which one to read (visible when more than one metafield of that type is configured on the function input)
Resolution Rules
- Numeric links expect a positive numeric value. Non-numeric or missing values cause that line to be skipped — it gets no discount
- Percentage values are treated as whole numbers (
20= 20%), not fractions (0.20) - Linked messages support the same
{{percentage}}and{{amount}}placeholders as static messages - Linked values are resolved per cart line for product/variant sources, and once for cart, customer, or shop sources
Tip
If a discount isn’t applying to a specific product, the most common cause is that the linked metafield or property isn’t set on that product. Items without a resolved value are silently skipped.
Use Cases
Per-Product Percentage Discounts
Each product carries its own markdown.
Create metafield
Add custom.clearance_pct (number_integer) to products
Set values
20 on one product, 35 on another, leave blank on products that shouldn’t discount
Function input
Include the metafield in the function’s input configuration
Discount block
Set Discount type to Percentage
Link Discount value
Click the link icon on Discount value and choose custom.clearance_pct
Message
Use Save {{percentage}} so each product shows its own percent
Per-Product Fixed Prices (Flash Sale)
Each product has an explicit sale price.
Create metafield
custom.flash_price (money or number_decimal)
Discount type
Fixed Price
Link Discount value
Point at custom.flash_price
Number of items
1 (each sale is per-unit)
Message
Flash sale: {{amount}}
Individual Fixed Amount Discounts
Each product has its own dollar-off value.
Create metafield
custom.amount_off (money)
Discount type
Fixed Amount
Link Discount value
Point at custom.amount_off
Message
Save {{amount}} on this item
Bundle Builder with Line Properties
A bundle-builder app writes _bundle_discount onto each cart line. The discount reads it directly — no metafield setup needed on products.
Confirm the property
Check the storefront / app sets properties._bundle_discount on bundle lines
Link Discount value
Click the link icon, choose the line property, and pick _bundle_discount
Behavior
Each bundled line uses its own discount; non-bundle lines are skipped
Advanced Settings — Custom Base Pricing
The Advanced section on the Apply Product Discount block appears only when Discount type is Percentage. It lets you change the price the percentage is calculated from.
Enable Advanced Settings
Optional — Percentage only
Toggle the Advanced Settings switch on the block to reveal the fields below.
Discount base price
Required when Advanced is on
The field or metafield whose value replaces the regular product price when computing the percentage discount. Supports the same source selector as linked fields — metafields (product, variant, customer, company, shop), attributes, and JSON subfields.
Use cases:
- Wholesale pricing — discount from the wholesale cost, not retail
- Member base price — VIP discounts computed from a member-only price
- Compare-at driven savings — always discount against the compare-at price
Note
Only numeric metafields and fields are selectable here. For JSON metafields, pick the numeric subfield.
Calculate target price from base field
Optional
Changes how the percentage interacts with Discount base price.
- Off (default) — the percentage is applied to the base price, and the resulting amount becomes the discount. Example: 25% of
$80wholesale =$20off the line’s regular price. - On — the percentage computes a target price from the base field, and the discount brings the item to that target. Example: 50% off a
$120compare-at price targets$60; the line is discounted to$60regardless of its current price.
This is the cleanest way to implement “half-off compare-at” style pricing.
Combining Features
Base pricing and linked discount values stack freely. For maximum flexibility:
- Base price from metafield A + Discount value from metafield B → per-product wholesale pricing with per-product percent off
- Base price from metafield + static percent → uniform discount against a custom base
- Linked discount value + default base price → per-product percentages against the regular price
Important Considerations
Warning
Products without the linked metafield or attribute receive no discount — they’re skipped entirely. This is intentional, but make sure your catalog data is complete before launching.
- Percentage metafield values are whole numbers (
20, not0.20) - Money/amount metafields use the store’s currency; currency conversion is handled at checkout
- Linked fields must be included in the function’s input configuration before they can be selected
- JSON metafields expose subfields after you select the metafield and pick the subfield key
Troubleshooting
Discount isn’t applying to some products
- Check that the metafield or property is actually set on those products or lines
- Verify the metafield is included in the function’s input configuration
- For attributes/properties, confirm the storefront or app is writing them correctly
Wrong discount amount
- Double-check the metafield value on the product — whole number for percentages, currency amount for money fields
- For JSON metafields, confirm the correct subfield key is selected
- If using Advanced Settings, remember the percentage is applied to the base price, not the regular price (unless Calculate target price from base field is on, which targets an absolute price)
“Available for metafield input only” message in Advanced
The block requires a metafield input to be configured on the function before Advanced Settings can be used. Add a metafield input on the function’s input configuration, then reopen the block.
Related Documentation
- Basic Discount Settings — discount type, value, message, strategy
- Quantity Logic — per-line and per-cart quantity caps, also linkable
- Cart Line Groups — targeting specific products
- Volume Tiered Discounts — tier-based pricing