How We Built JellyBean's Free Gift With a Shopify Discount Function

“Spend a little more, get a free gift” sounds simple. For JellyBean Tanning it had to work across several markets, let customers choose their gift, and never give away more than intended.

Here's how we built it with a custom Shopify Discount Function and a smarter side cart.

How it works

  1. Spend to unlock. A two-step progress bar in the side cart shows how close the customer is to free shipping and a free gift.
  2. Choose a gift. Once the threshold is reached, the cart lets them pick from a short list of approved gifts.
  3. Free at checkout. A Shopify Discount Function checks the cart and makes exactly one gift free.
JellyBean side cart in three steps: progress towards the free gift, the gift picker unlocked, and the chosen gift shown as free

1

Free gift per order, enforced at checkout.

Per market

Thresholds the team manages in Shopify admin.

33

Automated tests protecting the gift rules.

Why checkout makes the final call

The storefront can suggest a gift, but only Shopify checkout decides whether it's free. Every cart is checked again:

  • Only approved gift products can be free.
  • The gift never counts towards its own threshold.
  • Only one unit is ever free, even if more are added.
  • If anything looks wrong, no gift is applied.
A Shopify Discount Function checks the cart: approved gift, gift excluded from threshold, market threshold reached and only one unit free; if all pass one gift is free, otherwise no gift.

A cart that stays in sync

  • Every cart change re-checks the gift, including changes made by bundle and quiz apps.
  • Swapping gifts never leaves the cart without one.
  • Checkout waits for a moment while the gift updates.
  • The gift only shows as FREE once Shopify has actually applied the discount.

The takeaway

Each market's threshold is managed in Shopify admin, so the JellyBean team can change the offer without a developer, while 33 automated tests protect the rules behind it.

Read the JellyBean Tanning case study.

Case StudySpell&Sell
Spell&Sell
  • Fraud-proof gift rules
  • Market-aware thresholds
  • 33 automated tests
2 min read