Skip to main content

Guide: Reading from GET Β· ← Conditions Β· Effects β†’

rule_application β€” complete reference

info

Field in the GET response

In GET /discounts and GET /discounts/{id}, this block is returned in **rule_application** (JSON string). After parsing, the internal root is **application.and[]** (not conditions).

On this page​


What it does (and what it does not)​

BlockQuestion it answers
**rule_conditions**When can the campaign come into play? (eligibility: customer, cart, lines, thresholds, …)
**rule_application**Where is the discount applied if the campaign applies? (cart lines and/or a specific additional cost)

rule_application does not replace win conditions: it scopes the effect. It reuses grammar similar to line conditions (conditions.and, array_field: lines, field, values, …) and also supports application on a field under the cart’s **additional_costs**.

Empty vs defined​

rule_application stateBehavior
Empty / absent / nullThe discount may apply to all lines on the cart (per rule_effects.distribution)
With filtersThe discount applies only where the rule indicates (lines and/or an additional_costs.name``)

Typical case: no win conditions, application only​

For a campaign that must discount certain products always (no cart threshold, no minimum qty in conditions, etc.):

  1. Leave **rule_conditions empty** (no eligibility requirements).
  2. Define only the target products (or categories) in **rule_application**.

Conceptual example:

{
"rule_conditions": { "conditions": { "and": [] } },
"rule_application": {
"conditions": {
"and": [
{
"array_field": "lines",
"field": "product_id",
"key": "cart_item_product",
"operator": "in",
"values": [10045, 10046]
}
]
}
},
"rule_effects": "{ ... percentage, distribution: individual_items ... }"
}

Interpretation: β€œThe campaign does not require anything special to β€˜win’; if it is active and the customer qualifies by audience/stackability, the % (or amount) applies only on lines with product_id 10045 or 10046.”

In GET /discounts and GET /discounts/{id}, rule_conditions and rule_application are returned as JSON strings; parse both separately.

Two application families​

FamilyHow to identify itWhat it scopes
Cart linesarray_field: linesProducts, categories, line attributes
Additional costfield: additional_costs.name``A specific charge on the cart’s additional_costs object (e.g. shipping)

Do not use customer conditions (customer.*), country, cart total, payments, etc. in application β€” those belong in rule_conditions.

Nested subconditions on lines: quantity only​

Inside conditions[] on application clauses over lines, only quantity exists. You cannot choose line **total** (unlike rule_conditions, where total may appear).

Subcondition fieldIn rule_conditionsIn rule_application
quantityβœ“βœ“
totalβœ“Not available

Valid example in application:

"conditions": [{ "field": "quantity", "value": 1, "operator": "gte" }]

Grammar shared with line conditions​

ConceptIn rule_conditionsIn rule_application
Catalog productMay require line qty and/or totalDefines which products the effect applies to; typical subcondition: quantity only
Manual product (cart_product_id)SameSame
Category (product_categories)May require qty/totalDefines target categories; subcondition: quantity only
Line attributesWin conditionScopes application (no qty subcondition if not needed)

Reading rules (same as in conditions):

  • **field** defines the data; **key** is informational.
  • cart_item_product = catalog; cart_product_id = manual.
  • Categories: values = feature_pk (taxonomy_slug|external_id). On **product_categories** only, optional **external_values** (taxonomy_slug|external_code) may appear for external systems β€” engine still evaluates on values / feature_ids. Not used on location_categories. Full semantics: external_values in Conditions.
  • Store filters in application (when present) use location_id or location_code the same way as in conditions β€” see location_id vs location_code.
  • bundle / grouped: internal flags β€” ignore the flag value.

Bundle / 2x1: quantity in application​

If rule_effects.rule_group is **true**, the **quantity** subcondition in **rule_application** defines how many units per group receive the effect (e.g. gte 1 = one discounted unit per group formed in win conditions). See Bundle mechanics.

Application on additional_costs​

You can indicate that the effect applies to one specific additional cost on the cart (not a product line).

FieldDescription
fieldPath to the cost: additional_costs.key`` (e.g. additional_costs.delivery when the cart has "delivery": 2.99 inside additional_costs)
operator / valueComparison on that cost amount (e.g. gt + 0 β†’ it exists and is > 0)
keyOften total_cart_without_additional_costs (informational); **field** takes precedence
additional_cost_idInternal ID of the additional cost type (auxiliary; e.g. 34 = shipping in the Company)

Example β€” effect on shipping cost:

{
"conditions": {
"and": [
{
"key": "total_cart_without_additional_costs",
"field": "additional_costs.delivery",
"value": 0,
"operator": "gt",
"additional_cost_id": 34
}
]
}
}

Interpretation: the discount/effect applies to the delivery component of the cart’s additional_costs block (when its value is > 0), not to product lines.

Master reference JSON β€” line application​

Real example with categories, products (catalog and manual), and line attributes:

{
"conditions": {
"and": [
{
"key": "cart_item_product_category",
"field": "product_categories",
"bundle": 1,
"values": ["gaston_interno|106", "frutas|17852"],
"grouped": true,
"operator": "in",
"conditions": [{ "field": "quantity", "value": 1, "operator": "gte" }],
"array_field": "lines",
"feature_ids": [17885, 17852],
"external_values": ["gaston_interno|GI-106", "frutas|code_1", "frutas|code_2"]
},
{
"key": "cart_item_product",
"field": "product_code",
"bundle": 1,
"values": ["12000041", "camisetaGlobo", "croata_01", "croata_02", "undefined"],
"grouped": true,
"operator": "in",
"conditions": [{ "field": "quantity", "value": 1, "operator": "gte" }],
"array_field": "lines",
"product_ids": ["1", "2", "4", "5", "6"]
},
{
"key": "cart_product_id",
"field": "product_code",
"bundle": 1,
"values": ["22333", "98999", "977788"],
"grouped": true,
"operator": "in",
"conditions": [{ "field": "quantity", "value": 1, "operator": "gte" }],
"array_field": "lines"
},
{
"key": "cart_item_attributes",
"field": "attributes.color",
"value": "azul",
"operator": "eq",
"array_field": "lines"
},
{
"key": "cart_item_attributes",
"field": "attributes.product_condition",
"value": "refurbished",
"operator": "neq",
"array_field": "lines"
}
]
}
}

Quick read of the master JSON (application)​

#field / contextInterpretation
1lines β†’ product_categoriesDiscount on lines in categories `gaston_interno
2lines β†’ product_code, catalogListed catalog codes; qtyβ‰₯1
3lines β†’ product_code, manualManually entered codes (cart_product_id); qtyβ‰₯1
4lines β†’ attributes.colorOnly lines with color = azul
5lines β†’ attributes.product_conditionExcludes refurbished lines (neq)

Win conditions + different application (common case)​

The campaign wins with one logic and the discount lands on a subset of lines:

BlockBusiness example
rule_conditionsCart β‰₯ €50 and at least 2 units of Coca-Cola
rule_applicationThe % only on lines in category Snacks

Integration: the cart may meet conditions via Coca-Cola but the discount in the response appears only on Snack lines that satisfy rule_application.

Mandatory application (percentage / ratio)​

For cart **percentage** and **ratio** effects, application is usually required in Owner App (see Create a Discount Campaign β€” Application Conditions). If it is missing and the effect is line-level %, check for incomplete configuration.

Common mistakes β€” rule_application​

ConfusionHow to resolve it
Condition vs applicationrule_conditions = does the campaign apply? Β· rule_application = which lines get the discount?
Copying customer conditions into applicationCustomer/cart go in rule_conditions; application = lines and/or additional_costs
Looking for total in application subconditionIn application only **quantity** exists in conditions[]; line total does not apply
Empty rule_conditions misreadEmpty = no win filters, not β€œcampaign disabled”
Discount not on expected productCheck field + values in application, not only win conditions
Confusing lines with additional_costsarray_field: lines = products; field: additional_costs.X = extra charge (shipping, etc.)
Same product in conditions and applicationValid: conditions require buying it; application limits where it is discounted (may be same list or another)


Next: Effects (rule_effects)