CartDiscount
Describes a cart discount, including title, description, discount percentage, type, code, and total amount.
Type Definition
type CartDiscount {
title: String
description: String
discountPercent: Float
type: String
code: String
amount: Float
totalAmount: Float
totalSavings: Float
}
Fields
Field | Type | Nullable | Description | Related Types |
---|---|---|---|---|
title | String | Yes | Returns the title of the discount. | None |
description | String | Yes | Returns the description of the discount. | None |
discountPercent | Float | Yes | Returns the discount percentage applied. | None |
type | String | Yes | Returns the discount type (e.g., coupon, automatic). | None |
code | String | Yes | Returns the discount code for coupons. | None |
amount | Float | Yes | Returns the discount amount in the customer’s currency. | None |
totalAmount | Float | Yes | Returns the total discount amount in the customer’s currency. | None |
totalSavings | Float | Yes | Returns the total savings in the customer’s currency. | None |
Relationships
The CartDiscount
object type does not have explicit relationships to other object types defined in the source material. It primarily represents discount details applied to a cart and is typically nested within cart-related queries or mutations.
Usage Examples
Basic Query
query {
cartDiscount {
title
description
discountPercent
type
code
amount
totalAmount
totalSavings
}
}
Field Selection
query {
cartDiscount {
title
discountPercent
code
}
}
Nested Queries
query {
cart(id: 98765) {
discounts {
title
description
amount
totalSavings
}
}
}
Filtering and Sorting
The CartDiscount
type itself does not support filtering or sorting fields directly. These operations should be performed at the parent level (e.g., filtering discounts within a cart or order) if supported by the API.
Implements
The CartDiscount
type does not implement any interfaces as per the provided source.
Connections
No connection fields or pagination are defined for CartDiscount
in the source material.
Related Types
While not explicitly defined in the source, CartDiscount
is commonly related to cart or order types where discounts are applied. For example, it may be nested inside a Cart
object under a discounts
field.
Best Practices
- Always check for nullability on all fields since all fields in
CartDiscount
are optional. - Use the
code
field to identify coupon-based discounts uniquely. - Use
discountPercent
andamount
fields together to understand the discount impact. - When querying multiple discounts on a cart, retrieve
totalAmount
andtotalSavings
to summarize the overall discount effect. - Avoid requesting all fields if only a subset is needed to reduce response size and improve performance.
Notes
- All monetary fields (
amount
,totalAmount
,totalSavings
) are returned in the customer’s currency. - The API currently requires no authentication but this may change in future versions.
- Since all fields are optional, clients should implement proper null checks to avoid runtime errors.
- There are no computed or derived fields explicitly defined for
CartDiscount
. - No field arguments are defined for this type.
- Performance considerations: Minimize requested fields to improve response times, especially when querying multiple discounts within large carts.