Cannot subscriptionDraftLineRemove on lines with discount code applied

Topic summary

Issue: Removing a subscription draft line that has a discount applied causes subscriptionDraftCommit to fail with “Contract draft discount with title: ‘my discount code’ is invalid.”

Cause: The discount targets the specific line. When the line is removed, the discount’s target becomes invalid, blocking commit.

Recommended approaches:

  • Update the draft discount’s targets before/after removing the line by adjusting entitledLines via subscriptionDraftDiscountUpdate (use SubscriptionManualDiscountLinesInput.remove).
  • Practical workaround: If an edit/remove triggers the error, first remove the specific discount with subscriptionDraftDiscountRemove, then modify the line, and re-apply/adjust discounts as needed.

Outcome: A working process was confirmed—remove or retarget the discount before committing changes. This may require multiple API calls but resolves the error.

Status: Not a platform bug; behavior is due to discount targeting rules. Discussion concludes with a viable workaround and guidance on updating discount targets. No media or code snippets are central to understanding.

Summarized with AI on February 23. AI used: gpt-5.

I cannot remove a line that has a discount code applied using the mutation subscriptionDraftLineRemove.

I get the error below when I call subscriptionDraftCommit. (after calling subscriptionDraftLineRemove)

Contract draft discount with title: “my discount code” is invalid

Can this be an issue on the Shopify side? Or should I do something else to remove a subscription line with a discount code applied?

1 Like

Did you ever find the solution to this? I’m getting the same error.

If there’s an existing discount targeting a line in your subscription, and that line gets removed you will get the error because the discount no longer points at a valid target.

Have you tried updating the discount by changing the entitledLines? (`

SubscriptionManualDiscountLinesInput.remove`)

https://shopify.dev/api/admin-graphql/2022-01/mutations/subscriptionDraftDiscountUpdate#returns

@Philibert_Dugas Thanks for the tip in the right direction. What we ended up doing is if the attempt to amend the draft line returned that error, we used subscriptionDraftDiscountRemove to remove the specific discount applied before attempting to edit the line again. It’s a little clunky and requires quite a few API calls but it works.

2 Likes