Hello Shopify Community,
I’m currently working on integrating draft orders via the Shopify Admin API, and I need assistance with a mutation request for creating draft orders. However, I’m encountering the following error:
Error: “Applied discount value can have at most 2 digits after decimal point”
Here’s the mutation query I’m trying to use:
mutation DraftOrderCreate($input: DraftOrderInput!) {
draftOrderCreate(input: $input) {
draftOrder {
id
}
userErrors {
field
message
}
}
}
payload = {
"query": '''
mutation DraftOrderCreate($input: DraftOrderInput!) {
draftOrderCreate(input: $input) {
draftOrder {
id
}
userErrors {
field
message
}
}
}
''',
"variables": {
"input": {
"email": "member@myapp.dev",
"taxExempt": True,
"tags": "myapp-order",
"lineItems": [
{
"variantId": "gid://shopify/ProductVariant/{id}",
"quantity": 5,
"appliedDiscount": {
"amount": "6.98", # This is where the error seems to occur
"description": "Price Difference",
"value": 6.98, # This is where the error seems to occur
"valueType": "FIXED_AMOUNT"
}
}
],
"shippingAddress": {
"firstName": "Van Beek",
"address1": "Cedar Ln",
"address2": "",
"phone": "xxxx",
"city": "Rock",
"province": "Iowa",
"country": "United States",
"zip": "51246"
},
"billingAddress": {
"firstName": "Van Beek",
"address1": "Cedar Ln",
"address2": "",
"phone": "xxx",
"city": "Rock",
"province": "Iowa",
"country": "United States",
"zip": "51246"
},
"shippingLine": {
"price": "5.95",
"title": "Shipping"
}
}
}
}
- I’m getting the error related to the discount value having more than 2 digits after the decimal point, but the amount is already set to “6.98”. Are there any other issues that might cause this error?
- Is there a way to ensure that the discount value is formatted correctly for Shopify’s API?
Thanks in advance for any guidance!