Skip to main content
Version: 1.0.0

CartRulesQuery

Description

Returns all cart rules configured in the system. Cart rules define conditions and actions that can be applied to shopping carts, such as discounts, free shipping, or other promotions.

Endpoint

query allCartRules {
allCartRules {
# Return fields
}
}

Arguments

This query does not accept any arguments.

Return Values

The query returns an array of CartRule objects with the following fields:

FieldTypeDescription
idInt!The unique identifier for the cart rule.
nameString!The name of the cart rule.
descriptionStringA description of the cart rule, explaining its purpose or conditions.
discountAmountFloatThe amount of discount provided by the rule, if applicable.
isActiveBoolean!Indicates whether the rule is currently active and can be applied to carts.
conditionsStringA string representation of the conditions that must be met for the rule to apply.

Usage Example

query {
allCartRules {
id
name
description
discountAmount
isActive
conditions
}
}

Example Response

{
"data": {
"allCartRules": [
{
"id": 1,
"name": "Free Shipping Over $100",
"description": "Orders over $100 get free shipping",
"discountAmount": 0,
"isActive": true,
"conditions": "subtotal > 100"
},
{
"id": 2,
"name": "10% Off All Orders",
"description": "10% discount on all orders",
"discountAmount": 10,
"isActive": true,
"conditions": null
}
]
}
}

Notes

  • This query returns all cart rules configured in the system, regardless of whether they are active or not.
  • The isActive field can be used to determine if a rule is currently in effect.
  • The conditions field provides a string representation of the conditions that must be met for the rule to apply. The format of this string depends on the implementation of the cart rule system.
  • Cart rules are typically configured by store administrators and are not meant to be modified through the GraphQL API.
  • This query is useful for displaying available promotions to customers or for understanding what rules might be applied to a cart.