Facing issue in orderEditAddLineItemDiscount mutation

mutation

mutation orderEditAddLineItemDiscount($id: ID!, $lineItemId: ID!, $discount: OrderEditAppliedDiscountInput!) {
orderEditAddLineItemDiscount(id: $id, lineItemId: $lineItemId, discount: $discount) {
addedDiscountStagedChange {
id
}
calculatedLineItem {
id
}
calculatedOrder {
id
}
userErrors {
field
message
}
}
}

getting error

{
“field”: [
“lineItemId”
],
“message”: “Only items added during the current edit may be discounted.”
}

The line item id you inputted is not correct. If you add a new variant to the order, then use the calculatedLineItemID returned from the response. It should be ok.

The graphQL sequence:

  1. OrderEditBegin
  2. Add a new variant
  3. Add discount to the new variant
  4. CommitEdit