Tom Sailors
· Refreshed
Brief · Anonymized case study

Bulk Quantity Discount Engine

Build a Cart Transform Function that reads bulk-pricing tiers stored on each product metafield and applies the appropriate discount to each line. Display the tier thresholds and savings amounts in the cart drawer and on product pages so customers see the incentive to increase order quantity.

A wholesale-focused or high-volume DTC merchant needs to apply tiered discounts automatically as customers increase cart quantity, without requiring discount codes. The discount structure varies by product and should be stored centrally for easy management and real-time display.
Four pieces
Cart & Checkout

Bulk Tier Reader

Reads the bulk pricing tier data stored on each product and matches it against what is in the cart at checkout time.

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 based on current quantity.

Function script
Storefront

Real-Time Cart Preview

Displays the exact savings at each tier as customers adjust quantity in the cart drawer or on product pages, making the discount structure transparent.

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 form-driven admin interface where bulk tiers can be set for each product; the Cart Transform Function reads and applies them 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 the 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 →