Quantity Price Breaks Function
This is a Shopify Function, not a theme app extension. It runs server-side at checkout and applies a product discount. The grouping here is alongside the storefront blocks so all of PromoSync’s storefront-facing extensions live in one place.
The Quantity Price Breaks Function is the server-side half of PromoSync’s volume pricing. It reads each variant’s tier-price array from the psrestful.part_price_array metafield, decides which tier the line qualifies for based on cart quantity, and applies a product discount that brings the line’s effective unit price down to that tier.
Without this Function, the Volume Pricing Theme Extension on the product page would show price tiers that the cart never actually honors. The Function is what makes the discount real.
Overview
| Property | Value |
|---|---|
| Extension type | Shopify Function (product discount) |
| Extension name in Shopify | Quantity Price Breaks |
| Discount name in Admin | Quantity Price Breaks (automatic discount) |
| Data source | psrestful.part_price_array metafield on each variant |
| Mode source | volume_pricing_mode shop setting (passed as Function configuration) |
| Activated by | Enable Volume Pricing checkbox in Volume Pricing settings |
| Discount target | Individual cart lines (variants), as fixed-amount per-unit reduction |
How It Calculates the Discount
For each cart line:
- The Function reads the variant’s
psrestful.part_price_array(a JSON array of{ quantityMin, price }objects, with prices in cents). - It determines the effective quantity based on the configured mode (see below).
- It picks the tier whose
quantityMinis the highest value still less than or equal to the effective quantity. - It computes the per-unit discount:
(currentUnitPrice - tierPrice). - If the discount is positive, it applies a fixed amount product discount of that size, targeting just that variant.
If the variant has no psrestful.part_price_array, or if the currently listed price is already at or below the matching tier price, the line is left alone.
Per-Variant vs Combined-by-Product
The Function reads its mode from the shop’s volume_pricing_mode setting, configured under Volume Pricing settings.
Per-variant mode (default)
Each cart line’s effective quantity is just its own line quantity. Two lines of the same product are treated as two independent purchases when deciding tiers.
Cart:
Red Polo × 4 → effective qty 4 → 1+ tier → $20/unit
Blue Polo × 4 → effective qty 4 → 1+ tier → $20/unitCombined-by-product mode
Before deciding tiers, the Function pre-computes a total quantity per parent product ID across every cart line. Each line then uses the parent product’s combined total as its effective quantity.
Cart (combined-by-product mode):
Red Polo × 4 ┐
Blue Polo × 4 ├─→ combined qty 12 for the polo → 12+ tier → $15/unit per line
Green Polo × 4 ┘This is the common pattern for apparel and other products where customers mix colors and sizes of the same item but expect quantity discounts to apply across the mix.
Screenshot needed: Checkout breakdown for combined-by-product mode showing three variant lines of the same product all getting the higher-quantity tier price. Save to /public/images/volume-pricing-combined-by-product.png.
Where the Discount Appears
When Enable Volume Pricing is on, the Function is wired up as an automatic discount in your store’s Discounts section, named Quantity Price Breaks.
Screenshot needed: Shopify Admin Discounts page showing the active Quantity Price Breaks automatic discount row. Save to /public/images/volume-pricing-discount-in-admin.png.
At checkout, qualifying lines show the discount as a line-level price reduction.
Screenshot needed: Checkout breakdown showing the Quantity Price Breaks discount applied to a single cart line in per-variant mode. Save to /public/images/volume-pricing-checkout-discount.png.
Activating and Deactivating
You don’t install the Function or manage the discount by hand. The lifecycle is driven entirely by the Enable Volume Pricing checkbox in Volume Pricing settings:
| Action in PromoSync | What happens in your Shopify store |
|---|---|
| Turn Enable Volume Pricing ON | PromoSync calls the Discounts API to create an automatic discount linked to the Function. The discount appears in Discounts and starts firing immediately. |
| Switch the Mode | PromoSync updates the discount’s configuration metafield in place. The same discount keeps running with the new grouping behavior. |
| Turn Enable Volume Pricing OFF | PromoSync removes the automatic discount via the Discounts API. The Function is still deployed but no longer wired into checkout. |
Don’t edit the Quantity Price Breaks automatic discount directly in Shopify Admin. PromoSync owns it; manual edits can desync the discount from the toggle and leave it in a half-configured state. To pause discounting, untick Enable Volume Pricing in PromoSync settings.
Relationship With the Display Block
The Volume Pricing Theme Extension and this Function are two halves of the same feature:
| Display block | This Function | |
|---|---|---|
| Where it runs | Browser, on the product page | Shopify’s server, at checkout |
| What it does | Renders the tier-price table for the visible variant | Applies the actual per-unit discount on cart lines |
| Reads from | psrestful.part_price_array | psrestful.part_price_array |
| Required for the feature? | No, optional UX | Yes, to actually deliver the tier price |
Because both halves read the same metafield, the table the shopper sees on the product page matches the discount applied at checkout, as long as the metafield is current. After editing pricing rules, run Update Metafields on the affected products to refresh both halves together.
Why a Variant Might Not Be Discounted
| Reason | What’s happening | What to do |
|---|---|---|
Variant has no psrestful.part_price_array | The supplier didn’t publish PPC tiers and no Tier Pricing Rule matches the product. | Either run Update Metafields after adding a Tier Pricing Rule, or accept the line will be sold at its listed price. |
| Current Shopify price is already at or below the tier price | There’s nothing to discount; the Function only goes down, never up. | This is the expected behavior. |
| Enable Volume Pricing is off in settings | The discount isn’t installed; no Function is consulted at checkout. | Tick the box in Volume Pricing settings. |
| Cart contains only one variant of a product in combined-by-product mode | Combined quantity equals line quantity, so it behaves like per-variant mode. | This is the expected behavior. |
| Variant’s tier array is malformed | The Function defensively skips any line whose tier data it can’t parse. | Re-import the product or run Update Metafields to rebuild the array from current data. |
Related
- Volume Pricing settings: the toggle and mode dropdown that drive this Function’s lifecycle.
- Volume Pricing Theme Extension: the storefront table that shows tier prices to shoppers on the product page.
- Tier Pricing Rules: how to populate
psrestful.part_price_arrayfor products whose supplier doesn’t publish tier data. - Update Metafields: how to refresh tier data on existing products after editing rules.