Brief · Anonymized case study
Automatic Bulk Quantity Discount Engine
I'd build a Cart Transform Function that reads bulk pricing tiers stored on each product's metafield and applies the right discount instantly at checkout. On the storefront, I'd add a tier preview widget so customers see their savings threshold before they buy. The whole thing lives in product metadata — no codes, no manual intervention.
A mid-market DTC merchant sells products where bulk purchases are common and wanted a way to apply tiered discounts based on quantity without requiring customers to enter a code. The merchant needed the discount to calculate automatically at checkout and display the savings tiers to customers in real time as they adjusted quantities.
Four pieces
Cart & Checkout
Bulk Tier Reader
Reads the bulk pricing tier data you've stored on each product and matches it against what's in the cart right now.
Shopify Function + metafield
extensions/cart-transform/src/run.graphql
function
query Input {
cart {
lines {
id
quantity
merchandise {
__typename
... on ProductVariant {
id
title
product {
id
title
metafield(namespace: "bulk_pricing", key: "tiers") {
value
}
}
}
}
}
}
}
Store tiers as JSON in the metafield: [{"minQty": 5, "discountPercent": 10}, {"minQty": 10, "discountPercent": 15}]
Cart & Checkout
Tier Discount Logic
Calculates which tier each line qualifies for and computes the exact discount amount per item.
Function script
Storefront
Real-Time Cart Preview
Shows customers the exact savings they'll get at each tier as they change the quantity in the cart or on product pages.
Theme extension + cart drawer
theme/snippets/bulk-tiers-preview.liquid
liquid
{% if product.metafields.bulk_pricing.tiers %}
{% assign tiers = product.metafields.bulk_pricing.tiers | parse_json %}
<div class="bulk-tiers-widget">
<p class="rte"><strong>Buy more, save more:</strong></p>
<ul style="list-style: none; padding: 0;">
{% for tier in tiers %}
<li style="display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #eee;">
<span>{{ tier.minQty }}+ items</span>
<span style="font-weight: bold; color: #27ae60;">{{ tier.discountPercent }}% off</span>
</li>
{% endfor %}
</ul>
</div>
{% endif %}
Render this snippet on the product page and in the cart drawer; update quantity input to re-render and show which tier the customer is about to hit.
Operations
Metafield Setup & Admin Dashboard
A simple form where you set bulk tiers for each product — the Function reads it automatically.
Custom admin app
Admin GraphQL explorer
graphql
# Admin GraphQL — set bulk pricing tiers on a product
mutation SetBulkTiers($ownerId: ID!, $tiers: String!) {
metafieldsSet(metafields: [
{
ownerId: $ownerId
namespace: "bulk_pricing"
key: "tiers"
type: "json"
value: $tiers
}
]) {
metafields {
id
namespace
key
value
}
userErrors {
field
message
}
}
}
# Variables:
# {
# "ownerId": "gid://shopify/Product/123456789",
# "tiers": "[{\"minQty\": 3, \"discountPercent\": 8}, {\"minQty\": 10, \"discountPercent\": 15}]"
# }
Build a simple React form in your admin app that collects tiers and calls this mutation for each product you want to enable bulk pricing on.
Got a similar problem?
Sketch your build in 30 seconds — voice, type, or attach a screenshot.
Sketch the build →