Storefront GraphQL APIReferenceQueries
Preview Discounts
QUERY
previewDiscounts(input: PreviewDiscountsInput!): PreviewDiscountsResponse!Arguments
input*Returns
- previewDiscounts
subtotal*Float!deliveryCharge*Float!applications*lineAllocations*productDiscount*Float!orderDiscount*Float!shippingDiscount*Float!discountTotal*Float!totalAfterDiscount*Float!subtotal + deliveryCharge - discountTotal (before tax).
hints*code?StringNormalised code when the entered code was applied.
codeError?StringWhy the entered code was not applied.
Example Request
query PreviewDiscounts($input: PreviewDiscountsInput!) { previewDiscounts(input: $input) { subtotal deliveryCharge applications { discountId title type method code amount } lineAllocations { index productId variantId discountAmount discountedUnits discountId } productDiscount orderDiscount shippingDiscount discountTotal totalAfterDiscount code }}{ "input": { "lineItems": [ { "productId": "1", "quantity": 10 } ] }}{ "data": { "previewDiscounts": { "subtotal": 10.5, "deliveryCharge": 10.5, "applications": [ { "discountId": "string", "title": "string", "type": "PRODUCT_AMOUNT", "method": "CODE", "code": "string", "amount": 10.5 } ], "lineAllocations": [ { "index": 10, "productId": "string", "variantId": "string", "discountAmount": 10.5, "discountedUnits": 10, "discountId": "string" } ], "productDiscount": 10.5, "orderDiscount": 10.5, "shippingDiscount": 10.5, "discountTotal": 10.5, "totalAfterDiscount": 10.5, "code": "string" } }}