GraphQL mutation - discount problems

GabrielaReckitt
New Member
1 0 1

Hello everyone,

I'm developing my app in flutter. I'm trying to make shopify checkout inside our app and we would like to use my custom UI - not webview. To do that I was trying to use GrapghQL with below mutation:

 

mutation checkoutDiscountCodeApply($checkoutId : ID!, $discountCode : String!) {
checkoutDiscountCodeApplyV2(checkoutId: $checkoutId, discountCode: $discountCode) {
checkout {
id
lineItemsSubtotalPrice {
amount
}
shippingLine {
handle
priceV2 {
amount
}
title
}
email
requiresShipping
availableShippingRates {
ready
shippingRates {
handle
priceV2 {
amount
}
title
}
}
completedAt
createdAt
currencyCode
discountApplications(first: 10) {
edges {
node {
targetType 
value {
... on PricingPercentageValue {
percentage
}
... on MoneyV2 {
amount
}
}
}
}
}
lineItems(first: 10) {
edges {
node {
id
quantity
title
variant {
id
priceV2 {
amount
currencyCode
}
title
image {
altText
originalSrc
id
}
compareAtPriceV2 {
amount
currencyCode
}
weight
weightUnit
availableForSale
sku
requiresShipping
}
}
}
}
note
webUrl
updatedAt
totalTaxV2 {
amount
currencyCode
}
totalPriceV2 {
amount
currencyCode
}
taxesIncluded
taxExempt
subtotalPriceV2 {
amount
currencyCode
}
orderStatusUrl
}
checkoutUserErrors {
message
field
code
}
}
}

 

Thanks to that I would like to handle discounts like:
-percentage
-buyXGetY
-fixedAmount
-freeShipping 

When the discount applies to all products - then everything works ok. But when it's not, e.g. it's for a specific product, I don't know how to get information about this product ID's from response which discount can be applied. I couldn't find any information about it in documentation.