Hi, Developer Team
I wonder that is there any way to remove unpaid order line items via admin REST API or admin GraphQL?
Hi, Developer Team
I wonder that is there any way to remove unpaid order line items via admin REST API or admin GraphQL?
Hi @Julian29 - thanks for reaching out. This is a great question! There is a way to remove unpaid order line items through our GraphQL Admin API. There’s a guide here in our docs that goes over how to use the API to make edits to existing orders. You’ll want to use the orderEditSetQuantity mutation to do this. Basically, in the API call’s variables, you would just want to set the line item’s quantity value to 0 and it will remove the unpaid line item from the order.
Hope this helps - let us know if we can clarify anything on our end.
Hi ShopifyDevSup,
Thank you for your answer.
Actually, I know how to edit existing orders. However, I have no idea which order line item is unpaid.
Hi @Julian29 !
TL;DR: There is no single API call that can determine which item is “unpaid” because this is a fundamental misunderstanding of the Order object. Developing an app around this idea requires a clear purpose and for the app to do the logic.
Adding a product to an Order increases the total cost of the Order, so there is no specific “unpaid item” on an Order. If a product is added to an order after payment there are many ways that payment of the order can be balanced, including removing any product or products that would bring the balance back to zero. This is fundamental to understanding a Shopify Order.
Removing an “unpaid item” with the API would require your app to determine what makes a specific item “unpaid”. Consider a merchant using the Shopify Admin to do this. The merchant knows what item they added because they added it, therefore they know what item to remove. If they forget which item they added, they can look down at the Order timeline and see when the order was paid for and what was added to the order after payment. If multiple things were added and removed, they can reason out for themselves what they consider “unpaid” and remove it.
Now consider your app that wants to remove these “unpaid” items. I can think of a few possible solutions but they require asking some questions of your app’s purpose:
I would recommend considering the relationship your app has with these “unpaid items” in terms of order flow, and then start building in a way that compliments or enhances the merchant’s experience with Shopify. Simply removing a product from an order when a customer doesn’t want to settle the bill is a function of the Shopify Admin already.