Thanks for clarifying, that makes the percentage discount question straightforward.
The orderEditAddLineItemDiscount mutation supports percentage discounts natively through the percentValue field on OrderEditAppliedDiscountInput. So for your percentage case, the flow is similar to the fixed-amount workaround but you pull the percentage from discountApplications instead of reading allocatedAmountSet:
query {
order(id: "gid://shopify/Order/ORDER_ID") {
discountApplications(first: 10) {
nodes {
... on DiscountCodeApplication {
code
value {
... on PricingPercentageValue {
percentage
}
}
}
}
}
}
}
If the value comes back as PricingPercentageValue with percentage: 11, then after removing “Banana” and adding “Cake”, apply it to the new line item with percentValue instead of fixedValue:
{
"discount": {
"percentValue": 11,
"description": "Reapplied order discount"
}
}
I tested this on my own store with a 15% order discount. After removing one item and adding a replacement, orderEditAddLineItemDiscount with percentValue: 15 applied exactly 15% of the new item’s price as the discount allocation. The full flow (begin edit, set quantity to 0, add variant, apply percentage discount, commit) completed without errors. Since “Cake” is the same price as “Banana”, this gives you the same order total before and after the edit.
For the second question about splitting “Chocolate-Shake” into “Chocolate” + “Milk”, the error you’re getting is expected. You can’t add a manual discount (including a 100% discount) to a line item that already has a discount code applied.
The standard approach for this swap should still work though. You can remove “Chocolate-Shake” by setting its quantity to 0 with orderEditSetQuantity, then add “Chocolate” and “Milk” as new line items. Setting quantity to 0 is allowed even on discounted items (I confirmed this in the same test, removing a line item with a discount applied worked with no errors). The restriction is on partial quantity changes and discount modifications, not full removal.
On your cancellation concern, when you remove “Chocolate-Shake” via order edit, the order total adjusts at that point. If the order is later cancelled, the refund is based on the current order state (Chocolate + Milk), not the pre-edit state. The removed “Chocolate-Shake” won’t factor into the refund calculation. The order timeline will show both the edit removal and the cancellation as separate events, but the financials should be correct.