Discount Rules Queries

Retrieve discount rules for automated document discounts.

DiscountRule — Returns a single discount rule based on the id provided

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 }
    supplier_tags_condition { id label }
    suppliers_condition { id label }
    conditions_operators { conditionable_type operator }
  }
}
{
  "id": 100012
}

DiscountRules — Returns a list of discount rules with ordering, filters, and search

query DiscountRules(
  $where: QueryDiscountRulesWhereWhereConditions,
  $orderBy: [QueryDiscountRulesOrderByOrderByClause!],
  $search: String
) {
  DiscountRules(
    where: $where
    orderBy: $orderBy
    search: $search
  ) {
    data {
      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"
}

Available fields

FieldTypeDescription
idIntUnique identifier of the discount rule.
labelStringLabel of the discount rule.
activeBooleanWhether the discount rule is active.
targetTargetTarget of the discount rule (document, product, shipping_cost).
originDiscountRuleOriginal discount rule this rule is based on.
started_atDateStart date of the discount rule.
ended_atDateEnd date of the discount rule.
intervals[DiscountInterval]Discount intervals for the rule.
start_date_conditionDateStart date condition for the discount.
end_date_conditionDateEnd 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.

Filters

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" }

Sorting

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 }]
  ) {
    data {
      id
      label
      active
      target
      started_at
      ended_at
    }
  }
}

Example of data returned

{
  "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
      }
    ]
  }
}

Data Types

DiscountRuleInterval

FieldTypeDescription
idIntInterval ID.
interval_start_typeIntervalStartTypeType of interval start (amount, quantity).
interval_start_valueFloatValue for the interval start.
discount_typeDiscountTypeType of discount (amount, percentage).
discount_valueFloatValue of the discount.

DiscountRuleConditionOperator

FieldTypeDescription
conditionable_typeStringCondition group the operator applies to (ProductTag, CustomerTag, SupplierTag, Supplier, Season).
operatorDiscountRuleConditionsOperatorHow the values of that group combine.

Enums

DiscountRule

FieldTypeDescription
idIntDiscount rule ID.
labelStringRule label.
activeBooleanWhether active.

DiscountInterval

FieldTypeDescription
idIntInterval ID.
interval_start_typeIntervalStartTypeType of interval start.
interval_start_valueFloatValue for the interval start.
discount_typeDiscountTypeType of discount.
discount_valueFloatValue of the discount.

Target

ValueDescription
documentDiscount applies to the entire document.
productDiscount applies to specific products.
shipping_costDiscount applies to shipping costs.

DiscountRuleScope

ValueDescription
salesRule applies to sales documents only.
purchasesRule applies to purchase documents only.
bothRule applies to both sales and purchases.

DiscountRuleConditionsOperator

ValueDescription
andAll conditions of the group must match.
orAt least one condition of the group must match.