We noticed a weird behaviour in the GraphQL draftOrderCalculate mutation which might be a bug. This is the setup:
- We have an app installed called FeeBee that uses a cart transform function to expand our products with a bottle deposit product
- When calling the draftOrderCalculate mutation with a line item discount, we get an exception
- If we disable FeeBee, everything works fine. So my guess is that the cart transform breaks the discount distribution
- I have tested this with all available API versions
Mutation:
mutation ($input: DraftOrderInput!) {
draftOrderCalculate(input: $input) {
calculatedDraftOrder {
availableShippingRates {
handle
price {
amount
currencyCode
}
title
}
lineItems {
bundleComponents {
title
}
variant {
id
}
originalUnitPriceSet {
presentmentMoney {
amount
}
}
}
lineItemsSubtotalPrice {
presentmentMoney {
amount
}
}
shippingLine {
shippingRateHandle
title
taxLines {
priceSet {
presentmentMoney {
amount
}
}
rate
}
}
taxesIncluded
taxLines {
priceSet {
presentmentMoney {
amount
}
}
rate
}
totalPriceSet {
presentmentMoney {
amount
}
}
totalShippingPriceSet {
presentmentMoney {
amount
}
}
totalTaxSet {
presentmentMoney {
amount
}
}
}
userErrors {
message
field
}
}
}
Variables:
{
"input": {
"billingAddress": {
"address1": "Musterstraße 123",
"city": "Karlsruhe",
"company": "",
"countryCode": "DE",
"firstName": "Max",
"lastName": "Muster",
"provinceCode": "",
"zip": "76137"
},
"purchasingEntity": {
"customerId": "gid://shopify/Customer/23033114198389"
},
"lineItems": [
{
"appliedDiscount": {
"amountWithCurrency": {
"amount": "7.85",
"currencyCode": "EUR"
},
"value": 7.85,
"valueType": "FIXED_AMOUNT"
},
"quantity": 2,
"variantId": "gid://shopify/ProductVariant/46611957809404"
}
],
"shippingAddress": {
"address1": "Musterstraße 123",
"city": "Karlsruhe",
"company": "",
"countryCode": "DE",
"firstName": "Max",
"lastName": "Muster",
"provinceCode": "",
"zip": "76137"
},
"shippingLine": {
"priceWithCurrency": null,
"shippingRateHandle": "f353893d3d00300e39d1ec83f9956055",
"title": null
},
"useCustomerDefaultAddress": false,
"presentmentCurrencyCode": "EUR"
}
}
Response:
{
"data": {
"draftOrderCalculate": {
"calculatedDraftOrder": null,
"userErrors": [
{
"message": "Applied discount value can have at most 2 digits after decimal point",
"field": [
"lineItems",
"0",
"appliedDiscount",
"value"
]
}
]
}
},
"extensions": {
"cost": {
"requestedQueryCost": 17,
"actualQueryCost": 10,
"throttleStatus": {
"maximumAvailable": 2000,
"currentlyAvailable": 1990,
"restoreRate": 100
}
}
}
}
My Findings
- The error only happens when the cart transform is enabled
- The error only happens when there is a line item discount
- The error only happens when the item quantity is > 1
- The error does not occur when we increase the discount to 7.86. However, the error re-occurs when we increase the line item quantity to e.g. 7
- My guess is that splitting the discount between the expanded sub-items is broken