Functions / 2026-04

Product Discount Functions now support
prerequisites for defining "Buy X"

Product Discount Functions can now set "prerequisites" on discount candidates. This lets you express the "Buy X" side of BXGY (Buy X, Get Y) — for example, "buy 2 of A, get B discounted" — directly in code.

What's on this page
  1. What's actually changing (30-second overview)
  2. What is a BXGY discount (diagram)
  3. Structure of the new prerequisites
  4. Flow diagram: how a discount qualifies
  5. Before vs. after
  6. 5 key points for developers
  7. 3 practical use cases
  8. One-line summary for proposals

1What's actually changing

Discount Functions'product discount candidatesnow have a prerequisites field added.
This lets you declare aprerequisiteinside the Function — "to get this discount, the cart must contain a certain quantity of another product." In other words, you can now express the "Buy X" side of BXGY (Buy X, Get Y).

Before: only the discount target could be specified

Product Discount Functions could express "which product to discount and by how much," but couldn't hold prerequisites like "only if the customer has bought XX."

Now: specify with prerequisites

You can attach prerequisites to a discount candidate. The BXGY logic — "apply this discount only when cart line X has quantity items" — is now fully expressible inside the Function.

2What is a BXGY discount (diagram)

BXGY = Buy X, Get Y. A promotional pattern where "buying a specified quantity of one product (Buy X) discounts another product (Get Y)." Visualized directly from the definition:

Buy X = prerequisite Product A Product A ×2 Purchase specified quantity If satisfied Get Y = discount target Product B Discount This product gets discounted Discount applied
Article definition: "When a customer purchases a specified quantity of one product (Buy X), they receive a discount on another product (Get Y)." What's been added this time is a mechanism for declaring "Buy X" on the Function side.

3Structure of the added prerequisites

On product discount candidates, prerequisites field has been added. Each prerequisite is defined as cartLinePrerequisite and holds two values.

FieldMeaningArticle description
id The identifier of the cart line used as the prerequisite The identifier for the cart line used as the prerequisite.
quantity The quantity required on that cart line in order to qualify for the discount The number of items from that cart line required to qualify for the discount.

Structure image

// On a product discount candidate, // an image of attaching prerequisites { prerequisites: [ { // cartLinePrerequisite id: "<id of the prerequisite cart line>", quantity: 2 // Required quantity (the "X" in Buy X) } ] }
The above is a conceptual image based on the field names (prerequisites / cartLinePrerequisite / id / quantity). Theexact schema, types, and required/optional distinctions are not stated in the article. Before implementation, verify in the Discount Functions documentation.

4Evaluation flow diagram: how a discount gets applied

Cart Multiple cart lines (product + quantity) Discount Function Returns discount candidate + prerequisites Prerequisite check Does the cart line with id have at least quantity items? Satisfied → discount applied Get Y gets discounted Not satisfied → no application Stays at regular price

* The diagram above is id/quantity a conceptual flow assembled from the meaning. The actual evaluation timing and behavior with multiple prerequisites are not stated in the article.

5Before vs. Now

ItemExisting Product Discount FunctionAfter adding prerequisites
Specifying discount targets Yes Which products are discounted and by how much Yes Same as above
"Must have purchased ○○" condition No Candidates cannot carry prerequisites Yes prerequisites Declared with
BXGY's "Buy X" expression No Yes cartLinePrerequisite Defined with
Condition unit Cart line (id) + required quantity (quantity)
Target Function type Product discount candidates

65 key points for engineers

pre

1. Only one field is added

Product discount candidates now have prerequisites added. The way discounts themselves are returned is unchanged — the only difference is that prerequisites can now be attached.Prerequisites can now be "attached"Diff.

id+qty

2. The condition is cartLinePrerequisite

Each prerequisite is represented as cartLinePrerequisite , holding two values:id(the cart line identifier) and quantity(the required quantity).

X Y

3. Buy X and Get Y are separated

Discount target (Get Y) = the candidate itself; prerequisite (Buy X) =prerequisites. Since the two are linked at the candidate level, you can set different conditions per candidate.

?

4. Fine-grained spec is not documented here

Behavior for multiple prerequisites (AND/OR), handling of excess quantities, target API versions, etc. are not specified in the article.Verify in the docs before implementing.

5. The Discount Functions docs are the source of truth

The article directs readers to "see the Discount Functions documentation for details." Field types, required/optional status, and sample implementations live there. Treat the diagrams and code on this page as conceptual overviews only.

7Three practical use cases you can apply to your business

A×2 B
USE CASE 1

Automating bundle sales and cross-sell promotions with Functions

The problem
Running "give a discount on genuine accessories to customers who buy the main product" through apps or manual coupons, which breaks every time products are swapped.
The approach
On the candidates (Get Y = accessories) of a product discount Function, add prerequisites(Buy X = main product), so the discount applies automatically only when the main product is purchased.
The impact
Prevents missed cross-sell opportunities and codifies discount operations (reproducibility and reviewability).
Technical notes
id Set the main product cart line inquantity and the required quantity in. Check the docs for the evaluation spec when multiple conditions apply.
3 Free / discounted
USE CASE 2

"Buy 3, get 1 free"-style bulk purchase promotions

The problem
For consumables and groceries, you want to offer "better deals on bulk purchases," but managing quantity conditions via the storefront or manual discounts is cumbersome.
The approach
Attach a quantity with a threshold (e.g., 3) set on cartLinePrerequisite of the target cart line as a discount candidate, so the discount applies only when the threshold is reached.
The impact
Increases items per order (AOV improvement) through declarative discount logic.
Technical notes
Behavior when the same product is used as both Buy X and Get Y should be confirmed in the docs (not covered in this article).
USE CASE 3

Moving away from third-party discount apps and consolidating on Functions

The problem
Subscribing to a third-party discount app solely to enable BXGY, leaving monthly costs and black-box behavior as technical debt.
The approach
Now that BXGY's "Buy X" can be expressed natively in a Function, consider migrating to a self-managed Discount Function.
The impact
Reduces app costs, brings discount logic in-house with version control, and makes checkout behavior transparent.
Technical notes
Migration feasibility depends on reconciling the existing app's discount spec with what the Function supports. Verify the gaps in the Discount Functions docs.

8One-line summary for pitching

"The candidates for product discount Functions now include prerequisites(cartLinePrerequisite = id+quantity). Added.
With this, you can natively express BXGY's "Buy X" — "buy N of A, get B at a discount" — in a Function.
It applies to bundle sales, bulk purchases, and graduating from third-party discount apps."