Pular para o conteúdo

How to Auto-Add a Free Gift When the Cart Hits a Spend Goal (Without Customers Adding It Themselves)

By Stackable TeamPublished on July 24, 2026Discount Strategy#free-gift#spend-goal
How to Auto-Add a Free Gift When the Cart Hits a Spend Goal (Without Customers Adding It Themselves)

Shopify's native Buy X Get Y discount does not add the free gift to the cart for you. It can discount a gift down to $0 once that gift is in the cart, and it can even be triggered by a minimum spend, but the customer still has to notice the offer, find the gift product, and add it themselves. A true auto-add gift-with-purchase, where the gift appears on its own the moment the cart crosses a spend threshold and disappears if the cart drops back below it, needs either custom theme code built on Shopify's Ajax Cart API or an app that does the add-and-remove for you.

This guide explains why native gift-with-purchase falls short, why the manual-add step quietly kills the promotion, how the do-it-yourself Ajax cart approach works and what it costs you to maintain, what to look for in an app, and the one piece of this you can ship reliably today: a live cart progress bar that shows shoppers how close they are to the reward.

Does Shopify automatically add a free gift when the cart hits a threshold?

No, not on its own. Shopify gives you two native building blocks, and neither one auto-adds a product.

The first is a minimum-purchase order discount, which takes money off the order once the cart crosses a spend threshold. That is money off, not a free product.

The second is Buy X Get Y, which can make a specific product free. Since 2019, Buy X Get Y has even supported a minimum purchase amount as the trigger, so you can build a promotion that reads "Spend $100, get a free gift." According to the Shopify developer changelog, this option lets you require a spend amount instead of a specific quantity of items, which sounds exactly like gift-with-purchase.

Here is the catch that trips up almost every merchant who tries it: Buy X Get Y discounts a gift that is already in the cart. It does not put the gift in the cart. The customer has to add the gift product themselves for the discount to fire and zero out its price. If they never add it, they simply do not get the offer, and the discount sits there doing nothing. That gap, between "the discount exists" and "the customer actually receives the gift," is the entire problem this article is about.

IMAGE PLACEHOLDER (Image 1): Native Buy X Get Y versus true auto-add
Suggested visual: A clean 16:9 diagram on a white background, two side-by-side flows. Left flow labeled "Native Buy X Get Y" shows four steps with a red friction icon: cart hits $100, banner appears, customer must find the gift, customer must add it manually. Right flow labeled "Auto-add gift-with-purchase" shows two steps with a green check: cart hits $100, gift appears at $0.00 automatically. Brand colors violet and gold, flat vector, sans-serif labels, no photography.

Why does native Buy X Get Y fall short for a free gift?

Buy X Get Y is a genuinely useful discount, but it was built to price items, not to manage the contents of a cart. That design choice creates three practical gaps for gift-with-purchase.

It discounts the gift, it does not add the gift

This is the core limitation. Buy X Get Y watches the cart, and when the "buy" condition is met (a spend amount or a quantity of qualifying products), it applies a discount to the "get" product. But the "get" product has to be present in the cart for the discount to have anything to act on. Shopify does not inject it. So the offer only works for the subset of shoppers who both notice the promotion and take the extra steps to add the gift.

The customer carries the burden

Every step you ask a shopper to take is a step where you can lose them. A gift-with-purchase that requires the customer to leave what they are doing, navigate to the gift product page, and add it to the cart is asking for effort at exactly the moment they are closest to checking out. Most shoppers will not do it. The ones who would have loved the gift never see it happen, and the incentive you are paying for goes unredeemed.

It cannot remove the gift automatically either

The reverse case is just as messy. Say a shopper does add the gift, then removes an item and drops below the threshold. With a manual setup, the free gift can linger in the cart. Depending on how the discount is configured, it either quietly reverts to full price (an unpleasant surprise at checkout) or stays discounted when the customer no longer qualifies (margin you did not intend to give away). A proper gift-with-purchase has to add and remove the gift in lockstep with the cart total.

Merchants feel this directly. On a widely viewed Shopify Community thread, a merchant asked how to automatically add a free gift once the cart reaches a spend threshold without a third-party app, and the answer came back the same way it always does: native Buy X Get Y exists, but it will not add the gift itself, so you are left with custom code or an app.

Why can't a Shopify Function just add the gift to the cart?

This is the natural next question, because Shopify Functions are the modern, server-side way to customize discounts, and they run inside checkout where everything is reliable. The honest answer is that the discount function can price things but cannot add products.

A Shopify discount function returns discount operations that target existing cart lines. According to Shopify's Discount Function API docs, the function applies a percentage or fixed amount off products or the order, or discounts shipping. It reads the cart and adjusts prices. Nowhere in that model is "insert a new line item," because a discount function's job is to price merchandise the buyer chose, not to change what is in the cart.

The other function that touches the cart is the Cart Transform API. Its documented job is to change the "pricing and presentation of items in a cart," with use cases limited to expanding a bundle into its components, merging lines into a bundle, and updating a line's title, image, or price. It works on lines that already exist. It is not a mechanism for dropping a brand-new gift product into the cart out of nowhere, and some of its operations are limited to development stores or Shopify Plus.

So the server-side toolkit is excellent at making a gift free once it is in the cart and useless at putting the gift there in the first place. Adding a product to a cart happens on the storefront, in the theme, which is why every real auto-add solution ends up running some JavaScript there.

How does the DIY Ajax Cart API approach work?

If you want to build auto-add yourself without an app, the storefront route is Shopify's Ajax Cart API. This is the same lightweight endpoint themes use to add products to the cart without a page reload.

The mechanics

The Ajax Cart API exposes a POST /{locale}/cart/add.js endpoint that adds one or more variants to the cart. Per the Shopify Ajax Cart API reference, you send the variant ID and a quantity, and the item lands in the cart. In practice, a gift-with-purchase built this way looks like this:

  1. A script in your theme listens for cart changes.
  2. When the cart subtotal crosses your threshold, the script calls cart/add.js with the gift variant's ID.
  3. A Buy X Get Y or product discount (native or Functions-based) prices that gift at $0 so the customer is not charged for it.
  4. When the cart drops back below the threshold, the script calls the cart API again to remove the gift.

You pair a storefront script that manages the cart contents with a discount that manages the price. Neither half does the whole job alone.

The maintenance cost

This works, and plenty of stores run some version of it, but it is code you now own forever. A few things to keep in mind before you commit:

  • It is theme-coupled. The Ajax API only works on Shopify-hosted themes, and your script hooks into your specific theme's cart markup and events. Switch themes, or take a theme update that changes the cart drawer, and the script can break silently.
  • You have to guard the edge cases. What happens if the shopper already had the gift product in their cart as a paid item? What if they qualify for two different gifts? What if they change quantities rapidly? Every one of these is a branch you have to write and test.
  • Removal is the hard half. Adding a gift at a threshold is easy. Reliably removing it the instant the cart drops below the threshold, without fighting the customer who is trying to edit their cart, is where DIY implementations get flaky.

The accelerated-checkout gotcha

Here is the failure mode that costs real money, and it is the same trap that hits any storefront-only discount logic. Accelerated checkouts like Shop Pay, Apple Pay, and Google Pay let the buyer skip the cart page entirely and jump straight into checkout. Your theme's JavaScript does not run on that path. So a shopper who taps the Shop Pay button never triggers your add-the-gift script, and the whole promotion silently does not happen for them.

This is why the price side of a gift-with-purchase belongs in a Shopify Function (which runs server-side on every checkout path) even when the add side has to live in the theme. Keep the discount server-side and it applies identically whether the buyer went through the cart page or an accelerated checkout. Put the discount logic in theme JavaScript and you will get one total in the cart and a different one at checkout for your fastest-converting buyers.

IMAGE PLACEHOLDER (Image 2): Where the Ajax script does and does not run
Suggested visual: A 16:9 split illustration. Left panel labeled "Standard checkout" shows a cart page with a green "gift script runs" badge and the gift added at $0.00. Right panel labeled "Shop Pay / Apple Pay" shows a fast-checkout button bypassing the cart page with a red "theme JS never runs" badge and no gift. A caption strip below reads "Storefront scripts skip accelerated checkout. Keep pricing server-side." Brand colors violet and gold, flat vector style, no photography.

What should you look for in a free-gift app?

If DIY sounds like more maintenance than you want, an app is the usual answer. Not all gift-with-purchase apps are built the same way, though. Here is what actually matters.

Auto-add and auto-remove, both

Adding the gift is table stakes. The real test is whether the app removes the gift automatically when the cart falls back under the threshold. Without automatic removal, you get carts that keep a free gift they no longer qualify for, or gifts that quietly revert to full price and surprise the customer. Insist on both directions.

Server-side pricing so cart and checkout agree

Ask how the gift gets priced to $0. If the answer is "our script sets the price on the cart page," you have the accelerated-checkout problem baked in. The reliable pattern prices the gift with a Shopify Function so the $0 holds on the cart page, the checkout page, and Shop Pay alike. The add can happen in the theme; the discount should not.

It works with your other offers

A gift-with-purchase rarely runs alone. You probably also have a sale, a volume tier, or free shipping live at the same time. Check that the gift offer combines cleanly with your other discounts under Shopify's real stacking rules, rather than blocking them or being blocked. (If discount stacking is new to you, our guide on how discount stacking works in Shopify walks through the three discount classes and what combines with what.)

It does not rewrite your catalog

Some apps change product prices to simulate a discount. That is fragile and leaves a mess if you uninstall. The clean approach is a checkout-time adjustment that never touches your real product prices, so removing the app leaves your catalog exactly as it was.

What can you ship reliably today: the spend-goal progress bar

Here is the honest split. The auto-add-and-remove part of gift-with-purchase is genuinely hard, because it depends on storefront cart manipulation that Shopify's server-side tools cannot do. But the part that drives most of the conversion lift, showing shoppers how close they are to the reward, is completely solvable today, and Stackable ships it now.

A spend goal is an order-level discount that pays off once the cart crosses a threshold you set: spend $75 and get 10% off, or spend $100 and get $15 off. Stackable's spend goal feature is built and live, and it comes with a live cart progress bar that reads the real cart total and counts down as the shopper adds items, with no page reload. "You're $12 away from your reward" is the single most effective nudge in a threshold promotion, and it is doing the same psychological work whether the reward is money off or a free gift.

Because the spend goal is computed by a Shopify Function, the reward a shopper sees on the cart page is exactly what checkout charges, including through Shop Pay. There is no cart-versus-checkout drift to chase. And a spend goal stacks as an order-class layer, so it combines cleanly with a product discount or free shipping on the same order.

To be clear about what is and is not available right now: Stackable's auto-add free gift feature, where the gift product itself appears and disappears automatically at a threshold, is on the roadmap and coming soon, not something you can turn on today. The free gift feature page describes exactly how it will work when it ships. What you can run today is the spend-goal reward with the live progress bar, which is the reliable, checkout-safe half of the pattern.

IMAGE PLACEHOLDER (Image 3): Cart progress bar counting down to the reward
Suggested visual: A 16:9 storefront cart drawer mockup. A progress bar near the top is about 80 percent filled in violet, with the label "You're $12 away from your reward." Below it, two cart line items with prices. A gold reward chip at the end of the progress bar reads "10% off." Clean modern e-commerce styling, theme-neutral, brand accent violet and gold, no photography. Reference the docs/screenshot-manifest.md slot spend-goal-step-3 to capture the real widget later.

Worked example: a gift that auto-adds at $75 and auto-removes below it

Let us walk through how a true auto-add gift-with-purchase behaves, so you know exactly what "done right" looks like, and how the spend-goal progress bar supports it today.

A fashion brand wants every order over $75 to include a free tote bag, added automatically. A shopper builds this cart:

  • 1 knit sweater at $58
  • 1 beanie at $22
  • Subtotal: $80

The store runs a gift-with-purchase set to trigger at a $75 cart subtotal, with the tote as the gift.

The two things that make this feel effortless are the two things native Buy X Get Y cannot do on its own: the tote adds itself the moment the cart hits $75, and it removes itself the moment the cart drops below $75. The customer never hunts for the gift and never gets charged for one they no longer qualify for.

Today, the progress-bar half of that experience (the "$17 away" nudge, computed server-side so it matches checkout) is what Stackable's spend goal delivers, paired with a money-off reward. The automatic add-and-remove of the gift product itself is the coming-soon free-gift capability. Framed honestly: you can run the countdown and the reward now, and the auto-adding gift product is on the way.

Run threshold rewards reliably with Stackable

If you want the threshold-reward mechanics to be dependable rather than a theme script you babysit, that is what Stackable is built for, within Shopify's real rules.

  • Spend goals with a live cart progress bar that counts down to the reward as the shopper adds items, with no page reload.
  • The reward is computed by a Shopify Function, so the cart page, the checkout page, and Shop Pay all show the same total. There is no theme-versus-checkout drift.
  • Spend goals stack as an order-class layer, so they combine cleanly with your product discounts and free shipping under Shopify's combination rules.
  • Stackable never rewrites your product prices. Rewards are checkout adjustments only, so uninstalling leaves your catalog untouched.
  • The auto-add free gift feature is on the roadmap and honestly flagged as coming soon, so you always know what is live and what is planned.

Install Stackable free and put a countdown-to-reward in front of your shoppers today at usestackable.com/pricing. 🎁

The bottom line

  • Shopify's native Buy X Get Y does not auto-add the gift. It can price a gift to $0 and can be triggered by a spend amount, but the customer has to add the gift product themselves.
  • The manual-add step is where the promotion leaks. Most shoppers never notice or bother, so the incentive you are paying for goes unredeemed.
  • Server-side functions cannot add a product to the cart. Discount functions only price existing lines, and Cart Transform only expands, merges, or updates lines that are already there.
  • The DIY route is a theme script on the Ajax Cart API that adds and removes the gift, paired with a discount that prices it. It works but is theme-coupled, edge-case-heavy, and skipped by accelerated checkouts.
  • In an app, insist on automatic add and automatic remove, server-side pricing so cart and checkout agree, clean stacking with your other offers, and no rewriting of catalog prices.
  • What you can ship reliably today is a spend-goal reward with a live cart progress bar. Stackable delivers that now, computed server-side so it matches checkout, while the auto-add free-gift feature is honestly flagged as coming soon.

Perguntas Frequentes

Encontre respostas para as perguntas mais comuns

  • No. Shopify's native Buy X Get Y can discount a gift to $0 once that gift is in the cart, and it can be triggered by a minimum spend, but it does not add the gift for the customer. The shopper has to find and add the gift product themselves for the discount to fire. A true auto-add gift needs custom theme code on the Ajax Cart API or an app that manages the cart contents for you.

  • Because Buy X Get Y is a pricing tool, not a cart-management tool. It applies a discount to a "get" product that must already be in the cart. Shopify's server-side discount functions can only adjust prices of existing lines; they cannot insert a new product. Adding a product to a cart happens on the storefront in the theme, which is why native discounts alone can never auto-add the gift.

  • No. A discount function returns discount operations that target existing cart lines, and the Cart Transform function only expands, merges, or updates lines that are already there. Neither can drop a brand-new gift product into the cart. Functions are great at pricing the gift to $0 once it is present, but the add itself has to happen in the theme via the Ajax Cart API.

  • You write a theme script on Shopify's Ajax Cart API. It watches the cart, calls the cart/add.js endpoint to add the gift variant when the subtotal crosses your threshold, pairs with a Buy X Get Y or product discount to price the gift at $0, and calls the cart API again to remove the gift if the cart drops below the threshold. It works, but it is theme-coupled code you have to maintain and test through every theme change.

  • Not the add-the-gift part. Accelerated checkouts like Shop Pay, Apple Pay, and Google Pay skip the cart page, so your theme JavaScript never runs and the gift is never added for those buyers. This is the biggest reason DIY gift scripts fail silently. Keep the discount that prices the gift server-side in a Shopify Function so at least the pricing is consistent everywhere.

  • Yes, automatic removal is essential. Without it you get carts that keep a free gift the customer no longer qualifies for (lost margin) or a gift that quietly reverts to full price at checkout (a bad surprise). A proper gift-with-purchase adds and removes the gift in lockstep with the cart total, so the cart always reflects what the customer actually qualifies for.

  • Yes, and this is the highest-impact part of the whole pattern. A live cart progress bar that reads the real cart total and counts down ("You're $12 away from your free gift") is the single most effective nudge in a threshold promotion. Stackable's spend goal ships this progress bar today, computed server-side so it matches checkout exactly.

  • Not yet. The auto-add-and-remove free gift feature is on the roadmap and coming soon; the feature page describes exactly how it will work. What is live today is the spend-goal reward with a live cart progress bar, which delivers the countdown-to-reward experience with a money-off reward and is computed server-side so cart and checkout always agree.

  • Today a Stackable spend goal rewards a percentage or a fixed amount off the order, not a free product. Adding a free product at a spend threshold is a separate offer type, Free Gift, which is currently coming soon. If you want a threshold incentive you can run right now, a spend goal with a percentage or dollar reward plus the progress bar is the reliable option.

  • It can, if the offers live in different discount classes and each is set to combine. A spend goal is an order-class discount, so it stacks with a product discount and with free shipping on the same order. Two discounts in the same class do not stack. See our guide on how discount stacking works in Shopify for the full rules on what combines with what.

  • That is the intent of a tiered gift-with-purchase, for example a sample at $50 and a full-size gift at $100, showing only the higher-tier gift once the cart qualifies for it. Stackable's spend goal supports multiple thresholds today for money-off rewards (checkout applies the single highest tier the cart qualifies for). Multiple free-gift tiers are part of the coming-soon free-gift feature.

  • A well-built solution should not. The pricing runs server-side in a Shopify Function, and any storefront progress bar should render without heading tags or layout shift. Avoid apps that rewrite your product prices to fake a discount; those are fragile and leave a mess if you uninstall. Look for checkout-time adjustments only, and a lightweight, SEO-safe storefront widget.

Stackable Team

The team building Stackable, the reliability-first bulk and volume discount app for Shopify. We write about discount stacking, Shopify Functions, and how to run promotions that hold up at checkout.

Usamos cookies essenciais para operar este site e, apenas com sua permissão, cookies de análise para entender o tráfego. Leia nossa Política de Cookies.