All guides › Any 4 for $99 (mix and match)

"Any 4 for $99" on Shopify when the products have different prices

Disclosure: I build No-App Sections; this guide was written with AI assistance. The code on this page was written for this guide. It passes Shopify's Theme Check inside Dawn 16.0.0 and automated tests in headless Chrome, run against Dawn's own cart and variant events with mocked store data. It hasn't been run on a live store yet, so try it on a duplicate theme first.

Short answer first, because it decides everything else: Shopify's built-in discounts can't charge exactly $99 for any 4 products when those products have different prices. They can take a percentage or a fixed amount off once the shopper has 4 items from a collection, but not "make the total $99". If $99 matters, you need Shopify Functions, which in practice means an app. If something close is fine, the native offer below works on every plan and has a cart message you can add without an app.

Why a percentage can't equal $99

Say the range has products at $20, $25, $30 and $40. "Any 4 for $99" means a different saving for every basket:

Basket of 4Full priceSaving to reach $99As a %
$20 + $25 + $30 + $40$115$1613.9%
4 × $30$120$2117.5%
4 × $40$160$6138.1%
4 × $20$80−$19 (a price rise)n/a

One percentage can't fit all four rows. A fixed $X off can't either. The last row is a trap: a basket that's already under $99 must be left alone, which any real "4 for $99" logic has to handle.

What you can do natively

OfferNative?How
Any 4 from the range, save 20%YesAmount off products, % off, applies to a collection, minimum quantity of items 4. Only items from that collection count towards the 4.
Any 4 for $99, all products the same pricePartlyWith every product at $30, $21 off "once per order" with a minimum of 4 gives $99 for 4. But 8 items still get only $21 off, and 5 items cost $129.
Any 4 for $99, mixed pricesNoNeeds a Shopify Functions discount (below).

For most shops the honest move is to change the offer to the first row and say it plainly: "Any 4 from the range, save 20%". It's easy to understand, it's always a real saving, and it's correct for 5, 6 or 10 items.

Tell shoppers how close they are

A collection discount is invisible until it kicks in. This snippet sits in Dawn's cart footer and says either "Add 2 more from the any 4, save 20% range to unlock the offer" with a progress bar, or, once Shopify has applied the discount, "Any 4, save 20%: you're saving $23.00 on this order". It only counts items from the offer's collection, and the saving it shows is read from Shopify's own discount on the cart lines, never worked out by the theme. So it can't promise a saving the checkout won't give.

{%- comment -%}
  snippets/mix-and-match-progress.liquid: cart message for a native "buy any N from a collection" discount.
  Render it inside <div class="js-contents"> in sections/main-cart-footer.liquid: Dawn re-renders that
  wrapper after every quantity change, so this is plain Liquid with no JavaScript.
  The saving shown is read from Shopify's own discount allocations, never calculated here.
  Keep offer_collection, offer_min and discount_title identical to the automatic discount in your admin.
{%- endcomment -%}
{%- liquid
  assign offer_collection = 'mix-and-match'
  assign offer_min = 4
  assign offer_label = 'any 4, save 20%'
  assign discount_title = 'Any 4, save 20%'

  assign eligible = 0
  assign saved = 0
  for item in cart.items
    for c in item.product.collections
      if c.handle == offer_collection
        assign eligible = eligible | plus: item.quantity
        break
      endif
    endfor
    for allocation in item.line_level_discount_allocations
      if allocation.discount_application.title == discount_title
        assign saved = saved | plus: allocation.amount
      endif
    endfor
  endfor
  assign missing = offer_min | minus: eligible
  assign shown = eligible
  if shown > offer_min
    assign shown = offer_min
  endif
  assign show_box = false
  if saved > 0
    assign show_box = true
  elsif eligible > 0 and missing > 0
    assign show_box = true
  endif
-%}
{%- if show_box -%}
  <div class="mix-progress" role="status">
    {%- if saved > 0 -%}
      <p class="mix-progress__text">{{ discount_title | escape }}: you're saving {{ saved | money }} on this order.</p>
    {%- elsif missing > 0 -%}
      <p class="mix-progress__text">
        Add {{ missing }} more from
        <a href="{{ routes.collections_url }}/{{ offer_collection }}">the {{ offer_label | escape }} range</a>
        to unlock the offer.
      </p>
      <progress class="mix-progress__bar" max="{{ offer_min }}" value="{{ shown }}">{{ shown }} of {{ offer_min }}</progress>
    {%- endif -%}
  </div>
{%- endif -%}
<style>
  .mix-progress { margin: 0 0 1.5rem; text-align: left; }
  .mix-progress__text { margin: 0 0 0.6rem; }
  .mix-progress__bar { width: 100%; height: 0.6rem; accent-color: rgb(var(--color-foreground)); }
</style>

Dawn re-renders the cart footer after every quantity change, so the message updates without a reload and needs no JavaScript.

Install it

  1. Put the offer products in one collection. Create a collection (for example handle mix-and-match) with only the products in the offer. Its URL is where the message links to.
  2. Create the automatic discount. In Discounts → Create discount → Amount off products, choose Automatic discount, title it exactly "Any 4, save 20%", choose Percentage 20 and Applies to: Specific collections (your collection). Under minimum requirements choose Minimum quantity of items: 4. Save.
  3. Create the snippet file. In Online Store → Themes → … → Edit code, add a new snippet called mix-and-match-progress and paste the code above. Set offer_collection, offer_min and discount_title to match the discount.
  4. Render it in the cart footer. Open sections/main-cart-footer.liquid, find <div class="js-contents">, and add {% render 'mix-and-match-progress' %} just inside it. Save.
  5. Test the steps. Add 1, then 3, then 4 items from the collection: the message counts up, then switches to the saving. Add an item from outside the collection: the count doesn't change.

When you really need "4 for $99"

  • A discount app built on Shopify Functions. Functions are the only way to run your own discount logic at checkout. Public apps from the Shopify App Store that use Functions work on any plan. Many "bundle" and "mix and match" apps do this, and most aren't free.
  • Your own Function. A custom app with its own discount Function is only available on Shopify Plus. Off Plus, you'd have to publish it as a public app.
  • Bundles with fixed contents. If "any 4" can become "this set of 4", Shopify Bundles (free, by Shopify) sells a fixed bundle at a fixed price.

Whichever you choose, the snippet above still works for the message as long as the app's discount title matches discount_title.

Nothing to buy here

No-App Sections doesn't sell a bundle or quantity-break section, and a fixed "4 for $99" isn't something theme code can do. If you want a free, tested cart message for a spend threshold rather than an item count, the free shipping bar section is free.

Browse all guides Get the free section

FAQ

Can I do "any 4 for $99" with a Buy X get Y discount?

Not exactly. Buy X get Y gives some items free or a % off, so the total still depends on which products were picked. "Buy 3, get the cheapest free" is native and close in spirit, but it isn't $99.

Does a 5th item get the 20% too?

Yes. Once the minimum is reached, every eligible item in the cart is discounted. That's why the message says "save 20%" and not "4 for".

Do items outside the collection count towards the 4?

No. With the discount applied to a specific collection, only items from that collection count towards the minimum quantity and get the discount.

Can I run several offers at once?

Yes, up to 25 automatic discounts can be active at a time. Check Combinations so two offers don't stack in a way you didn't plan, and render the snippet once per offer with different settings.

Why doesn't the message show on an empty cart?

It appears once there's at least one item from the offer in the cart. Before that it would be an advert, which belongs on the collection page instead.