Buy X Get Y Shopify Functions: The Free No-Code Way

Native BXGY caps out at one tier per discount. Here's how Shopify Functions and a free app remove that limit without writing code.

A merchant posted the same question on Shopify's developer forum that comes up constantly: how do you run a Buy X Get Y discount on a subscription product now that Scripts are gone. The answer used to be "write a custom Shopify Function." That's no longer the only answer.

Here's how Buy X Get Y actually works on Shopify Functions, where native BXGY runs out of road, and how to build advanced versions without a developer.

What is a Buy X Get Y discount on Shopify?

A Buy X Get Y discount rewards a customer with a free or discounted item after they meet a purchase condition, and Shopify supports it natively as a built-in discount type. You set what the customer needs to buy (a quantity or a minimum spend, from specific products or collections), then what they receive in return, free, a percentage off, or a fixed amount off. Shopify's Buy X get Y discount documentation covers the full native setup: choose a discount code or automatic discount, define the "customer buys" condition, then the "customer gets" reward.

It's a proven mechanic. Retailers have used variations of it for decades to move inventory and lift average order value, and Shopify's own guidance treats it as one of the platform's core discount types alongside amount-off and free shipping. Shopify's general discount types overview groups Buy X Get Y with percentage-off and free shipping as the three foundational discount categories every store can build on without an app.

Where does native Buy X Get Y fall short?

Shopify's native Buy X Get Y discount supports only one tier per discount, so running both "Buy 2 Get 1" and "Buy 4 Get 2" as a single promotion isn't possible without stacking separate discounts or using Shopify Functions. That's a real limitation for merchants who want a graduated offer. You either create multiple discounts and hope they don't conflict, or you build custom logic.

There's a second, less obvious gap: products inside an active Buy X Get Y discount are ineligible for additional product discounts, per Shopify's own combining-discounts documentation. If a discount code would apply to a product that's part of a live BXGY offer, Shopify removes the BXGY discount entirely and applies only the code. That's the kind of edge case that quietly breaks a promotion during a sale you didn't test carefully enough.

There's also a checkout-mechanics limitation worth knowing before you build anything: native automatic discounts require the customer to add every eligible item to their cart themselves, as Shopify's automatic discounts documentation explains. The "get" item in a BXGY promotion doesn't add itself. If a customer qualifies but never manually adds the reward product, they simply don't receive it, and the store doesn't know the promotion underperformed until someone reviews conversion data.

How does Shopify Functions handle Buy X Get Y differently?

Shopify Functions treats Buy X Get Y as one of the actions available inside the Discount Function API, which means a Function-based app can combine it with the same condition logic used for every other discount type, something native BXGY can't do. Instead of a single fixed rule, a Function evaluates cart data (line items, quantities, tags, customer segment) against custom logic and returns the discount operation. Shopify's Discount Function API documentation confirms Buy X Get Y-style logic falls under the Product discount class, alongside tiered pricing and exclusions.

The catch has always been that building a custom Function means Shopify CLI, a compiled language, and a developer. That's the gap free no-code apps close. Shopify's own tutorial for building a discount function walks through exactly that process, scaffolding with the CLI, writing the run-target logic, deploying through the Partner Dashboard, and it's genuinely developer-oriented documentation, not something a merchant configures directly.

Building a multi-tier Buy X Get Y rule without a developer

Flowly: Discount Functions builds Buy X Get Y logic on a visual canvas of Start, Condition, and Apply Discount nodes, letting you create tiered BXGY rules that native Shopify can't run as a single discount. It's a free Subscribfy app built on the Discount Function API. Here's how to build a two-tier BXGY structure, "Buy 2 Get 1 at 50% off" and "Buy 4 Get 2 free":

  1. Create the first rule. Add a Start node, a Condition node set to Line Quantity (2 or more), and an Apply Discount node set to Buy X Get Y, targeting the Product class.

  2. Create a second rule for the higher tier. Condition set to Line Quantity (4 or more), Apply Discount set to Buy X Get Y with a higher reward.

  3. Set the selection strategy to Maximum on both, so a customer who qualifies for tier two automatically gets the better deal instead of the first-matching rule.

  4. Add a Product Tag or Collection condition with AND logic if the offer should only apply to specific products.

  5. Save. Flowly validates the flow before saving and syncs the rule onto the live Shopify discount, applying it in real time.

Because conditions combine through AND/OR/NOT logic across 12 fields (cart subtotal, item count, line quantity, line price, product tag, product vendor, collection, variant SKU, delivery country, customer segment, customer tag, order count), the same builder handles BXGY offers restricted by customer segment, delivery country, or order history, none of which native Buy X Get Y supports.

Native BXGY vs. custom Shopify Function vs. Flowly


Native Shopify BXGY

Custom-built Function

Flowly

Cost

Free

Developer time

Free

Multiple tiers in one promotion

No

Yes

Yes

Targeting by customer segment/tag

No

Yes

Yes

Combine with subtotal or quantity conditions

Limited

Yes

Yes

Coding required

None

Rust/JS + WebAssembly

None

Runs on Shopify Functions infrastructure

No

Yes

Yes

FAQ

Can Buy X Get Y apply to subscription products?

Yes. Shopify added Buy X Get Y support for subscription products, letting merchants offer a free or discounted product when a customer subscribes. This runs through Shopify's native discount system, separate from what a Functions-based app configures for one-time purchases.

Can I set a fixed dollar amount off instead of a free item or percentage?

Yes, natively. Shopify supports fixed amount discounts for Buy X Get Y, letting merchants create offers like "buy 2 items, get $10 off" as either an automatic discount or a code.

Does the free "Y" item get added to the cart automatically?

Not with native Shopify discounts. The customer has to add both the qualifying and reward items themselves. Automating that add-to-cart step for a Buy X Get Y offer generally requires a dedicated app or a Functions-based cart transform.

How many discount functions can run at once for BXGY-style logic?

Up to 25 active discount functions per store, per Shopify's Discount Function API documentation, shared across every discount class, not exclusive to Buy X Get Y.

Do Buy X Get Y discounts work in physical retail through Shopify POS?

Discount functions, including BXGY-style logic, became available on Shopify POS after previously being limited to online checkout. Any previously created Functions-based discount is automatically eligible on POS, though it may need to be published for smart grid tile linking in-store.

The move from Scripts to Functions genuinely opened up more BXGY flexibility than most merchants realize, it just requires a builder instead of Ruby. Download Flowly directly from the Shopify App Store to build your first tiered BXGY rule, or book a call with Subscribfy's team if you want a hand mapping your old Scripts logic to Flowly's condition set.

Image

Book a meeting with our sales team now!

Create predictable revenue from the customers you already have.