draftOrderCreate() only recognizes custom shippingLine

mfio
New Member
2 0 0

I was having issues getting the GraphQL API to recognize the shippingLine I was passing in. I found this thread that mentions omitting the shippingRateHandle. That works, but then it always creates a custom shippingLine:

 

 

   "shippingLine": {
          "id": "gid:\/\/shopify\/ShippingLine\/347937505456?type=draft_order",
          "title": "Economy",
          "code": "custom",
          "shippingRateHandle": null,
          "originalPriceSet": {
            "presentmentMoney": {
              "amount": "4.9",
              "currencyCode": "USD"
            }
          }
        }

 

 

How do I go about creating a non-custom shippingLine? I inspected the Network Tab while creating a draft order in Shopify's own admin interface at x.myshopify.com/admin/  - there it clearly requests the shippingLine with a specific shippingRateHandle and in the response it is evident that the shippingLine is not custom. I took the GraphQL payload from there and used it exactly with my own credentials, with no luck. Just to be sure I checked the permissions for my private app and added anything that sounded order-related.

What am I doing wrong?

Replies 2 (2)
GrahamS
Shopify Staff
154 25 32

Hey @mfio ,

 

Have you tried using draftOrderCalculate to generate the content for availableShippingRates and then copying out that info for your draftOrderCreate shipping input? I ran a test using this method and was able to successfully utilize a non-custom shipping line:

 

29-57-ce47n-vitdt

29-56-2yaqc-1964j

29-58-uzjik-8t4nw

29-00-zrky4-wqf1f

Graham S | API 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

mfio
New Member
2 0 0

Thank you for the response @GrahamS.

 

That is exactly what I tried to do. If I do it like you have shown, what I get back is:

 

"shippingLine": null

 

In order to make it work I omit the handle in the input, but what I get back is a custom shipping line:

        "shippingLine": {
          "title": "Economy International",
          "code": "custom",
          "shippingRateHandle": null,
          "originalPriceSet": {
            "presentmentMoney": {
              "amount": "12.0",
              "currencyCode": "USD"
            }
          }
        }

 

I'm guessing there is something else in my request that triggers this. I would probably have to provide you with a minimal example, but it's hard to anonymize everything. Is there somewhere I can post you the info in private?