Skip to Content
StoreOSv0.27.1
Storefront GraphQL APIReferenceQueries

Preview Discounts

QUERYpreviewDiscounts(input: PreviewDiscountsInput!): PreviewDiscountsResponse!

Arguments

input*

Returns

  1. previewDiscounts
subtotal*Float!
deliveryCharge*Float!
applications*
lineAllocations*
productDiscount*Float!
orderDiscount*Float!
shippingDiscount*Float!
discountTotal*Float!
totalAfterDiscount*Float!

subtotal + deliveryCharge - discountTotal (before tax).

hints*
code?String

Normalised code when the entered code was applied.

codeError?String

Why 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  }}
Variables
{  "input": {    "lineItems": [      {        "productId": "1",        "quantity": 10      }    ]  }}
Example Response
{  "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"    }  }}