Use the DraftOrder and Checkout resources to create a checkout from a draft order

amosmos
Shopify Expert
64 1 23

Hello,

 

The DraftOrder API documentation has this:

draft.png

 

Look at that last bullet: "Use the DraftOrder and Checkout resources to create a checkout from a draft order (sales channel apps only)."

 

But I couldn't find any explanation on how to do this. How to convert a draftorder object into a checkout object to be used with the checkout API.

 

I tried looking for a checkout ID or checkout token, but it's not there. Not even when completing the draftorder.

 

Can anyone clarify?

 

Thanks!

Amos

0 Likes
Alex
Shopify Staff
Shopify Staff
1555 81 306

This looks like it can be phrased better. This sentence was refactored around 4 months ago from: 

 

Use Draft Orders API in conjunction with the Checkouts API by creating a Checkout object based on a draft order (Sales Channel SDK only). based on a draft order (Sales Channel SDK only).

 

I'm going to get that corrected so it's less confusing, but I guess what it's trying to say is that you can use the draft orders API to template a checkout, and then create a checkout from what you end up with on your nearly finished draft order.

 

Cheers.

0 Likes
tolgapaksoy
Shopify Partner
73 5 41

@Alex Is it correct though that you can exactly template a Checkout by a DraftOrder?

 

In DraftOrders, you're allowed to use (custom) discounts per line item. I can't see a possibility for this using the Checkout API?

0 Likes
amosmos
Shopify Expert
64 1 23

@Alex  - Thank so much for clearing it out, but what I still don't understand, and nowhere in the documentation or the forums it is explained, is:

 

How do I create a checkout from what I end up with on my nearly finished draft order?

 

It is quite what I understood too from the remark in the documentation, just don't understand how to do it.

 

I do believe it's possible because that's what the Shopify admin is probably doing - you create a draft order, and then you can send an email to the customer with a link to complete a checkout. I really want to know how to do it too :-)

0 Likes
tolgapaksoy
Shopify Partner
73 5 41

Yo @amosmos, I just found out that if you visit the draft_order.invoice_url, it will redirect you automatically to a checkout that is prefilled with all the DraftOrder line items, shipping lines and discounts.

0 Likes
amosmos
Shopify Expert
64 1 23

@tolgapaksoy Thanks! Yes I'm aware of this, but it's not a checkout resource that I can use with the checkout API.

 

One example of the benefits of transforming a draft order into a checkout resource is that it will allow to add discounts (predefined in the store) to the order...

 

Amos

0 Likes
gabrielnaologic
New Member
1 0 0

No, you are not. No matter what you send in `applied_discounts` fails. You can't use discount codes on Draft Orders

0 Likes
amosmos
Shopify Expert
64 1 23

@gabrielnaologic I know you can't add discount codes to draft orders.

That's why I am looking to create a checkout object from the draft order, because you can add discount codes to a checkout object.

That's the whole point of this post.

 

Amos

0 Likes
JMartinezFSL
New Member
3 0 0

The only way I found is to update cart from draft order a then checkout.

0 Likes
amosmos
Shopify Expert
64 1 23

Hi @JMartinezFSL ,

That KS for your note.

How do you update cart from draft order?

Thanks,

Amos

0 Likes