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
- 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.
- Choose a gift. Once the threshold is reached, the cart lets them pick from a short list of approved gifts.
- Free at checkout. A Shopify Discount Function checks the cart and makes exactly one gift 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 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.



