Guide: Reading from GET Β· β Conditions Β· Effects β
rule_application β complete reference
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)
- Empty vs defined
- Typical case: no win conditions, application only
- Two application families
- Nested subconditions on lines:
quantityonly - Grammar shared with line conditions
- Bundle / 2x1:
quantityin application - Application on
additional_costs - Master reference JSON β line application
- Win conditions + different application (common case)
- Mandatory application (percentage / ratio)
- Common mistakes β
rule_application
What it does (and what it does not)β
| Block | Question 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 state | Behavior |
|---|---|
Empty / absent / null | The discount may apply to all lines on the cart (per rule_effects.distribution) |
| With filters | The 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.):
- Leave
**rule_conditionsempty** (no eligibility requirements). - 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 /discountsandGET /discounts/{id},rule_conditionsandrule_applicationare returned as JSON strings; parse both separately.
Two application familiesβ
| Family | How to identify it | What it scopes |
|---|---|---|
| Cart lines | array_field: lines | Products, categories, line attributes |
| Additional cost | field: 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 field | In rule_conditions | In rule_application |
|---|---|---|
quantity | β | β |
total | β | Not available |
Valid example in application:
"conditions": [{ "field": "quantity", "value": 1, "operator": "gte" }]
Grammar shared with line conditionsβ
| Concept | In rule_conditions | In rule_application |
|---|---|---|
| Catalog product | May require line qty and/or total | Defines which products the effect applies to; typical subcondition: quantity only |
Manual product (cart_product_id) | Same | Same |
Category (product_categories) | May require qty/total | Defines target categories; subcondition: quantity only |
| Line attributes | Win condition | Scopes 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 onvalues/feature_ids. Not used onlocation_categories. Full semantics:external_valuesin Conditions. - Store filters in application (when present) use
location_idorlocation_codethe same way as in conditions β seelocation_idvslocation_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).
| Field | Description |
|---|---|
field | Path to the cost: additional_costs.key`` (e.g. additional_costs.delivery when the cart has "delivery": 2.99 inside additional_costs) |
operator / value | Comparison on that cost amount (e.g. gt + 0 β it exists and is > 0) |
key | Often total_cart_without_additional_costs (informational); **field** takes precedence |
additional_cost_id | Internal 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 / context | Interpretation |
|---|---|---|
| 1 | lines β product_categories | Discount on lines in categories `gaston_interno |
| 2 | lines β product_code, catalog | Listed catalog codes; qtyβ₯1 |
| 3 | lines β product_code, manual | Manually entered codes (cart_product_id); qtyβ₯1 |
| 4 | lines β attributes.color | Only lines with color = azul |
| 5 | lines β attributes.product_condition | Excludes refurbished lines (neq) |
Win conditions + different application (common case)β
The campaign wins with one logic and the discount lands on a subset of lines:
| Block | Business example |
|---|---|
rule_conditions | Cart β₯ β¬50 and at least 2 units of Coca-Cola |
rule_application | The % 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β
| Confusion | How to resolve it |
|---|---|
| Condition vs application | rule_conditions = does the campaign apply? Β· rule_application = which lines get the discount? |
| Copying customer conditions into application | Customer/cart go in rule_conditions; application = lines and/or additional_costs |
Looking for total in application subcondition | In application only **quantity** exists in conditions[]; line total does not apply |
Empty rule_conditions misread | Empty = no win filters, not βcampaign disabledβ |
| Discount not on expected product | Check field + values in application, not only win conditions |
Confusing lines with additional_costs | array_field: lines = products; field: additional_costs.X = extra charge (shipping, etc.) |
| Same product in conditions and application | Valid: conditions require buying it; application limits where it is discounted (may be same list or another) |
Next: Effects (rule_effects)