I need to create a draft order from an existing order via a POS extension. I’m currently using the draftOrderCreateFromOrder admin API endpoint to do this, but am unable to see the new draft in the POS app.
I saw some old posts indicating that this might be due to the source value of the draft order causing it to be filtered out. Can anyone confirm if this is the root of the problem? If so, is there any way I can modify the draft order so that it becomes visible in the POS?
Just confirming what you found in those older threads. The Drafts list in POS only surfaces drafts that were created in POS or directly in the admin (that’s the “Sale type: POS / Admin” filter you see there). Anything created through the Admin API, including draftOrderCreateFromOrder, gets attributed to the app that made the call, so it’s filtered out. Liam confirmed this a while back here as well: Creating POS Orders via API / Draft Order Visibility - #2 by Liam-Shopify
Right now, there’s not way to change that after the fact unfortunately. DraftOrderInput and draftOrderUpdate don’t expose a source field, so right now, you can’t flip an API-created draft into one POS will pick up. I definitely get that’s not super ideal.
That said, since you’re working from inside a POS extension there may be a way around it depending on what you’re actually trying to accomplish. A few questions so I can point you in the right direction:
What’s the end goal for the draft once it’s created? For example, is staff meant to load it and take payment right away on the same device, or does it need to sit there so someone can pick it up later (possibly from a different register or location)?
Which target is your extension rendering from - pos.order-details.action.render, a home tile/modal, or something else?
Is there anything the draft needs to carry over from the original order beyond line items and the customer - things like custom items, discounts, notes, or shipping?
Depending on the answers, one direction that might work is skipping the draft entirely and using the Cart API to rebuild the cart from the original order directly in POS (if that would work for you) - staff could then check out or save it as a POS-sourced draft from there. But I’d rather understand the flow first before suggesting that, since it doesn’t fit every case.
Thanks for the quick response @Alan_G. Just a pity it’s not the answer I was hoping for.
Unfortunately, I’m not sure the alternative approach you suggested will work for us. Our extension is rendering from the pos.purchase.post.action.render target which, as far as I can tell, doesn’t have access to the Cart API.
Out of interest, do you happen to know why app source drafts are filtered from the POS? Also, are there any plans to alter this behaviour?