Retrieve discount rules for automated document discounts.
query GetDiscountRule($id: ID) {
DiscountRule(id: $id) {
id
label
active
target
origin { id label }
started_at
ended_at
intervals { id interval_start_type interval_start_value discount_type discount_value }
start_date_condition
end_date_condition
product_tags_condition { id label }
customer_tags_condition { id label }
seasons_condition { id label }
}
}
query DiscountRules(
$where: QueryDiscountRulesWhereWhereConditions,
$orderBy: [QueryDiscountRulesOrderByOrderByClause!],
$search: String
) {
DiscountRules(
where: $where
orderBy: $orderBy
search: $search
) {
id
label
active
target
started_at
ended_at
start_date_condition
end_date_condition
}
}
{
"where": {
"AND": [
{ "column": "ACTIVE", "operator": "EQ", "value": true }
]
},
"orderBy": [
{ "column": "LABEL", "order": "ASC" }
],
"search": "discount rule name"
}
| Field | Type | Description |
|---|
id | Int | Unique identifier of the discount rule. |
label | String | Label of the discount rule. |
active | Boolean | Whether the discount rule is active. |
target | Target | Target of the discount rule (document, product, shipping_cost). |
origin | DiscountRule | Original discount rule this rule is based on. |
started_at | Date | Start date of the discount rule. |
ended_at | Date | End date of the discount rule. |
intervals | [DiscountInterval] | Discount intervals for the rule. |
start_date_condition | Date | Start date condition for the discount. |
end_date_condition | Date | End date condition for the discount. |
product_tags_condition | [ProductTag] | Product tags that must match for the discount. |
customer_tags_condition | [CustomerTag] | Customer tags that must match for the discount. |
seasons_condition | [Season] | Seasons that must match for the discount. |
You can create filters based on following fields
| id - Int |
|---|
Example: { "column": "ID", "operator": "EQ", "value": 100012 } |
| label - String |
|---|
Example: { "column": "LABEL", "operator": "LIKE", "value": "%discount%" } |
| origin_id - ID |
|---|
Example: { "column": "ORIGIN_ID", "operator": "EQ", "value": 100001 } |
| active - Boolean |
|---|
Example: { "column": "ACTIVE", "operator": "EQ", "value": true } |
| target - Target |
|---|
Example: { "column": "TARGET", "operator": "EQ", "value": "product" } |
| started_at - Date |
|---|
Example: { "column": "STARTED_AT", "operator": "GTE", "value": "2025-01-01" } |
| ended_at - Date |
|---|
Example: { "column": "ENDED_AT", "operator": "LTE", "value": "2025-12-31" } |
| condition_start_date - Date |
|---|
Example: { "column": "CONDITION_START_DATE", "operator": "GTE", "value": "2025-01-01" } |
| condition_end_date - Date |
|---|
Example: { "column": "CONDITION_END_DATE", "operator": "LTE", "value": "2025-12-31" } |
You can sort data based on following fields: id, label, condition_start_date, condition_end_date
query SortDiscountRules(
$where: QueryDiscountRulesWhereWhereConditions
) {
DiscountRules(
where: $where
orderBy: [{ column: LABEL, order: ASC }]
) {
id
label
active
target
started_at
ended_at
}
}
{
"data": {
"DiscountRules": [
{
"id": 100001,
"label": "Summer Sale 2025",
"active": true,
"target": "product",
"started_at": "2025-06-01",
"ended_at": "2025-08-31",
"start_date_condition": "2025-06-01",
"end_date_condition": "2025-08-31"
},
{
"id": 100002,
"label": "Bulk Discount",
"active": true,
"target": "document",
"started_at": null,
"ended_at": null,
"start_date_condition": null,
"end_date_condition": null
}
]
}
}
| Field | Type | Description |
|---|
id | Int | Interval ID. |
interval_start_type | IntervalStartType | Type of interval start (amount, quantity). |
interval_start_value | Float | Value for the interval start. |
discount_type | DiscountType | Type of discount (amount, percentage). |
discount_value | Float | Value of the discount. |
| Value | Description |
|---|
document | Discount applies to the entire document. |
product | Discount applies to specific products. |
shipping_cost | Discount applies to shipping costs. |
| Value | Description |
|---|
sales | Rule applies to sales documents only. |
purchases | Rule applies to purchase documents only. |
both | Rule applies to both sales and purchases. |