I have a GWP discount using the Discount API which works well, however, I can’t seem to find a way to calculate the new subtotal when an order discount code is applied where the new subtotal may not meet the GWP threshold which would result the cart to not qualify for the FREE GWP.
I have the following for my CartInput query:
query CartInput {
cart {
discountApplications {
targetType
totalAllocatedAmount {
amount
}
}
lines {
id
quantity
merchandise {
__typename
... on ProductVariant {
id
}
}
cost {
subtotalAmount {
amount
}
totalAmount {
amount
}
}
}
cost {
subtotalAmount {
amount
}
totalAmount {
amount
}
totalDutyAmount {
amount
}
totalTaxAmount {
amount
}
}
}
discount {
discountClasses
metafield(namespace: "$app", key: "gwp-discount-config") {
value
}
}
}
and then the Input (STDIN) that is logged from the function returns as:
{
"cart": {
"discountApplications": [],
"lines": [
{
"id": "gid:\/\/shopify\/CartLine\/0",
"quantity": 1,
"merchandise": {
"__typename": "ProductVariant",
"id": "gid:\/\/shopify\/ProductVariant\/43120043786440"
},
"cost": {
"subtotalAmount": {
"amount": "89.0"
},
"totalAmount": {
"amount": "89.0"
}
}
},
{
"id": "gid:\/\/shopify\/CartLine\/1",
"quantity": 1,
"merchandise": {
"__typename": "ProductVariant",
"id": "gid:\/\/shopify\/ProductVariant\/43118909194440"
},
"cost": {
"subtotalAmount": {
"amount": "89.0"
},
"totalAmount": {
"amount": "89.0"
}
}
}
],
"cost": {
"subtotalAmount": {
"amount": "178.0"
},
"totalAmount": {
"amount": "178.0"
},
"totalDutyAmount": null,
"totalTaxAmount": null
}
},
"discount": {
"discountClasses": [
"PRODUCT",
"ORDER"
],
"metafield": {
"value": "{\"tiers\":[{\"priceThreshold\":89,\"gwpVariantId\":\"gid:\/\/shopify\/ProductVariant\/43118909194440\",\"maxUnitsToApply\":1}]}"
}
}
}
The input log above show’s that even when a discount code is applied, the subtotalAmount and totalAmount are the same. Is there a way for functions to read order discount values? Or is this a known limitation where order discounts are executed after Discount API functions run?