Conditional Discount
Overview
The Conditional Discount function follows a straightforward “if X is true, apply discount Y” pattern. It is the simplest and most common discount type in Advance Discount Function, covering the majority of promotion scenarios merchants encounter.
- Discount Classes: Product, Order, Shipping
- Billing: Starter plan and above
- Condition Support: Full set — all 18 conditions (9 cart-level + 9 product-level)
Because the Conditional Discount supports all three discount classes and the complete condition library, it is the go-to function for most promotions. If your discount logic does not require escalating tiers, buy/get mechanics, or bundle validation, the Conditional Discount is the right choice.
Real-Life Use Cases
1. 10% Off Orders Over $100
A classic order-level promotion. When the cart subtotal exceeds $100, every customer receives a flat 10% order discount.
- Condition:
cartSubtotalgreater than or equal to100 - Target: Order
- Discount: Percentage, 10%
2. Free Shipping for VIP Customers
Reward loyalty program members with free shipping on every order. Customers tagged “VIP” in Shopify automatically qualify.
- Condition:
customerTaghasAny["VIP"] - Target: Shipping, scope “all”
- Discount: Percentage, 100%
3. 15% Off All “Sale” Tagged Items
Run a site-wide sale that only applies to products you have tagged. Non-sale items in the same cart remain full price.
- Condition:
productTaghasAny["Sale"] - Target: Product, scope “filtered” (only tagged items receive the discount)
- Discount: Percentage, 15%
4. $5 Off for First-Time Customers
Welcome new shoppers with a small incentive. Shopify exposes the customer’s historical order count, so you can target those who have never placed an order.
- Condition:
customerOrderCountequals0 - Target: Order
- Discount: Fixed amount, $5
5. 20% Off a Specific Collection When Cart Has 3+ Items
Combine cart-level and product-level conditions using AND logic. The customer must have at least 3 items in the cart, and the discount applies only to products in the designated collection.
- Conditions (AND):
cartTotalQuantitygreater than or equal to3collectionhasAny["Summer Essentials"]
- Target: Product, scope “filtered”
- Discount: Percentage, 20%
How It Works
Execution Flow for Cart Lines (Product and Order Discounts)
- Read configuration — The function loads the JSON metafield containing version, strategy, rule groups, and rejection rules.
- Evaluate rejection rules — If any rejection rule matches, the function exits early with no discount.
- Check discount classes — Determine whether the current run targets product discounts, order discounts, or both.
- For each rule group:
- Evaluate the group’s conditions against the cart and customer context.
- Filter eligible cart lines based on product-level conditions (tags, collections, etc.).
- Build discount candidates for each qualifying line or the order total.
- Strategy check — Apply the configured strategy (
first,best, orall) to determine which rule group’s discounts are returned.
Execution Flow for Delivery Options (Shipping Discounts)
- Check shipping class — Confirm the discount is configured to apply to shipping.
- For each rule group:
- Evaluate cart-level conditions (product-level conditions do not apply to shipping).
- Resolve the shipping scope (
alldelivery options or specific ones). - Build the delivery discount output.
Step-by-Step Setup
The following walkthrough creates a “Summer Sale 20% Off Tagged Products” discount.
Step 1: Create the Discount
Navigate to Shopify Admin > Discounts > Create discount. Choose either Automatic discount or Discount code. In the app selection, pick Conditional Discount Function.
Step 2: Add Conditions
In the rule builder, add a product-level condition:
- Type:
productTag - Operator:
hasAny - Value:
["summer-sale"]
This ensures only products carrying the “summer-sale” tag are eligible.
Step 3: Set the Target
Configure the discount target:
- Class: Product
- Scope: Filtered (only items matching the condition receive the discount)
Step 4: Set the Discount Value
- Type: Percentage
- Value: 20
- Message: “Summer Sale 20% OFF”
The message appears in the cart and checkout UI so customers understand why the price changed.
Step 5: Save
Click Save to activate the discount. It takes effect immediately for automatic discounts or when the code is entered for code-based discounts.
Configuration Example
The following JSON represents the complete configuration for the Summer Sale discount described above.
{
"version": "1.0",
"strategy": "first",
"productTags": ["summer-sale"],
"ruleGroups": [
{
"id": "rg_001",
"name": "Summer Sale",
"enabled": true,
"conditionLogic": "and",
"conditions": [
{
"type": "productTag",
"operator": "hasAny",
"tags": ["summer-sale"]
}
],
"targets": {
"product": { "scope": "filtered" }
},
"discount": {
"type": "percentage",
"value": 20,
"message": "Summer Sale 20% OFF"
}
}
],
"rejectionRules": []
}
Key Fields
| Field | Purpose |
|---|---|
version | Configuration schema version. Always "1.0" for current releases. |
strategy | How to handle multiple matching rule groups: "first" (stop at the first match), "best" (pick the largest discount), or "all" (apply all matches). |
productTags | Top-level declaration of tags the function needs to query. Required for Shopify’s input query. |
ruleGroups | Array of rule group objects, each containing conditions, targets, and discount definitions. |
conditionLogic | "and" requires all conditions to pass. "or" requires at least one. |
rejectionRules | Array of conditions that, if matched, prevent any discount from being applied. |
Multi-Rule Example: VIP + General Discount
This configuration demonstrates two rule groups within a single discount function. The strategy is set to "first", meaning the function evaluates rule groups in order and stops at the first match. VIP customers receive 30% off; everyone else gets 10% off orders over $50.
{
"version": "1.0",
"strategy": "first",
"ruleGroups": [
{
"id": "rg_001",
"name": "VIP 30% Off",
"enabled": true,
"conditionLogic": "and",
"conditions": [
{
"type": "customerTag",
"operator": "hasAny",
"tags": ["VIP"]
}
],
"targets": {
"order": {}
},
"discount": {
"type": "percentage",
"value": 30,
"message": "VIP Exclusive 30% OFF"
}
},
{
"id": "rg_002",
"name": "General 10% Off $50+",
"enabled": true,
"conditionLogic": "and",
"conditions": [
{
"type": "cartSubtotal",
"operator": "greaterThanOrEqualTo",
"value": 50
}
],
"targets": {
"order": {}
},
"discount": {
"type": "percentage",
"value": 10,
"message": "10% OFF orders over $50"
}
}
],
"rejectionRules": []
}
Because the strategy is "first", a VIP customer with a $60 cart receives 30% off (rule group 1 matches and evaluation stops). A non-VIP customer with a $60 cart skips rule group 1 and receives 10% off from rule group 2. A non-VIP customer with a $30 cart receives no discount.
Shipping Discount Example
Free shipping for orders over $75.
{
"version": "1.0",
"strategy": "first",
"ruleGroups": [
{
"id": "rg_001",
"name": "Free Shipping Over $75",
"enabled": true,
"conditionLogic": "and",
"conditions": [
{
"type": "cartSubtotal",
"operator": "greaterThanOrEqualTo",
"value": 75
}
],
"targets": {
"shipping": { "scope": "all" }
},
"discount": {
"type": "percentage",
"value": 100,
"message": "Free Shipping on $75+"
}
}
],
"rejectionRules": []
}
This applies a 100% shipping discount to all delivery options when the cart subtotal is $75 or more. The scope "all" ensures every shipping method is discounted, not just the cheapest one.
Next Steps
- Tiered Discount — Escalate discounts based on quantity or spending thresholds.
- Buy X Get Y — Create buy-one-get-one and promotional bundle offers.
- Bundle Discount — Require specific product combinations for a discount.