Calculate shipping rate with draft order api

Solved
zivmiz
Shopify Partner
3 0 1

Hi,

I'm developing a custom app and I'm trying to create a draft order with the calculation of shipping via API.

The problem is that I don't have the shipping rates options.

How can I get the shipping rates of a specific draft order?

like there is in checkout api?

_JB
Shopify Staff
Shopify Staff
834 98 188

Hey @zivmiz,

 

Just wanted to let you know we're looking in to this. The documentation definitely makes it seem like you can calculate shipping rates using this endpoint, but to be honest I don't remember ever seeing that and I'm not seeing a way to do it now. I'll post back here when I have an update for you.

JB | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

Brett13
Tourist
4 1 4

I'm also facing this issue.  I need to get the shipping rates for a draft order to be able to set the shipping_line of the draft order.  Any updates on this?

nepthar
Tourist
5 0 2

Hey guys,

Just want to throw my two cents in here! I've also been trying to get this to work based on what I read in the docs, but I can't figure it out. Seems like I'm not alone! Any word on a possible fix?

Brett13
Tourist
4 1 4

This is an accepted solution.

I did find a way to get this working.  Take a look at the Checkouts API.  There is an endpoint to shipping_rates.json that returns the shipping rates.  All you need is the checkout token.  I was able to get this from the draft order's invoice URL. For example, draft order invoice URL: https://apple.myshopify.com/690933842/invoices/d64d93d528cfc75c0876183d58f4a has checkout token: d64d93d528cfc75c0876183d58f4a.

https://shopify.dev/docs/admin-api/rest/reference/sales-channels/checkout?api[version]=2020-04

Screen Shot 2020-08-04 at 11.38.27 AM.png

nepthar
Tourist
5 0 2

Thanks for that follow up! I'm going to give it a try now. Out of curiosity, are you a "Sales Channel"?

Brett13
Tourist
4 1 4

Sure no problem.  No, I'm not a sales channel.  Just a software developer from Unific dealing with this issue myself.

0 Likes
NiceTeam
Excursionist
15 0 12

The problem with the solution here is that this endpoint is only available to Sales Channels. It can't be used by normal apps.
As far as I know, there is still no way to get the shipping rate for draft order without specifying it by yourself.

0 Likes
tolgapaksoy
Shopify Partner
73 5 40

Use the Storefront API to fetch the shipping rates on the frontend/client.

We use this exact trick with DraftOrder API, and use the checkout token in the invoice URL as a checkout ID. This checkout ID is used client-side to query for shipping rates.

0 Likes
NiceTeam
Excursionist
15 0 12

@tolgapaksoyThank you for this information. It seems like this should work Will try it out.

0 Likes