We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

DraftOrderCreate - "Applied discount value can have at most 2 digits after decimal point"

DraftOrderCreate - "Applied discount value can have at most 2 digits after decimal point"

ravimobifyi
Shopify Partner
10 1 0

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!

Reply 1 (1)

ravimobifyi
Shopify Partner
10 1 0

can anyone help ?